diff --git a/resource-manager/deviceprovisioningservices/2022-02-05/client.go b/resource-manager/deviceprovisioningservices/2022-02-05/client.go index 4f5932f2fb6..99b2f1cf858 100644 --- a/resource-manager/deviceprovisioningservices/2022-02-05/client.go +++ b/resource-manager/deviceprovisioningservices/2022-02-05/client.go @@ -4,9 +4,12 @@ package v2022_02_05 // 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/deviceprovisioningservices/2022-02-05/dpscertificate" "github.com/hashicorp/go-azure-sdk/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/environments" ) type Client struct { @@ -14,16 +17,21 @@ type Client struct { IotDpsResource *iotdpsresource.IotDpsResourceClient } -func NewClientWithBaseURI(endpoint string, configureAuthFunc func(c *autorest.Client)) Client { - - dpsCertificateClient := dpscertificate.NewDpsCertificateClientWithBaseURI(endpoint) - configureAuthFunc(&dpsCertificateClient.Client) - - iotDpsResourceClient := iotdpsresource.NewIotDpsResourceClientWithBaseURI(endpoint) - configureAuthFunc(&iotDpsResourceClient.Client) +func NewClientWithBaseURI(api environments.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + dpsCertificateClient, err := dpscertificate.NewDpsCertificateClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building DpsCertificate client: %+v", err) + } + configureFunc(dpsCertificateClient.Client) - return Client{ - DpsCertificate: &dpsCertificateClient, - IotDpsResource: &iotDpsResourceClient, + iotDpsResourceClient, err := iotdpsresource.NewIotDpsResourceClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building IotDpsResource client: %+v", err) } + configureFunc(iotDpsResourceClient.Client) + + return &Client{ + DpsCertificate: dpsCertificateClient, + IotDpsResource: iotDpsResourceClient, + }, nil } diff --git a/resource-manager/deviceprovisioningservices/2022-02-05/dpscertificate/client.go b/resource-manager/deviceprovisioningservices/2022-02-05/dpscertificate/client.go index f19ccff4a47..9bcbdae2f39 100644 --- a/resource-manager/deviceprovisioningservices/2022-02-05/dpscertificate/client.go +++ b/resource-manager/deviceprovisioningservices/2022-02-05/dpscertificate/client.go @@ -1,18 +1,26 @@ package dpscertificate -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 DpsCertificateClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewDpsCertificateClientWithBaseURI(endpoint string) DpsCertificateClient { - return DpsCertificateClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewDpsCertificateClientWithBaseURI(api environments.Api) (*DpsCertificateClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "dpscertificate", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DpsCertificateClient: %+v", err) } + + return &DpsCertificateClient{ + Client: client, + }, nil } diff --git a/resource-manager/deviceprovisioningservices/2022-02-05/dpscertificate/constants.go b/resource-manager/deviceprovisioningservices/2022-02-05/dpscertificate/constants.go index 996b4144ec0..aaae04cf495 100644 --- a/resource-manager/deviceprovisioningservices/2022-02-05/dpscertificate/constants.go +++ b/resource-manager/deviceprovisioningservices/2022-02-05/dpscertificate/constants.go @@ -1,6 +1,10 @@ package dpscertificate -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. @@ -19,6 +23,19 @@ func PossibleValuesForCertificatePurpose() []string { } } +func (s *CertificatePurpose) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCertificatePurpose(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseCertificatePurpose(input string) (*CertificatePurpose, error) { vals := map[string]CertificatePurpose{ "clientauthentication": CertificatePurposeClientAuthentication, diff --git a/resource-manager/deviceprovisioningservices/2022-02-05/dpscertificate/method_createorupdate.go b/resource-manager/deviceprovisioningservices/2022-02-05/dpscertificate/method_createorupdate.go new file mode 100644 index 00000000000..2b7da1aef35 --- /dev/null +++ b/resource-manager/deviceprovisioningservices/2022-02-05/dpscertificate/method_createorupdate.go @@ -0,0 +1,84 @@ +package dpscertificate + +import ( + "context" + "fmt" + "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 *CertificateResponse +} + +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 DpsCertificateClient) CreateOrUpdate(ctx context.Context, id CertificateId, input CertificateResponse, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/deviceprovisioningservices/2022-02-05/dpscertificate/method_createorupdate_autorest.go b/resource-manager/deviceprovisioningservices/2022-02-05/dpscertificate/method_createorupdate_autorest.go deleted file mode 100644 index 1235de605bb..00000000000 --- a/resource-manager/deviceprovisioningservices/2022-02-05/dpscertificate/method_createorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package dpscertificate - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// 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 - Model *CertificateResponse -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c DpsCertificateClient) CreateOrUpdate(ctx context.Context, id CertificateId, input CertificateResponse, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "dpscertificate.DpsCertificateClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "dpscertificate.DpsCertificateClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "dpscertificate.DpsCertificateClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c DpsCertificateClient) preparerForCreateOrUpdate(ctx context.Context, id CertificateId, input CertificateResponse, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateOrUpdate handles the response to the CreateOrUpdate request. The method always -// closes the http.Response Body. -func (c DpsCertificateClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/deviceprovisioningservices/2022-02-05/dpscertificate/method_delete.go b/resource-manager/deviceprovisioningservices/2022-02-05/dpscertificate/method_delete.go new file mode 100644 index 00000000000..5e37cd6e82f --- /dev/null +++ b/resource-manager/deviceprovisioningservices/2022-02-05/dpscertificate/method_delete.go @@ -0,0 +1,107 @@ +package dpscertificate + +import ( + "context" + "fmt" + "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 +} + +type DeleteOperationOptions struct { + CertificateCreated *string + CertificateHasPrivateKey *bool + CertificateIsVerified *bool + CertificateLastUpdated *string + CertificateName *string + CertificateNonce *string + CertificatePurpose *CertificatePurpose + CertificateRawBytes *string + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.CertificateCreated != nil { + out.Append("certificate.created", fmt.Sprintf("%v", *o.CertificateCreated)) + } + if o.CertificateHasPrivateKey != nil { + out.Append("certificate.hasPrivateKey", fmt.Sprintf("%v", *o.CertificateHasPrivateKey)) + } + if o.CertificateIsVerified != nil { + out.Append("certificate.isVerified", fmt.Sprintf("%v", *o.CertificateIsVerified)) + } + if o.CertificateLastUpdated != nil { + out.Append("certificate.lastUpdated", fmt.Sprintf("%v", *o.CertificateLastUpdated)) + } + if o.CertificateName != nil { + out.Append("certificate.name", fmt.Sprintf("%v", *o.CertificateName)) + } + if o.CertificateNonce != nil { + out.Append("certificate.nonce", fmt.Sprintf("%v", *o.CertificateNonce)) + } + if o.CertificatePurpose != nil { + out.Append("certificate.purpose", fmt.Sprintf("%v", *o.CertificatePurpose)) + } + if o.CertificateRawBytes != nil { + out.Append("certificate.rawBytes", fmt.Sprintf("%v", *o.CertificateRawBytes)) + } + return &out +} + +// Delete ... +func (c DpsCertificateClient) Delete(ctx context.Context, id CertificateId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + 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 + } + + return +} diff --git a/resource-manager/deviceprovisioningservices/2022-02-05/dpscertificate/method_delete_autorest.go b/resource-manager/deviceprovisioningservices/2022-02-05/dpscertificate/method_delete_autorest.go deleted file mode 100644 index 7a6c03b73ba..00000000000 --- a/resource-manager/deviceprovisioningservices/2022-02-05/dpscertificate/method_delete_autorest.go +++ /dev/null @@ -1,135 +0,0 @@ -package dpscertificate - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// 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 -} - -type DeleteOperationOptions struct { - CertificateCreated *string - CertificateHasPrivateKey *bool - CertificateIsVerified *bool - CertificateLastUpdated *string - CertificateName *string - CertificateNonce *string - CertificatePurpose *CertificatePurpose - CertificateRawBytes *string - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.CertificateCreated != nil { - out["certificate.created"] = *o.CertificateCreated - } - - if o.CertificateHasPrivateKey != nil { - out["certificate.hasPrivateKey"] = *o.CertificateHasPrivateKey - } - - if o.CertificateIsVerified != nil { - out["certificate.isVerified"] = *o.CertificateIsVerified - } - - if o.CertificateLastUpdated != nil { - out["certificate.lastUpdated"] = *o.CertificateLastUpdated - } - - if o.CertificateName != nil { - out["certificate.name"] = *o.CertificateName - } - - if o.CertificateNonce != nil { - out["certificate.nonce"] = *o.CertificateNonce - } - - if o.CertificatePurpose != nil { - out["certificate.purpose"] = *o.CertificatePurpose - } - - if o.CertificateRawBytes != nil { - out["certificate.rawBytes"] = *o.CertificateRawBytes - } - - return out -} - -// Delete ... -func (c DpsCertificateClient) Delete(ctx context.Context, id CertificateId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "dpscertificate.DpsCertificateClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "dpscertificate.DpsCertificateClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "dpscertificate.DpsCertificateClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c DpsCertificateClient) preparerForDelete(ctx context.Context, id CertificateId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c DpsCertificateClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/deviceprovisioningservices/2022-02-05/dpscertificate/method_generateverificationcode.go b/resource-manager/deviceprovisioningservices/2022-02-05/dpscertificate/method_generateverificationcode.go new file mode 100644 index 00000000000..71d676f4f09 --- /dev/null +++ b/resource-manager/deviceprovisioningservices/2022-02-05/dpscertificate/method_generateverificationcode.go @@ -0,0 +1,111 @@ +package dpscertificate + +import ( + "context" + "fmt" + "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 GenerateVerificationCodeOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VerificationCodeResponse +} + +type GenerateVerificationCodeOperationOptions struct { + CertificateCreated *string + CertificateHasPrivateKey *bool + CertificateIsVerified *bool + CertificateLastUpdated *string + CertificateName *string + CertificateNonce *string + CertificatePurpose *CertificatePurpose + CertificateRawBytes *string + IfMatch *string +} + +func DefaultGenerateVerificationCodeOperationOptions() GenerateVerificationCodeOperationOptions { + return GenerateVerificationCodeOperationOptions{} +} + +func (o GenerateVerificationCodeOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o GenerateVerificationCodeOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o GenerateVerificationCodeOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.CertificateCreated != nil { + out.Append("certificate.created", fmt.Sprintf("%v", *o.CertificateCreated)) + } + if o.CertificateHasPrivateKey != nil { + out.Append("certificate.hasPrivateKey", fmt.Sprintf("%v", *o.CertificateHasPrivateKey)) + } + if o.CertificateIsVerified != nil { + out.Append("certificate.isVerified", fmt.Sprintf("%v", *o.CertificateIsVerified)) + } + if o.CertificateLastUpdated != nil { + out.Append("certificate.lastUpdated", fmt.Sprintf("%v", *o.CertificateLastUpdated)) + } + if o.CertificateName != nil { + out.Append("certificate.name", fmt.Sprintf("%v", *o.CertificateName)) + } + if o.CertificateNonce != nil { + out.Append("certificate.nonce", fmt.Sprintf("%v", *o.CertificateNonce)) + } + if o.CertificatePurpose != nil { + out.Append("certificate.purpose", fmt.Sprintf("%v", *o.CertificatePurpose)) + } + if o.CertificateRawBytes != nil { + out.Append("certificate.rawBytes", fmt.Sprintf("%v", *o.CertificateRawBytes)) + } + return &out +} + +// GenerateVerificationCode ... +func (c DpsCertificateClient) GenerateVerificationCode(ctx context.Context, id CertificateId, options GenerateVerificationCodeOperationOptions) (result GenerateVerificationCodeOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/generateVerificationCode", id.ID()), + OptionsObject: options, + } + + 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 +} diff --git a/resource-manager/deviceprovisioningservices/2022-02-05/dpscertificate/method_generateverificationcode_autorest.go b/resource-manager/deviceprovisioningservices/2022-02-05/dpscertificate/method_generateverificationcode_autorest.go deleted file mode 100644 index 41d25d29b3b..00000000000 --- a/resource-manager/deviceprovisioningservices/2022-02-05/dpscertificate/method_generateverificationcode_autorest.go +++ /dev/null @@ -1,138 +0,0 @@ -package dpscertificate - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GenerateVerificationCodeOperationResponse struct { - HttpResponse *http.Response - Model *VerificationCodeResponse -} - -type GenerateVerificationCodeOperationOptions struct { - CertificateCreated *string - CertificateHasPrivateKey *bool - CertificateIsVerified *bool - CertificateLastUpdated *string - CertificateName *string - CertificateNonce *string - CertificatePurpose *CertificatePurpose - CertificateRawBytes *string - IfMatch *string -} - -func DefaultGenerateVerificationCodeOperationOptions() GenerateVerificationCodeOperationOptions { - return GenerateVerificationCodeOperationOptions{} -} - -func (o GenerateVerificationCodeOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o GenerateVerificationCodeOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.CertificateCreated != nil { - out["certificate.created"] = *o.CertificateCreated - } - - if o.CertificateHasPrivateKey != nil { - out["certificate.hasPrivateKey"] = *o.CertificateHasPrivateKey - } - - if o.CertificateIsVerified != nil { - out["certificate.isVerified"] = *o.CertificateIsVerified - } - - if o.CertificateLastUpdated != nil { - out["certificate.lastUpdated"] = *o.CertificateLastUpdated - } - - if o.CertificateName != nil { - out["certificate.name"] = *o.CertificateName - } - - if o.CertificateNonce != nil { - out["certificate.nonce"] = *o.CertificateNonce - } - - if o.CertificatePurpose != nil { - out["certificate.purpose"] = *o.CertificatePurpose - } - - if o.CertificateRawBytes != nil { - out["certificate.rawBytes"] = *o.CertificateRawBytes - } - - return out -} - -// GenerateVerificationCode ... -func (c DpsCertificateClient) GenerateVerificationCode(ctx context.Context, id CertificateId, options GenerateVerificationCodeOperationOptions) (result GenerateVerificationCodeOperationResponse, err error) { - req, err := c.preparerForGenerateVerificationCode(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "dpscertificate.DpsCertificateClient", "GenerateVerificationCode", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "dpscertificate.DpsCertificateClient", "GenerateVerificationCode", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGenerateVerificationCode(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "dpscertificate.DpsCertificateClient", "GenerateVerificationCode", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGenerateVerificationCode prepares the GenerateVerificationCode request. -func (c DpsCertificateClient) preparerForGenerateVerificationCode(ctx context.Context, id CertificateId, options GenerateVerificationCodeOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/generateVerificationCode", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGenerateVerificationCode handles the response to the GenerateVerificationCode request. The method always -// closes the http.Response Body. -func (c DpsCertificateClient) responderForGenerateVerificationCode(resp *http.Response) (result GenerateVerificationCodeOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/deviceprovisioningservices/2022-02-05/dpscertificate/method_get.go b/resource-manager/deviceprovisioningservices/2022-02-05/dpscertificate/method_get.go new file mode 100644 index 00000000000..828c6d2b411 --- /dev/null +++ b/resource-manager/deviceprovisioningservices/2022-02-05/dpscertificate/method_get.go @@ -0,0 +1,80 @@ +package dpscertificate + +import ( + "context" + "fmt" + "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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CertificateResponse +} + +type GetOperationOptions struct { + IfMatch *string +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Get ... +func (c DpsCertificateClient) Get(ctx context.Context, id CertificateId, options GetOperationOptions) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + OptionsObject: options, + } + + 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 +} diff --git a/resource-manager/deviceprovisioningservices/2022-02-05/dpscertificate/method_get_autorest.go b/resource-manager/deviceprovisioningservices/2022-02-05/dpscertificate/method_get_autorest.go deleted file mode 100644 index 7f0baca0673..00000000000 --- a/resource-manager/deviceprovisioningservices/2022-02-05/dpscertificate/method_get_autorest.go +++ /dev/null @@ -1,97 +0,0 @@ -package dpscertificate - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *CertificateResponse -} - -type GetOperationOptions struct { - IfMatch *string -} - -func DefaultGetOperationOptions() GetOperationOptions { - return GetOperationOptions{} -} - -func (o GetOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o GetOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Get ... -func (c DpsCertificateClient) Get(ctx context.Context, id CertificateId, options GetOperationOptions) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "dpscertificate.DpsCertificateClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "dpscertificate.DpsCertificateClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "dpscertificate.DpsCertificateClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c DpsCertificateClient) preparerForGet(ctx context.Context, id CertificateId, options GetOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c DpsCertificateClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/deviceprovisioningservices/2022-02-05/dpscertificate/method_list.go b/resource-manager/deviceprovisioningservices/2022-02-05/dpscertificate/method_list.go new file mode 100644 index 00000000000..b3762237ae0 --- /dev/null +++ b/resource-manager/deviceprovisioningservices/2022-02-05/dpscertificate/method_list.go @@ -0,0 +1,53 @@ +package dpscertificate + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CertificateListDescription +} + +// List ... +func (c DpsCertificateClient) List(ctx context.Context, id commonids.ProvisioningServiceId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/certificates", 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 +} diff --git a/resource-manager/deviceprovisioningservices/2022-02-05/dpscertificate/method_list_autorest.go b/resource-manager/deviceprovisioningservices/2022-02-05/dpscertificate/method_list_autorest.go deleted file mode 100644 index db8e7ec0a3b..00000000000 --- a/resource-manager/deviceprovisioningservices/2022-02-05/dpscertificate/method_list_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package dpscertificate - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListOperationResponse struct { - HttpResponse *http.Response - Model *CertificateListDescription -} - -// List ... -func (c DpsCertificateClient) List(ctx context.Context, id commonids.ProvisioningServiceId) (result ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "dpscertificate.DpsCertificateClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "dpscertificate.DpsCertificateClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "dpscertificate.DpsCertificateClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForList prepares the List request. -func (c DpsCertificateClient) preparerForList(ctx context.Context, id commonids.ProvisioningServiceId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/certificates", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForList handles the response to the List request. The method always -// closes the http.Response Body. -func (c DpsCertificateClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/deviceprovisioningservices/2022-02-05/dpscertificate/method_verifycertificate.go b/resource-manager/deviceprovisioningservices/2022-02-05/dpscertificate/method_verifycertificate.go new file mode 100644 index 00000000000..23e49360468 --- /dev/null +++ b/resource-manager/deviceprovisioningservices/2022-02-05/dpscertificate/method_verifycertificate.go @@ -0,0 +1,115 @@ +package dpscertificate + +import ( + "context" + "fmt" + "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 VerifyCertificateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CertificateResponse +} + +type VerifyCertificateOperationOptions struct { + CertificateCreated *string + CertificateHasPrivateKey *bool + CertificateIsVerified *bool + CertificateLastUpdated *string + CertificateName *string + CertificateNonce *string + CertificatePurpose *CertificatePurpose + CertificateRawBytes *string + IfMatch *string +} + +func DefaultVerifyCertificateOperationOptions() VerifyCertificateOperationOptions { + return VerifyCertificateOperationOptions{} +} + +func (o VerifyCertificateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o VerifyCertificateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o VerifyCertificateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.CertificateCreated != nil { + out.Append("certificate.created", fmt.Sprintf("%v", *o.CertificateCreated)) + } + if o.CertificateHasPrivateKey != nil { + out.Append("certificate.hasPrivateKey", fmt.Sprintf("%v", *o.CertificateHasPrivateKey)) + } + if o.CertificateIsVerified != nil { + out.Append("certificate.isVerified", fmt.Sprintf("%v", *o.CertificateIsVerified)) + } + if o.CertificateLastUpdated != nil { + out.Append("certificate.lastUpdated", fmt.Sprintf("%v", *o.CertificateLastUpdated)) + } + if o.CertificateName != nil { + out.Append("certificate.name", fmt.Sprintf("%v", *o.CertificateName)) + } + if o.CertificateNonce != nil { + out.Append("certificate.nonce", fmt.Sprintf("%v", *o.CertificateNonce)) + } + if o.CertificatePurpose != nil { + out.Append("certificate.purpose", fmt.Sprintf("%v", *o.CertificatePurpose)) + } + if o.CertificateRawBytes != nil { + out.Append("certificate.rawBytes", fmt.Sprintf("%v", *o.CertificateRawBytes)) + } + return &out +} + +// VerifyCertificate ... +func (c DpsCertificateClient) VerifyCertificate(ctx context.Context, id CertificateId, input VerificationCodeRequest, options VerifyCertificateOperationOptions) (result VerifyCertificateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/verify", 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 + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/deviceprovisioningservices/2022-02-05/dpscertificate/method_verifycertificate_autorest.go b/resource-manager/deviceprovisioningservices/2022-02-05/dpscertificate/method_verifycertificate_autorest.go deleted file mode 100644 index cf2e6548db8..00000000000 --- a/resource-manager/deviceprovisioningservices/2022-02-05/dpscertificate/method_verifycertificate_autorest.go +++ /dev/null @@ -1,139 +0,0 @@ -package dpscertificate - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type VerifyCertificateOperationResponse struct { - HttpResponse *http.Response - Model *CertificateResponse -} - -type VerifyCertificateOperationOptions struct { - CertificateCreated *string - CertificateHasPrivateKey *bool - CertificateIsVerified *bool - CertificateLastUpdated *string - CertificateName *string - CertificateNonce *string - CertificatePurpose *CertificatePurpose - CertificateRawBytes *string - IfMatch *string -} - -func DefaultVerifyCertificateOperationOptions() VerifyCertificateOperationOptions { - return VerifyCertificateOperationOptions{} -} - -func (o VerifyCertificateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o VerifyCertificateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.CertificateCreated != nil { - out["certificate.created"] = *o.CertificateCreated - } - - if o.CertificateHasPrivateKey != nil { - out["certificate.hasPrivateKey"] = *o.CertificateHasPrivateKey - } - - if o.CertificateIsVerified != nil { - out["certificate.isVerified"] = *o.CertificateIsVerified - } - - if o.CertificateLastUpdated != nil { - out["certificate.lastUpdated"] = *o.CertificateLastUpdated - } - - if o.CertificateName != nil { - out["certificate.name"] = *o.CertificateName - } - - if o.CertificateNonce != nil { - out["certificate.nonce"] = *o.CertificateNonce - } - - if o.CertificatePurpose != nil { - out["certificate.purpose"] = *o.CertificatePurpose - } - - if o.CertificateRawBytes != nil { - out["certificate.rawBytes"] = *o.CertificateRawBytes - } - - return out -} - -// VerifyCertificate ... -func (c DpsCertificateClient) VerifyCertificate(ctx context.Context, id CertificateId, input VerificationCodeRequest, options VerifyCertificateOperationOptions) (result VerifyCertificateOperationResponse, err error) { - req, err := c.preparerForVerifyCertificate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "dpscertificate.DpsCertificateClient", "VerifyCertificate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "dpscertificate.DpsCertificateClient", "VerifyCertificate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForVerifyCertificate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "dpscertificate.DpsCertificateClient", "VerifyCertificate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForVerifyCertificate prepares the VerifyCertificate request. -func (c DpsCertificateClient) preparerForVerifyCertificate(ctx context.Context, id CertificateId, input VerificationCodeRequest, options VerifyCertificateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/verify", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForVerifyCertificate handles the response to the VerifyCertificate request. The method always -// closes the http.Response Body. -func (c DpsCertificateClient) responderForVerifyCertificate(resp *http.Response) (result VerifyCertificateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/client.go b/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/client.go index 6959319802b..3447cead3f5 100644 --- a/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/client.go +++ b/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/client.go @@ -1,18 +1,26 @@ package iotdpsresource -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 IotDpsResourceClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewIotDpsResourceClientWithBaseURI(endpoint string) IotDpsResourceClient { - return IotDpsResourceClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewIotDpsResourceClientWithBaseURI(api environments.Api) (*IotDpsResourceClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "iotdpsresource", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating IotDpsResourceClient: %+v", err) } + + return &IotDpsResourceClient{ + Client: client, + }, nil } diff --git a/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/constants.go b/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/constants.go index d9256dc2f8c..26b5ec77a1c 100644 --- a/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/constants.go +++ b/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/constants.go @@ -1,6 +1,10 @@ package iotdpsresource -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. @@ -27,6 +31,19 @@ func PossibleValuesForAccessRightsDescription() []string { } } +func (s *AccessRightsDescription) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAccessRightsDescription(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAccessRightsDescription(input string) (*AccessRightsDescription, error) { vals := map[string]AccessRightsDescription{ "deviceconnect": AccessRightsDescriptionDeviceConnect, @@ -61,6 +78,19 @@ func PossibleValuesForAllocationPolicy() []string { } } +func (s *AllocationPolicy) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAllocationPolicy(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAllocationPolicy(input string) (*AllocationPolicy, error) { vals := map[string]AllocationPolicy{ "geolatency": AllocationPolicyGeoLatency, @@ -90,6 +120,19 @@ func PossibleValuesForIPFilterActionType() []string { } } +func (s *IPFilterActionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPFilterActionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseIPFilterActionType(input string) (*IPFilterActionType, error) { vals := map[string]IPFilterActionType{ "accept": IPFilterActionTypeAccept, @@ -120,6 +163,19 @@ func PossibleValuesForIPFilterTargetType() []string { } } +func (s *IPFilterTargetType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPFilterTargetType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseIPFilterTargetType(input string) (*IPFilterTargetType, error) { vals := map[string]IPFilterTargetType{ "all": IPFilterTargetTypeAll, @@ -147,6 +203,19 @@ func PossibleValuesForIotDpsSku() []string { } } +func (s *IotDpsSku) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIotDpsSku(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseIotDpsSku(input string) (*IotDpsSku, error) { vals := map[string]IotDpsSku{ "s1": IotDpsSkuSOne, @@ -174,6 +243,19 @@ func PossibleValuesForNameUnavailabilityReason() []string { } } +func (s *NameUnavailabilityReason) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNameUnavailabilityReason(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseNameUnavailabilityReason(input string) (*NameUnavailabilityReason, error) { vals := map[string]NameUnavailabilityReason{ "alreadyexists": NameUnavailabilityReasonAlreadyExists, @@ -206,6 +288,19 @@ func PossibleValuesForPrivateLinkServiceConnectionStatus() []string { } } +func (s *PrivateLinkServiceConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateLinkServiceConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePrivateLinkServiceConnectionStatus(input string) (*PrivateLinkServiceConnectionStatus, error) { vals := map[string]PrivateLinkServiceConnectionStatus{ "approved": PrivateLinkServiceConnectionStatusApproved, @@ -236,6 +331,19 @@ func PossibleValuesForPublicNetworkAccess() []string { } } +func (s *PublicNetworkAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicNetworkAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePublicNetworkAccess(input string) (*PublicNetworkAccess, error) { vals := map[string]PublicNetworkAccess{ "disabled": PublicNetworkAccessDisabled, @@ -284,6 +392,19 @@ func PossibleValuesForState() []string { } } +func (s *State) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseState(input string) (*State, error) { vals := map[string]State{ "activating": StateActivating, diff --git a/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_checkprovisioningservicenameavailability.go b/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_checkprovisioningservicenameavailability.go new file mode 100644 index 00000000000..5592ded2095 --- /dev/null +++ b/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_checkprovisioningservicenameavailability.go @@ -0,0 +1,57 @@ +package iotdpsresource + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 CheckProvisioningServiceNameAvailabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NameAvailabilityInfo +} + +// CheckProvisioningServiceNameAvailability ... +func (c IotDpsResourceClient) CheckProvisioningServiceNameAvailability(ctx context.Context, id commonids.SubscriptionId, input OperationInputs) (result CheckProvisioningServiceNameAvailabilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.Devices/checkProvisioningServiceNameAvailability", 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 +} diff --git a/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_checkprovisioningservicenameavailability_autorest.go b/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_checkprovisioningservicenameavailability_autorest.go deleted file mode 100644 index c1dd869540d..00000000000 --- a/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_checkprovisioningservicenameavailability_autorest.go +++ /dev/null @@ -1,71 +0,0 @@ -package iotdpsresource - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CheckProvisioningServiceNameAvailabilityOperationResponse struct { - HttpResponse *http.Response - Model *NameAvailabilityInfo -} - -// CheckProvisioningServiceNameAvailability ... -func (c IotDpsResourceClient) CheckProvisioningServiceNameAvailability(ctx context.Context, id commonids.SubscriptionId, input OperationInputs) (result CheckProvisioningServiceNameAvailabilityOperationResponse, err error) { - req, err := c.preparerForCheckProvisioningServiceNameAvailability(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "CheckProvisioningServiceNameAvailability", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "CheckProvisioningServiceNameAvailability", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCheckProvisioningServiceNameAvailability(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "CheckProvisioningServiceNameAvailability", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCheckProvisioningServiceNameAvailability prepares the CheckProvisioningServiceNameAvailability request. -func (c IotDpsResourceClient) preparerForCheckProvisioningServiceNameAvailability(ctx context.Context, id commonids.SubscriptionId, input OperationInputs) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Devices/checkProvisioningServiceNameAvailability", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCheckProvisioningServiceNameAvailability handles the response to the CheckProvisioningServiceNameAvailability request. The method always -// closes the http.Response Body. -func (c IotDpsResourceClient) responderForCheckProvisioningServiceNameAvailability(resp *http.Response) (result CheckProvisioningServiceNameAvailabilityOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_createorupdate.go b/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_createorupdate.go new file mode 100644 index 00000000000..6ef8f4a0a16 --- /dev/null +++ b/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_createorupdate.go @@ -0,0 +1,75 @@ +package iotdpsresource + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 +} + +// CreateOrUpdate ... +func (c IotDpsResourceClient) CreateOrUpdate(ctx context.Context, id commonids.ProvisioningServiceId, input ProvisioningServiceDescription) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 IotDpsResourceClient) CreateOrUpdateThenPoll(ctx context.Context, id commonids.ProvisioningServiceId, input ProvisioningServiceDescription) 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 +} diff --git a/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_createorupdate_autorest.go b/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_createorupdate_autorest.go deleted file mode 100644 index f14ba7d8aee..00000000000 --- a/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_createorupdate_autorest.go +++ /dev/null @@ -1,80 +0,0 @@ -package iotdpsresource - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateOrUpdate ... -func (c IotDpsResourceClient) CreateOrUpdate(ctx context.Context, id commonids.ProvisioningServiceId, input ProvisioningServiceDescription) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c IotDpsResourceClient) CreateOrUpdateThenPoll(ctx context.Context, id commonids.ProvisioningServiceId, input ProvisioningServiceDescription) error { - result, err := c.CreateOrUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateOrUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateOrUpdate: %+v", err) - } - - return nil -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c IotDpsResourceClient) preparerForCreateOrUpdate(ctx context.Context, id commonids.ProvisioningServiceId, input ProvisioningServiceDescription) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateOrUpdate sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c IotDpsResourceClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_createorupdateprivateendpointconnection.go b/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_createorupdateprivateendpointconnection.go new file mode 100644 index 00000000000..d5f2706c3e4 --- /dev/null +++ b/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_createorupdateprivateendpointconnection.go @@ -0,0 +1,74 @@ +package iotdpsresource + +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 CreateOrUpdatePrivateEndpointConnectionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// CreateOrUpdatePrivateEndpointConnection ... +func (c IotDpsResourceClient) CreateOrUpdatePrivateEndpointConnection(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) (result CreateOrUpdatePrivateEndpointConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 +} + +// CreateOrUpdatePrivateEndpointConnectionThenPoll performs CreateOrUpdatePrivateEndpointConnection then polls until it's completed +func (c IotDpsResourceClient) CreateOrUpdatePrivateEndpointConnectionThenPoll(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) error { + result, err := c.CreateOrUpdatePrivateEndpointConnection(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdatePrivateEndpointConnection: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdatePrivateEndpointConnection: %+v", err) + } + + return nil +} diff --git a/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_createorupdateprivateendpointconnection_autorest.go b/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_createorupdateprivateendpointconnection_autorest.go deleted file mode 100644 index d88ede94baa..00000000000 --- a/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_createorupdateprivateendpointconnection_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package iotdpsresource - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdatePrivateEndpointConnectionOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateOrUpdatePrivateEndpointConnection ... -func (c IotDpsResourceClient) CreateOrUpdatePrivateEndpointConnection(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) (result CreateOrUpdatePrivateEndpointConnectionOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdatePrivateEndpointConnection(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "CreateOrUpdatePrivateEndpointConnection", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdatePrivateEndpointConnection(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "CreateOrUpdatePrivateEndpointConnection", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdatePrivateEndpointConnectionThenPoll performs CreateOrUpdatePrivateEndpointConnection then polls until it's completed -func (c IotDpsResourceClient) CreateOrUpdatePrivateEndpointConnectionThenPoll(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) error { - result, err := c.CreateOrUpdatePrivateEndpointConnection(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateOrUpdatePrivateEndpointConnection: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateOrUpdatePrivateEndpointConnection: %+v", err) - } - - return nil -} - -// preparerForCreateOrUpdatePrivateEndpointConnection prepares the CreateOrUpdatePrivateEndpointConnection request. -func (c IotDpsResourceClient) preparerForCreateOrUpdatePrivateEndpointConnection(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateOrUpdatePrivateEndpointConnection sends the CreateOrUpdatePrivateEndpointConnection request. The method will close the -// http.Response Body if it receives an error. -func (c IotDpsResourceClient) senderForCreateOrUpdatePrivateEndpointConnection(ctx context.Context, req *http.Request) (future CreateOrUpdatePrivateEndpointConnectionOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_delete.go b/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_delete.go new file mode 100644 index 00000000000..ab37010b6bb --- /dev/null +++ b/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_delete.go @@ -0,0 +1,72 @@ +package iotdpsresource + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 IotDpsResourceClient) Delete(ctx context.Context, id commonids.ProvisioningServiceId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 IotDpsResourceClient) DeleteThenPoll(ctx context.Context, id commonids.ProvisioningServiceId) 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 +} diff --git a/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_delete_autorest.go b/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_delete_autorest.go deleted file mode 100644 index cbce43eece2..00000000000 --- a/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_delete_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package iotdpsresource - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// Delete ... -func (c IotDpsResourceClient) Delete(ctx context.Context, id commonids.ProvisioningServiceId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c IotDpsResourceClient) DeleteThenPoll(ctx context.Context, id commonids.ProvisioningServiceId) error { - result, err := c.Delete(ctx, id) - if err != nil { - return fmt.Errorf("performing Delete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Delete: %+v", err) - } - - return nil -} - -// preparerForDelete prepares the Delete request. -func (c IotDpsResourceClient) preparerForDelete(ctx context.Context, id commonids.ProvisioningServiceId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDelete sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (c IotDpsResourceClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_deleteprivateendpointconnection.go b/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_deleteprivateendpointconnection.go new file mode 100644 index 00000000000..f756bbb533f --- /dev/null +++ b/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_deleteprivateendpointconnection.go @@ -0,0 +1,71 @@ +package iotdpsresource + +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 DeletePrivateEndpointConnectionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// DeletePrivateEndpointConnection ... +func (c IotDpsResourceClient) DeletePrivateEndpointConnection(ctx context.Context, id PrivateEndpointConnectionId) (result DeletePrivateEndpointConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 +} + +// DeletePrivateEndpointConnectionThenPoll performs DeletePrivateEndpointConnection then polls until it's completed +func (c IotDpsResourceClient) DeletePrivateEndpointConnectionThenPoll(ctx context.Context, id PrivateEndpointConnectionId) error { + result, err := c.DeletePrivateEndpointConnection(ctx, id) + if err != nil { + return fmt.Errorf("performing DeletePrivateEndpointConnection: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DeletePrivateEndpointConnection: %+v", err) + } + + return nil +} diff --git a/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_deleteprivateendpointconnection_autorest.go b/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_deleteprivateendpointconnection_autorest.go deleted file mode 100644 index 47c1a6717cb..00000000000 --- a/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_deleteprivateendpointconnection_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package iotdpsresource - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeletePrivateEndpointConnectionOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// DeletePrivateEndpointConnection ... -func (c IotDpsResourceClient) DeletePrivateEndpointConnection(ctx context.Context, id PrivateEndpointConnectionId) (result DeletePrivateEndpointConnectionOperationResponse, err error) { - req, err := c.preparerForDeletePrivateEndpointConnection(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "DeletePrivateEndpointConnection", nil, "Failure preparing request") - return - } - - result, err = c.senderForDeletePrivateEndpointConnection(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "DeletePrivateEndpointConnection", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeletePrivateEndpointConnectionThenPoll performs DeletePrivateEndpointConnection then polls until it's completed -func (c IotDpsResourceClient) DeletePrivateEndpointConnectionThenPoll(ctx context.Context, id PrivateEndpointConnectionId) error { - result, err := c.DeletePrivateEndpointConnection(ctx, id) - if err != nil { - return fmt.Errorf("performing DeletePrivateEndpointConnection: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after DeletePrivateEndpointConnection: %+v", err) - } - - return nil -} - -// preparerForDeletePrivateEndpointConnection prepares the DeletePrivateEndpointConnection request. -func (c IotDpsResourceClient) preparerForDeletePrivateEndpointConnection(ctx context.Context, id PrivateEndpointConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDeletePrivateEndpointConnection sends the DeletePrivateEndpointConnection request. The method will close the -// http.Response Body if it receives an error. -func (c IotDpsResourceClient) senderForDeletePrivateEndpointConnection(ctx context.Context, req *http.Request) (future DeletePrivateEndpointConnectionOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_get.go b/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_get.go new file mode 100644 index 00000000000..84c4f5acd69 --- /dev/null +++ b/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_get.go @@ -0,0 +1,52 @@ +package iotdpsresource + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ProvisioningServiceDescription +} + +// Get ... +func (c IotDpsResourceClient) Get(ctx context.Context, id commonids.ProvisioningServiceId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_get_autorest.go b/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_get_autorest.go deleted file mode 100644 index 3c9cb772f57..00000000000 --- a/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_get_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package iotdpsresource - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *ProvisioningServiceDescription -} - -// Get ... -func (c IotDpsResourceClient) Get(ctx context.Context, id commonids.ProvisioningServiceId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c IotDpsResourceClient) preparerForGet(ctx context.Context, id commonids.ProvisioningServiceId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c IotDpsResourceClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_getprivateendpointconnection.go b/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_getprivateendpointconnection.go new file mode 100644 index 00000000000..a9efb50aba3 --- /dev/null +++ b/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_getprivateendpointconnection.go @@ -0,0 +1,51 @@ +package iotdpsresource + +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 GetPrivateEndpointConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateEndpointConnection +} + +// GetPrivateEndpointConnection ... +func (c IotDpsResourceClient) GetPrivateEndpointConnection(ctx context.Context, id PrivateEndpointConnectionId) (result GetPrivateEndpointConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_getprivateendpointconnection_autorest.go b/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_getprivateendpointconnection_autorest.go deleted file mode 100644 index 263ab973d8f..00000000000 --- a/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_getprivateendpointconnection_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package iotdpsresource - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetPrivateEndpointConnectionOperationResponse struct { - HttpResponse *http.Response - Model *PrivateEndpointConnection -} - -// GetPrivateEndpointConnection ... -func (c IotDpsResourceClient) GetPrivateEndpointConnection(ctx context.Context, id PrivateEndpointConnectionId) (result GetPrivateEndpointConnectionOperationResponse, err error) { - req, err := c.preparerForGetPrivateEndpointConnection(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "GetPrivateEndpointConnection", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "GetPrivateEndpointConnection", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetPrivateEndpointConnection(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "GetPrivateEndpointConnection", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetPrivateEndpointConnection prepares the GetPrivateEndpointConnection request. -func (c IotDpsResourceClient) preparerForGetPrivateEndpointConnection(ctx context.Context, id PrivateEndpointConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetPrivateEndpointConnection handles the response to the GetPrivateEndpointConnection request. The method always -// closes the http.Response Body. -func (c IotDpsResourceClient) responderForGetPrivateEndpointConnection(resp *http.Response) (result GetPrivateEndpointConnectionOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_getprivatelinkresources.go b/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_getprivatelinkresources.go new file mode 100644 index 00000000000..df474196652 --- /dev/null +++ b/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_getprivatelinkresources.go @@ -0,0 +1,51 @@ +package iotdpsresource + +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 GetPrivateLinkResourcesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *GroupIdInformation +} + +// GetPrivateLinkResources ... +func (c IotDpsResourceClient) GetPrivateLinkResources(ctx context.Context, id PrivateLinkResourceId) (result GetPrivateLinkResourcesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_getprivatelinkresources_autorest.go b/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_getprivatelinkresources_autorest.go deleted file mode 100644 index 37f80ffc338..00000000000 --- a/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_getprivatelinkresources_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package iotdpsresource - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetPrivateLinkResourcesOperationResponse struct { - HttpResponse *http.Response - Model *GroupIdInformation -} - -// GetPrivateLinkResources ... -func (c IotDpsResourceClient) GetPrivateLinkResources(ctx context.Context, id PrivateLinkResourceId) (result GetPrivateLinkResourcesOperationResponse, err error) { - req, err := c.preparerForGetPrivateLinkResources(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "GetPrivateLinkResources", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "GetPrivateLinkResources", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetPrivateLinkResources(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "GetPrivateLinkResources", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetPrivateLinkResources prepares the GetPrivateLinkResources request. -func (c IotDpsResourceClient) preparerForGetPrivateLinkResources(ctx context.Context, id PrivateLinkResourceId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetPrivateLinkResources handles the response to the GetPrivateLinkResources request. The method always -// closes the http.Response Body. -func (c IotDpsResourceClient) responderForGetPrivateLinkResources(resp *http.Response) (result GetPrivateLinkResourcesOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_listbyresourcegroup.go b/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_listbyresourcegroup.go new file mode 100644 index 00000000000..5149f6de916 --- /dev/null +++ b/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_listbyresourcegroup.go @@ -0,0 +1,90 @@ +package iotdpsresource + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProvisioningServiceDescription +} + +type ListByResourceGroupCompleteResult struct { + Items []ProvisioningServiceDescription +} + +// ListByResourceGroup ... +func (c IotDpsResourceClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Devices/provisioningServices", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ProvisioningServiceDescription `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c IotDpsResourceClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, ProvisioningServiceDescriptionOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c IotDpsResourceClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ProvisioningServiceDescriptionOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]ProvisioningServiceDescription, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_listbyresourcegroup_autorest.go b/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_listbyresourcegroup_autorest.go deleted file mode 100644 index a56e2ebc039..00000000000 --- a/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_listbyresourcegroup_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package iotdpsresource - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByResourceGroupOperationResponse struct { - HttpResponse *http.Response - Model *[]ProvisioningServiceDescription - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByResourceGroupOperationResponse, error) -} - -type ListByResourceGroupCompleteResult struct { - Items []ProvisioningServiceDescription -} - -func (r ListByResourceGroupOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByResourceGroupOperationResponse) LoadMore(ctx context.Context) (resp ListByResourceGroupOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByResourceGroup ... -func (c IotDpsResourceClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (resp ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroup(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListByResourceGroup", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByResourceGroup(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListByResourceGroup", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByResourceGroup prepares the ListByResourceGroup request. -func (c IotDpsResourceClient) preparerForListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Devices/provisioningServices", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByResourceGroupWithNextLink prepares the ListByResourceGroup request with the given nextLink token. -func (c IotDpsResourceClient) preparerForListByResourceGroupWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByResourceGroup handles the response to the ListByResourceGroup request. The method always -// closes the http.Response Body. -func (c IotDpsResourceClient) responderForListByResourceGroup(resp *http.Response) (result ListByResourceGroupOperationResponse, err error) { - type page struct { - Values []ProvisioningServiceDescription `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroupWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListByResourceGroup", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByResourceGroup(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListByResourceGroup", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByResourceGroupComplete retrieves all of the results into a single object -func (c IotDpsResourceClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { - return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, ProvisioningServiceDescriptionOperationPredicate{}) -} - -// ListByResourceGroupCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c IotDpsResourceClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ProvisioningServiceDescriptionOperationPredicate) (resp ListByResourceGroupCompleteResult, err error) { - items := make([]ProvisioningServiceDescription, 0) - - page, err := c.ListByResourceGroup(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByResourceGroupCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_listbysubscription.go b/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_listbysubscription.go new file mode 100644 index 00000000000..55e4cc17533 --- /dev/null +++ b/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_listbysubscription.go @@ -0,0 +1,90 @@ +package iotdpsresource + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProvisioningServiceDescription +} + +type ListBySubscriptionCompleteResult struct { + Items []ProvisioningServiceDescription +} + +// ListBySubscription ... +func (c IotDpsResourceClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Devices/provisioningServices", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ProvisioningServiceDescription `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c IotDpsResourceClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, ProvisioningServiceDescriptionOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c IotDpsResourceClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ProvisioningServiceDescriptionOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]ProvisioningServiceDescription, 0) + + resp, err := c.ListBySubscription(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListBySubscriptionCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_listbysubscription_autorest.go b/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_listbysubscription_autorest.go deleted file mode 100644 index d14ae2fb27b..00000000000 --- a/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_listbysubscription_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package iotdpsresource - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListBySubscriptionOperationResponse struct { - HttpResponse *http.Response - Model *[]ProvisioningServiceDescription - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListBySubscriptionOperationResponse, error) -} - -type ListBySubscriptionCompleteResult struct { - Items []ProvisioningServiceDescription -} - -func (r ListBySubscriptionOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListBySubscriptionOperationResponse) LoadMore(ctx context.Context) (resp ListBySubscriptionOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListBySubscription ... -func (c IotDpsResourceClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (resp ListBySubscriptionOperationResponse, err error) { - req, err := c.preparerForListBySubscription(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListBySubscription", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListBySubscription", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListBySubscription(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListBySubscription", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListBySubscription prepares the ListBySubscription request. -func (c IotDpsResourceClient) preparerForListBySubscription(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Devices/provisioningServices", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListBySubscriptionWithNextLink prepares the ListBySubscription request with the given nextLink token. -func (c IotDpsResourceClient) preparerForListBySubscriptionWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListBySubscription handles the response to the ListBySubscription request. The method always -// closes the http.Response Body. -func (c IotDpsResourceClient) responderForListBySubscription(resp *http.Response) (result ListBySubscriptionOperationResponse, err error) { - type page struct { - Values []ProvisioningServiceDescription `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListBySubscriptionOperationResponse, err error) { - req, err := c.preparerForListBySubscriptionWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListBySubscription", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListBySubscription", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListBySubscription(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListBySubscription", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListBySubscriptionComplete retrieves all of the results into a single object -func (c IotDpsResourceClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { - return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, ProvisioningServiceDescriptionOperationPredicate{}) -} - -// ListBySubscriptionCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c IotDpsResourceClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ProvisioningServiceDescriptionOperationPredicate) (resp ListBySubscriptionCompleteResult, err error) { - items := make([]ProvisioningServiceDescription, 0) - - page, err := c.ListBySubscription(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListBySubscriptionCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_listkeys.go b/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_listkeys.go new file mode 100644 index 00000000000..aee09b0e095 --- /dev/null +++ b/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_listkeys.go @@ -0,0 +1,90 @@ +package iotdpsresource + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListKeysOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SharedAccessSignatureAuthorizationRuleAccessRightsDescription +} + +type ListKeysCompleteResult struct { + Items []SharedAccessSignatureAuthorizationRuleAccessRightsDescription +} + +// ListKeys ... +func (c IotDpsResourceClient) ListKeys(ctx context.Context, id commonids.ProvisioningServiceId) (result ListKeysOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listkeys", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]SharedAccessSignatureAuthorizationRuleAccessRightsDescription `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListKeysComplete retrieves all the results into a single object +func (c IotDpsResourceClient) ListKeysComplete(ctx context.Context, id commonids.ProvisioningServiceId) (ListKeysCompleteResult, error) { + return c.ListKeysCompleteMatchingPredicate(ctx, id, SharedAccessSignatureAuthorizationRuleAccessRightsDescriptionOperationPredicate{}) +} + +// ListKeysCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c IotDpsResourceClient) ListKeysCompleteMatchingPredicate(ctx context.Context, id commonids.ProvisioningServiceId, predicate SharedAccessSignatureAuthorizationRuleAccessRightsDescriptionOperationPredicate) (result ListKeysCompleteResult, err error) { + items := make([]SharedAccessSignatureAuthorizationRuleAccessRightsDescription, 0) + + resp, err := c.ListKeys(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListKeysCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_listkeys_autorest.go b/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_listkeys_autorest.go deleted file mode 100644 index dfd0377cde2..00000000000 --- a/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_listkeys_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package iotdpsresource - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListKeysOperationResponse struct { - HttpResponse *http.Response - Model *[]SharedAccessSignatureAuthorizationRuleAccessRightsDescription - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListKeysOperationResponse, error) -} - -type ListKeysCompleteResult struct { - Items []SharedAccessSignatureAuthorizationRuleAccessRightsDescription -} - -func (r ListKeysOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListKeysOperationResponse) LoadMore(ctx context.Context) (resp ListKeysOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListKeys ... -func (c IotDpsResourceClient) ListKeys(ctx context.Context, id commonids.ProvisioningServiceId) (resp ListKeysOperationResponse, err error) { - req, err := c.preparerForListKeys(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListKeys", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListKeys", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListKeys(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListKeys", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListKeys prepares the ListKeys request. -func (c IotDpsResourceClient) preparerForListKeys(ctx context.Context, id commonids.ProvisioningServiceId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/listkeys", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListKeysWithNextLink prepares the ListKeys request with the given nextLink token. -func (c IotDpsResourceClient) preparerForListKeysWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListKeys handles the response to the ListKeys request. The method always -// closes the http.Response Body. -func (c IotDpsResourceClient) responderForListKeys(resp *http.Response) (result ListKeysOperationResponse, err error) { - type page struct { - Values []SharedAccessSignatureAuthorizationRuleAccessRightsDescription `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListKeysOperationResponse, err error) { - req, err := c.preparerForListKeysWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListKeys", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListKeys", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListKeys(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListKeys", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListKeysComplete retrieves all of the results into a single object -func (c IotDpsResourceClient) ListKeysComplete(ctx context.Context, id commonids.ProvisioningServiceId) (ListKeysCompleteResult, error) { - return c.ListKeysCompleteMatchingPredicate(ctx, id, SharedAccessSignatureAuthorizationRuleAccessRightsDescriptionOperationPredicate{}) -} - -// ListKeysCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c IotDpsResourceClient) ListKeysCompleteMatchingPredicate(ctx context.Context, id commonids.ProvisioningServiceId, predicate SharedAccessSignatureAuthorizationRuleAccessRightsDescriptionOperationPredicate) (resp ListKeysCompleteResult, err error) { - items := make([]SharedAccessSignatureAuthorizationRuleAccessRightsDescription, 0) - - page, err := c.ListKeys(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListKeysCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_listkeysforkeyname.go b/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_listkeysforkeyname.go new file mode 100644 index 00000000000..f9bdd960052 --- /dev/null +++ b/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_listkeysforkeyname.go @@ -0,0 +1,52 @@ +package iotdpsresource + +import ( + "context" + "fmt" + "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 ListKeysForKeyNameOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SharedAccessSignatureAuthorizationRuleAccessRightsDescription +} + +// ListKeysForKeyName ... +func (c IotDpsResourceClient) ListKeysForKeyName(ctx context.Context, id KeyId) (result ListKeysForKeyNameOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listkeys", 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 +} diff --git a/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_listkeysforkeyname_autorest.go b/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_listkeysforkeyname_autorest.go deleted file mode 100644 index 9c42234978c..00000000000 --- a/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_listkeysforkeyname_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package iotdpsresource - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListKeysForKeyNameOperationResponse struct { - HttpResponse *http.Response - Model *SharedAccessSignatureAuthorizationRuleAccessRightsDescription -} - -// ListKeysForKeyName ... -func (c IotDpsResourceClient) ListKeysForKeyName(ctx context.Context, id KeyId) (result ListKeysForKeyNameOperationResponse, err error) { - req, err := c.preparerForListKeysForKeyName(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListKeysForKeyName", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListKeysForKeyName", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListKeysForKeyName(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListKeysForKeyName", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListKeysForKeyName prepares the ListKeysForKeyName request. -func (c IotDpsResourceClient) preparerForListKeysForKeyName(ctx context.Context, id KeyId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/listkeys", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListKeysForKeyName handles the response to the ListKeysForKeyName request. The method always -// closes the http.Response Body. -func (c IotDpsResourceClient) responderForListKeysForKeyName(resp *http.Response) (result ListKeysForKeyNameOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_listprivateendpointconnections.go b/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_listprivateendpointconnections.go new file mode 100644 index 00000000000..1f20a68e5f0 --- /dev/null +++ b/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_listprivateendpointconnections.go @@ -0,0 +1,53 @@ +package iotdpsresource + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListPrivateEndpointConnectionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PrivateEndpointConnection +} + +// ListPrivateEndpointConnections ... +func (c IotDpsResourceClient) ListPrivateEndpointConnections(ctx context.Context, id commonids.ProvisioningServiceId) (result ListPrivateEndpointConnectionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateEndpointConnections", 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 +} diff --git a/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_listprivateendpointconnections_autorest.go b/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_listprivateendpointconnections_autorest.go deleted file mode 100644 index b3bdd0f766a..00000000000 --- a/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_listprivateendpointconnections_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package iotdpsresource - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListPrivateEndpointConnectionsOperationResponse struct { - HttpResponse *http.Response - Model *[]PrivateEndpointConnection -} - -// ListPrivateEndpointConnections ... -func (c IotDpsResourceClient) ListPrivateEndpointConnections(ctx context.Context, id commonids.ProvisioningServiceId) (result ListPrivateEndpointConnectionsOperationResponse, err error) { - req, err := c.preparerForListPrivateEndpointConnections(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListPrivateEndpointConnections", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListPrivateEndpointConnections", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListPrivateEndpointConnections(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListPrivateEndpointConnections", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListPrivateEndpointConnections prepares the ListPrivateEndpointConnections request. -func (c IotDpsResourceClient) preparerForListPrivateEndpointConnections(ctx context.Context, id commonids.ProvisioningServiceId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/privateEndpointConnections", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListPrivateEndpointConnections handles the response to the ListPrivateEndpointConnections request. The method always -// closes the http.Response Body. -func (c IotDpsResourceClient) responderForListPrivateEndpointConnections(resp *http.Response) (result ListPrivateEndpointConnectionsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_listprivatelinkresources.go b/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_listprivatelinkresources.go new file mode 100644 index 00000000000..6c55400c101 --- /dev/null +++ b/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_listprivatelinkresources.go @@ -0,0 +1,53 @@ +package iotdpsresource + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListPrivateLinkResourcesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateLinkResources +} + +// ListPrivateLinkResources ... +func (c IotDpsResourceClient) ListPrivateLinkResources(ctx context.Context, id commonids.ProvisioningServiceId) (result ListPrivateLinkResourcesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateLinkResources", 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 +} diff --git a/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_listprivatelinkresources_autorest.go b/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_listprivatelinkresources_autorest.go deleted file mode 100644 index 290a19b7812..00000000000 --- a/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_listprivatelinkresources_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package iotdpsresource - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListPrivateLinkResourcesOperationResponse struct { - HttpResponse *http.Response - Model *PrivateLinkResources -} - -// ListPrivateLinkResources ... -func (c IotDpsResourceClient) ListPrivateLinkResources(ctx context.Context, id commonids.ProvisioningServiceId) (result ListPrivateLinkResourcesOperationResponse, err error) { - req, err := c.preparerForListPrivateLinkResources(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListPrivateLinkResources", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListPrivateLinkResources", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListPrivateLinkResources(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListPrivateLinkResources", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListPrivateLinkResources prepares the ListPrivateLinkResources request. -func (c IotDpsResourceClient) preparerForListPrivateLinkResources(ctx context.Context, id commonids.ProvisioningServiceId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/privateLinkResources", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListPrivateLinkResources handles the response to the ListPrivateLinkResources request. The method always -// closes the http.Response Body. -func (c IotDpsResourceClient) responderForListPrivateLinkResources(resp *http.Response) (result ListPrivateLinkResourcesOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_listvalidskus.go b/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_listvalidskus.go new file mode 100644 index 00000000000..e856a0ddef6 --- /dev/null +++ b/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_listvalidskus.go @@ -0,0 +1,90 @@ +package iotdpsresource + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListValidSkusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]IotDpsSkuDefinition +} + +type ListValidSkusCompleteResult struct { + Items []IotDpsSkuDefinition +} + +// ListValidSkus ... +func (c IotDpsResourceClient) ListValidSkus(ctx context.Context, id commonids.ProvisioningServiceId) (result ListValidSkusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/skus", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]IotDpsSkuDefinition `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListValidSkusComplete retrieves all the results into a single object +func (c IotDpsResourceClient) ListValidSkusComplete(ctx context.Context, id commonids.ProvisioningServiceId) (ListValidSkusCompleteResult, error) { + return c.ListValidSkusCompleteMatchingPredicate(ctx, id, IotDpsSkuDefinitionOperationPredicate{}) +} + +// ListValidSkusCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c IotDpsResourceClient) ListValidSkusCompleteMatchingPredicate(ctx context.Context, id commonids.ProvisioningServiceId, predicate IotDpsSkuDefinitionOperationPredicate) (result ListValidSkusCompleteResult, err error) { + items := make([]IotDpsSkuDefinition, 0) + + resp, err := c.ListValidSkus(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListValidSkusCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_listvalidskus_autorest.go b/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_listvalidskus_autorest.go deleted file mode 100644 index 59b8b6a312f..00000000000 --- a/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_listvalidskus_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package iotdpsresource - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListValidSkusOperationResponse struct { - HttpResponse *http.Response - Model *[]IotDpsSkuDefinition - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListValidSkusOperationResponse, error) -} - -type ListValidSkusCompleteResult struct { - Items []IotDpsSkuDefinition -} - -func (r ListValidSkusOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListValidSkusOperationResponse) LoadMore(ctx context.Context) (resp ListValidSkusOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListValidSkus ... -func (c IotDpsResourceClient) ListValidSkus(ctx context.Context, id commonids.ProvisioningServiceId) (resp ListValidSkusOperationResponse, err error) { - req, err := c.preparerForListValidSkus(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListValidSkus", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListValidSkus", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListValidSkus(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListValidSkus", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListValidSkus prepares the ListValidSkus request. -func (c IotDpsResourceClient) preparerForListValidSkus(ctx context.Context, id commonids.ProvisioningServiceId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/skus", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListValidSkusWithNextLink prepares the ListValidSkus request with the given nextLink token. -func (c IotDpsResourceClient) preparerForListValidSkusWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListValidSkus handles the response to the ListValidSkus request. The method always -// closes the http.Response Body. -func (c IotDpsResourceClient) responderForListValidSkus(resp *http.Response) (result ListValidSkusOperationResponse, err error) { - type page struct { - Values []IotDpsSkuDefinition `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListValidSkusOperationResponse, err error) { - req, err := c.preparerForListValidSkusWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListValidSkus", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListValidSkus", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListValidSkus(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListValidSkus", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListValidSkusComplete retrieves all of the results into a single object -func (c IotDpsResourceClient) ListValidSkusComplete(ctx context.Context, id commonids.ProvisioningServiceId) (ListValidSkusCompleteResult, error) { - return c.ListValidSkusCompleteMatchingPredicate(ctx, id, IotDpsSkuDefinitionOperationPredicate{}) -} - -// ListValidSkusCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c IotDpsResourceClient) ListValidSkusCompleteMatchingPredicate(ctx context.Context, id commonids.ProvisioningServiceId, predicate IotDpsSkuDefinitionOperationPredicate) (resp ListValidSkusCompleteResult, err error) { - items := make([]IotDpsSkuDefinition, 0) - - page, err := c.ListValidSkus(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListValidSkusCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_update.go b/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_update.go new file mode 100644 index 00000000000..f5a5248296a --- /dev/null +++ b/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_update.go @@ -0,0 +1,74 @@ +package iotdpsresource + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Update ... +func (c IotDpsResourceClient) Update(ctx context.Context, id commonids.ProvisioningServiceId, input TagsResource) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + 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 +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c IotDpsResourceClient) UpdateThenPoll(ctx context.Context, id commonids.ProvisioningServiceId, input TagsResource) error { + result, err := c.Update(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_update_autorest.go b/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_update_autorest.go deleted file mode 100644 index 4f4e60344e8..00000000000 --- a/resource-manager/deviceprovisioningservices/2022-02-05/iotdpsresource/method_update_autorest.go +++ /dev/null @@ -1,80 +0,0 @@ -package iotdpsresource - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Update ... -func (c IotDpsResourceClient) Update(ctx context.Context, id commonids.ProvisioningServiceId, input TagsResource) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "Update", nil, "Failure preparing request") - return - } - - result, err = c.senderForUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// UpdateThenPoll performs Update then polls until it's completed -func (c IotDpsResourceClient) UpdateThenPoll(ctx context.Context, id commonids.ProvisioningServiceId, input TagsResource) error { - result, err := c.Update(ctx, id, input) - if err != nil { - return fmt.Errorf("performing Update: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Update: %+v", err) - } - - return nil -} - -// preparerForUpdate prepares the Update request. -func (c IotDpsResourceClient) preparerForUpdate(ctx context.Context, id commonids.ProvisioningServiceId, input TagsResource) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForUpdate sends the Update request. The method will close the -// http.Response Body if it receives an error. -func (c IotDpsResourceClient) senderForUpdate(ctx context.Context, req *http.Request) (future UpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/deviceprovisioningservices/2022-12-12/client.go b/resource-manager/deviceprovisioningservices/2022-12-12/client.go index 551f4565e44..3a3e7f1cc17 100644 --- a/resource-manager/deviceprovisioningservices/2022-12-12/client.go +++ b/resource-manager/deviceprovisioningservices/2022-12-12/client.go @@ -4,9 +4,12 @@ package v2022_12_12 // 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/deviceprovisioningservices/2022-12-12/dpscertificate" "github.com/hashicorp/go-azure-sdk/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/environments" ) type Client struct { @@ -14,16 +17,21 @@ type Client struct { IotDpsResource *iotdpsresource.IotDpsResourceClient } -func NewClientWithBaseURI(endpoint string, configureAuthFunc func(c *autorest.Client)) Client { - - dpsCertificateClient := dpscertificate.NewDpsCertificateClientWithBaseURI(endpoint) - configureAuthFunc(&dpsCertificateClient.Client) - - iotDpsResourceClient := iotdpsresource.NewIotDpsResourceClientWithBaseURI(endpoint) - configureAuthFunc(&iotDpsResourceClient.Client) +func NewClientWithBaseURI(api environments.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + dpsCertificateClient, err := dpscertificate.NewDpsCertificateClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building DpsCertificate client: %+v", err) + } + configureFunc(dpsCertificateClient.Client) - return Client{ - DpsCertificate: &dpsCertificateClient, - IotDpsResource: &iotDpsResourceClient, + iotDpsResourceClient, err := iotdpsresource.NewIotDpsResourceClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building IotDpsResource client: %+v", err) } + configureFunc(iotDpsResourceClient.Client) + + return &Client{ + DpsCertificate: dpsCertificateClient, + IotDpsResource: iotDpsResourceClient, + }, nil } diff --git a/resource-manager/deviceprovisioningservices/2022-12-12/dpscertificate/client.go b/resource-manager/deviceprovisioningservices/2022-12-12/dpscertificate/client.go index f19ccff4a47..9bcbdae2f39 100644 --- a/resource-manager/deviceprovisioningservices/2022-12-12/dpscertificate/client.go +++ b/resource-manager/deviceprovisioningservices/2022-12-12/dpscertificate/client.go @@ -1,18 +1,26 @@ package dpscertificate -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 DpsCertificateClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewDpsCertificateClientWithBaseURI(endpoint string) DpsCertificateClient { - return DpsCertificateClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewDpsCertificateClientWithBaseURI(api environments.Api) (*DpsCertificateClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "dpscertificate", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DpsCertificateClient: %+v", err) } + + return &DpsCertificateClient{ + Client: client, + }, nil } diff --git a/resource-manager/deviceprovisioningservices/2022-12-12/dpscertificate/constants.go b/resource-manager/deviceprovisioningservices/2022-12-12/dpscertificate/constants.go index 996b4144ec0..aaae04cf495 100644 --- a/resource-manager/deviceprovisioningservices/2022-12-12/dpscertificate/constants.go +++ b/resource-manager/deviceprovisioningservices/2022-12-12/dpscertificate/constants.go @@ -1,6 +1,10 @@ package dpscertificate -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. @@ -19,6 +23,19 @@ func PossibleValuesForCertificatePurpose() []string { } } +func (s *CertificatePurpose) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCertificatePurpose(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseCertificatePurpose(input string) (*CertificatePurpose, error) { vals := map[string]CertificatePurpose{ "clientauthentication": CertificatePurposeClientAuthentication, diff --git a/resource-manager/deviceprovisioningservices/2022-12-12/dpscertificate/method_createorupdate.go b/resource-manager/deviceprovisioningservices/2022-12-12/dpscertificate/method_createorupdate.go new file mode 100644 index 00000000000..2b7da1aef35 --- /dev/null +++ b/resource-manager/deviceprovisioningservices/2022-12-12/dpscertificate/method_createorupdate.go @@ -0,0 +1,84 @@ +package dpscertificate + +import ( + "context" + "fmt" + "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 *CertificateResponse +} + +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 DpsCertificateClient) CreateOrUpdate(ctx context.Context, id CertificateId, input CertificateResponse, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/deviceprovisioningservices/2022-12-12/dpscertificate/method_createorupdate_autorest.go b/resource-manager/deviceprovisioningservices/2022-12-12/dpscertificate/method_createorupdate_autorest.go deleted file mode 100644 index 1235de605bb..00000000000 --- a/resource-manager/deviceprovisioningservices/2022-12-12/dpscertificate/method_createorupdate_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package dpscertificate - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// 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 - Model *CertificateResponse -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c DpsCertificateClient) CreateOrUpdate(ctx context.Context, id CertificateId, input CertificateResponse, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "dpscertificate.DpsCertificateClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "dpscertificate.DpsCertificateClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "dpscertificate.DpsCertificateClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c DpsCertificateClient) preparerForCreateOrUpdate(ctx context.Context, id CertificateId, input CertificateResponse, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateOrUpdate handles the response to the CreateOrUpdate request. The method always -// closes the http.Response Body. -func (c DpsCertificateClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/deviceprovisioningservices/2022-12-12/dpscertificate/method_delete.go b/resource-manager/deviceprovisioningservices/2022-12-12/dpscertificate/method_delete.go new file mode 100644 index 00000000000..5e37cd6e82f --- /dev/null +++ b/resource-manager/deviceprovisioningservices/2022-12-12/dpscertificate/method_delete.go @@ -0,0 +1,107 @@ +package dpscertificate + +import ( + "context" + "fmt" + "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 +} + +type DeleteOperationOptions struct { + CertificateCreated *string + CertificateHasPrivateKey *bool + CertificateIsVerified *bool + CertificateLastUpdated *string + CertificateName *string + CertificateNonce *string + CertificatePurpose *CertificatePurpose + CertificateRawBytes *string + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.CertificateCreated != nil { + out.Append("certificate.created", fmt.Sprintf("%v", *o.CertificateCreated)) + } + if o.CertificateHasPrivateKey != nil { + out.Append("certificate.hasPrivateKey", fmt.Sprintf("%v", *o.CertificateHasPrivateKey)) + } + if o.CertificateIsVerified != nil { + out.Append("certificate.isVerified", fmt.Sprintf("%v", *o.CertificateIsVerified)) + } + if o.CertificateLastUpdated != nil { + out.Append("certificate.lastUpdated", fmt.Sprintf("%v", *o.CertificateLastUpdated)) + } + if o.CertificateName != nil { + out.Append("certificate.name", fmt.Sprintf("%v", *o.CertificateName)) + } + if o.CertificateNonce != nil { + out.Append("certificate.nonce", fmt.Sprintf("%v", *o.CertificateNonce)) + } + if o.CertificatePurpose != nil { + out.Append("certificate.purpose", fmt.Sprintf("%v", *o.CertificatePurpose)) + } + if o.CertificateRawBytes != nil { + out.Append("certificate.rawBytes", fmt.Sprintf("%v", *o.CertificateRawBytes)) + } + return &out +} + +// Delete ... +func (c DpsCertificateClient) Delete(ctx context.Context, id CertificateId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + 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 + } + + return +} diff --git a/resource-manager/deviceprovisioningservices/2022-12-12/dpscertificate/method_delete_autorest.go b/resource-manager/deviceprovisioningservices/2022-12-12/dpscertificate/method_delete_autorest.go deleted file mode 100644 index 7a6c03b73ba..00000000000 --- a/resource-manager/deviceprovisioningservices/2022-12-12/dpscertificate/method_delete_autorest.go +++ /dev/null @@ -1,135 +0,0 @@ -package dpscertificate - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// 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 -} - -type DeleteOperationOptions struct { - CertificateCreated *string - CertificateHasPrivateKey *bool - CertificateIsVerified *bool - CertificateLastUpdated *string - CertificateName *string - CertificateNonce *string - CertificatePurpose *CertificatePurpose - CertificateRawBytes *string - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.CertificateCreated != nil { - out["certificate.created"] = *o.CertificateCreated - } - - if o.CertificateHasPrivateKey != nil { - out["certificate.hasPrivateKey"] = *o.CertificateHasPrivateKey - } - - if o.CertificateIsVerified != nil { - out["certificate.isVerified"] = *o.CertificateIsVerified - } - - if o.CertificateLastUpdated != nil { - out["certificate.lastUpdated"] = *o.CertificateLastUpdated - } - - if o.CertificateName != nil { - out["certificate.name"] = *o.CertificateName - } - - if o.CertificateNonce != nil { - out["certificate.nonce"] = *o.CertificateNonce - } - - if o.CertificatePurpose != nil { - out["certificate.purpose"] = *o.CertificatePurpose - } - - if o.CertificateRawBytes != nil { - out["certificate.rawBytes"] = *o.CertificateRawBytes - } - - return out -} - -// Delete ... -func (c DpsCertificateClient) Delete(ctx context.Context, id CertificateId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "dpscertificate.DpsCertificateClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "dpscertificate.DpsCertificateClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "dpscertificate.DpsCertificateClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c DpsCertificateClient) preparerForDelete(ctx context.Context, id CertificateId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c DpsCertificateClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/deviceprovisioningservices/2022-12-12/dpscertificate/method_generateverificationcode.go b/resource-manager/deviceprovisioningservices/2022-12-12/dpscertificate/method_generateverificationcode.go new file mode 100644 index 00000000000..71d676f4f09 --- /dev/null +++ b/resource-manager/deviceprovisioningservices/2022-12-12/dpscertificate/method_generateverificationcode.go @@ -0,0 +1,111 @@ +package dpscertificate + +import ( + "context" + "fmt" + "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 GenerateVerificationCodeOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VerificationCodeResponse +} + +type GenerateVerificationCodeOperationOptions struct { + CertificateCreated *string + CertificateHasPrivateKey *bool + CertificateIsVerified *bool + CertificateLastUpdated *string + CertificateName *string + CertificateNonce *string + CertificatePurpose *CertificatePurpose + CertificateRawBytes *string + IfMatch *string +} + +func DefaultGenerateVerificationCodeOperationOptions() GenerateVerificationCodeOperationOptions { + return GenerateVerificationCodeOperationOptions{} +} + +func (o GenerateVerificationCodeOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o GenerateVerificationCodeOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o GenerateVerificationCodeOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.CertificateCreated != nil { + out.Append("certificate.created", fmt.Sprintf("%v", *o.CertificateCreated)) + } + if o.CertificateHasPrivateKey != nil { + out.Append("certificate.hasPrivateKey", fmt.Sprintf("%v", *o.CertificateHasPrivateKey)) + } + if o.CertificateIsVerified != nil { + out.Append("certificate.isVerified", fmt.Sprintf("%v", *o.CertificateIsVerified)) + } + if o.CertificateLastUpdated != nil { + out.Append("certificate.lastUpdated", fmt.Sprintf("%v", *o.CertificateLastUpdated)) + } + if o.CertificateName != nil { + out.Append("certificate.name", fmt.Sprintf("%v", *o.CertificateName)) + } + if o.CertificateNonce != nil { + out.Append("certificate.nonce", fmt.Sprintf("%v", *o.CertificateNonce)) + } + if o.CertificatePurpose != nil { + out.Append("certificate.purpose", fmt.Sprintf("%v", *o.CertificatePurpose)) + } + if o.CertificateRawBytes != nil { + out.Append("certificate.rawBytes", fmt.Sprintf("%v", *o.CertificateRawBytes)) + } + return &out +} + +// GenerateVerificationCode ... +func (c DpsCertificateClient) GenerateVerificationCode(ctx context.Context, id CertificateId, options GenerateVerificationCodeOperationOptions) (result GenerateVerificationCodeOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/generateVerificationCode", id.ID()), + OptionsObject: options, + } + + 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 +} diff --git a/resource-manager/deviceprovisioningservices/2022-12-12/dpscertificate/method_generateverificationcode_autorest.go b/resource-manager/deviceprovisioningservices/2022-12-12/dpscertificate/method_generateverificationcode_autorest.go deleted file mode 100644 index 41d25d29b3b..00000000000 --- a/resource-manager/deviceprovisioningservices/2022-12-12/dpscertificate/method_generateverificationcode_autorest.go +++ /dev/null @@ -1,138 +0,0 @@ -package dpscertificate - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GenerateVerificationCodeOperationResponse struct { - HttpResponse *http.Response - Model *VerificationCodeResponse -} - -type GenerateVerificationCodeOperationOptions struct { - CertificateCreated *string - CertificateHasPrivateKey *bool - CertificateIsVerified *bool - CertificateLastUpdated *string - CertificateName *string - CertificateNonce *string - CertificatePurpose *CertificatePurpose - CertificateRawBytes *string - IfMatch *string -} - -func DefaultGenerateVerificationCodeOperationOptions() GenerateVerificationCodeOperationOptions { - return GenerateVerificationCodeOperationOptions{} -} - -func (o GenerateVerificationCodeOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o GenerateVerificationCodeOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.CertificateCreated != nil { - out["certificate.created"] = *o.CertificateCreated - } - - if o.CertificateHasPrivateKey != nil { - out["certificate.hasPrivateKey"] = *o.CertificateHasPrivateKey - } - - if o.CertificateIsVerified != nil { - out["certificate.isVerified"] = *o.CertificateIsVerified - } - - if o.CertificateLastUpdated != nil { - out["certificate.lastUpdated"] = *o.CertificateLastUpdated - } - - if o.CertificateName != nil { - out["certificate.name"] = *o.CertificateName - } - - if o.CertificateNonce != nil { - out["certificate.nonce"] = *o.CertificateNonce - } - - if o.CertificatePurpose != nil { - out["certificate.purpose"] = *o.CertificatePurpose - } - - if o.CertificateRawBytes != nil { - out["certificate.rawBytes"] = *o.CertificateRawBytes - } - - return out -} - -// GenerateVerificationCode ... -func (c DpsCertificateClient) GenerateVerificationCode(ctx context.Context, id CertificateId, options GenerateVerificationCodeOperationOptions) (result GenerateVerificationCodeOperationResponse, err error) { - req, err := c.preparerForGenerateVerificationCode(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "dpscertificate.DpsCertificateClient", "GenerateVerificationCode", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "dpscertificate.DpsCertificateClient", "GenerateVerificationCode", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGenerateVerificationCode(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "dpscertificate.DpsCertificateClient", "GenerateVerificationCode", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGenerateVerificationCode prepares the GenerateVerificationCode request. -func (c DpsCertificateClient) preparerForGenerateVerificationCode(ctx context.Context, id CertificateId, options GenerateVerificationCodeOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/generateVerificationCode", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGenerateVerificationCode handles the response to the GenerateVerificationCode request. The method always -// closes the http.Response Body. -func (c DpsCertificateClient) responderForGenerateVerificationCode(resp *http.Response) (result GenerateVerificationCodeOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/deviceprovisioningservices/2022-12-12/dpscertificate/method_get.go b/resource-manager/deviceprovisioningservices/2022-12-12/dpscertificate/method_get.go new file mode 100644 index 00000000000..828c6d2b411 --- /dev/null +++ b/resource-manager/deviceprovisioningservices/2022-12-12/dpscertificate/method_get.go @@ -0,0 +1,80 @@ +package dpscertificate + +import ( + "context" + "fmt" + "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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CertificateResponse +} + +type GetOperationOptions struct { + IfMatch *string +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Get ... +func (c DpsCertificateClient) Get(ctx context.Context, id CertificateId, options GetOperationOptions) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + OptionsObject: options, + } + + 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 +} diff --git a/resource-manager/deviceprovisioningservices/2022-12-12/dpscertificate/method_get_autorest.go b/resource-manager/deviceprovisioningservices/2022-12-12/dpscertificate/method_get_autorest.go deleted file mode 100644 index 7f0baca0673..00000000000 --- a/resource-manager/deviceprovisioningservices/2022-12-12/dpscertificate/method_get_autorest.go +++ /dev/null @@ -1,97 +0,0 @@ -package dpscertificate - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *CertificateResponse -} - -type GetOperationOptions struct { - IfMatch *string -} - -func DefaultGetOperationOptions() GetOperationOptions { - return GetOperationOptions{} -} - -func (o GetOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o GetOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Get ... -func (c DpsCertificateClient) Get(ctx context.Context, id CertificateId, options GetOperationOptions) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "dpscertificate.DpsCertificateClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "dpscertificate.DpsCertificateClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "dpscertificate.DpsCertificateClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c DpsCertificateClient) preparerForGet(ctx context.Context, id CertificateId, options GetOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c DpsCertificateClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/deviceprovisioningservices/2022-12-12/dpscertificate/method_list.go b/resource-manager/deviceprovisioningservices/2022-12-12/dpscertificate/method_list.go new file mode 100644 index 00000000000..b3762237ae0 --- /dev/null +++ b/resource-manager/deviceprovisioningservices/2022-12-12/dpscertificate/method_list.go @@ -0,0 +1,53 @@ +package dpscertificate + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CertificateListDescription +} + +// List ... +func (c DpsCertificateClient) List(ctx context.Context, id commonids.ProvisioningServiceId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/certificates", 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 +} diff --git a/resource-manager/deviceprovisioningservices/2022-12-12/dpscertificate/method_list_autorest.go b/resource-manager/deviceprovisioningservices/2022-12-12/dpscertificate/method_list_autorest.go deleted file mode 100644 index db8e7ec0a3b..00000000000 --- a/resource-manager/deviceprovisioningservices/2022-12-12/dpscertificate/method_list_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package dpscertificate - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListOperationResponse struct { - HttpResponse *http.Response - Model *CertificateListDescription -} - -// List ... -func (c DpsCertificateClient) List(ctx context.Context, id commonids.ProvisioningServiceId) (result ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "dpscertificate.DpsCertificateClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "dpscertificate.DpsCertificateClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "dpscertificate.DpsCertificateClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForList prepares the List request. -func (c DpsCertificateClient) preparerForList(ctx context.Context, id commonids.ProvisioningServiceId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/certificates", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForList handles the response to the List request. The method always -// closes the http.Response Body. -func (c DpsCertificateClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/deviceprovisioningservices/2022-12-12/dpscertificate/method_verifycertificate.go b/resource-manager/deviceprovisioningservices/2022-12-12/dpscertificate/method_verifycertificate.go new file mode 100644 index 00000000000..23e49360468 --- /dev/null +++ b/resource-manager/deviceprovisioningservices/2022-12-12/dpscertificate/method_verifycertificate.go @@ -0,0 +1,115 @@ +package dpscertificate + +import ( + "context" + "fmt" + "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 VerifyCertificateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CertificateResponse +} + +type VerifyCertificateOperationOptions struct { + CertificateCreated *string + CertificateHasPrivateKey *bool + CertificateIsVerified *bool + CertificateLastUpdated *string + CertificateName *string + CertificateNonce *string + CertificatePurpose *CertificatePurpose + CertificateRawBytes *string + IfMatch *string +} + +func DefaultVerifyCertificateOperationOptions() VerifyCertificateOperationOptions { + return VerifyCertificateOperationOptions{} +} + +func (o VerifyCertificateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o VerifyCertificateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o VerifyCertificateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.CertificateCreated != nil { + out.Append("certificate.created", fmt.Sprintf("%v", *o.CertificateCreated)) + } + if o.CertificateHasPrivateKey != nil { + out.Append("certificate.hasPrivateKey", fmt.Sprintf("%v", *o.CertificateHasPrivateKey)) + } + if o.CertificateIsVerified != nil { + out.Append("certificate.isVerified", fmt.Sprintf("%v", *o.CertificateIsVerified)) + } + if o.CertificateLastUpdated != nil { + out.Append("certificate.lastUpdated", fmt.Sprintf("%v", *o.CertificateLastUpdated)) + } + if o.CertificateName != nil { + out.Append("certificate.name", fmt.Sprintf("%v", *o.CertificateName)) + } + if o.CertificateNonce != nil { + out.Append("certificate.nonce", fmt.Sprintf("%v", *o.CertificateNonce)) + } + if o.CertificatePurpose != nil { + out.Append("certificate.purpose", fmt.Sprintf("%v", *o.CertificatePurpose)) + } + if o.CertificateRawBytes != nil { + out.Append("certificate.rawBytes", fmt.Sprintf("%v", *o.CertificateRawBytes)) + } + return &out +} + +// VerifyCertificate ... +func (c DpsCertificateClient) VerifyCertificate(ctx context.Context, id CertificateId, input VerificationCodeRequest, options VerifyCertificateOperationOptions) (result VerifyCertificateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/verify", 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 + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/deviceprovisioningservices/2022-12-12/dpscertificate/method_verifycertificate_autorest.go b/resource-manager/deviceprovisioningservices/2022-12-12/dpscertificate/method_verifycertificate_autorest.go deleted file mode 100644 index cf2e6548db8..00000000000 --- a/resource-manager/deviceprovisioningservices/2022-12-12/dpscertificate/method_verifycertificate_autorest.go +++ /dev/null @@ -1,139 +0,0 @@ -package dpscertificate - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type VerifyCertificateOperationResponse struct { - HttpResponse *http.Response - Model *CertificateResponse -} - -type VerifyCertificateOperationOptions struct { - CertificateCreated *string - CertificateHasPrivateKey *bool - CertificateIsVerified *bool - CertificateLastUpdated *string - CertificateName *string - CertificateNonce *string - CertificatePurpose *CertificatePurpose - CertificateRawBytes *string - IfMatch *string -} - -func DefaultVerifyCertificateOperationOptions() VerifyCertificateOperationOptions { - return VerifyCertificateOperationOptions{} -} - -func (o VerifyCertificateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o VerifyCertificateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.CertificateCreated != nil { - out["certificate.created"] = *o.CertificateCreated - } - - if o.CertificateHasPrivateKey != nil { - out["certificate.hasPrivateKey"] = *o.CertificateHasPrivateKey - } - - if o.CertificateIsVerified != nil { - out["certificate.isVerified"] = *o.CertificateIsVerified - } - - if o.CertificateLastUpdated != nil { - out["certificate.lastUpdated"] = *o.CertificateLastUpdated - } - - if o.CertificateName != nil { - out["certificate.name"] = *o.CertificateName - } - - if o.CertificateNonce != nil { - out["certificate.nonce"] = *o.CertificateNonce - } - - if o.CertificatePurpose != nil { - out["certificate.purpose"] = *o.CertificatePurpose - } - - if o.CertificateRawBytes != nil { - out["certificate.rawBytes"] = *o.CertificateRawBytes - } - - return out -} - -// VerifyCertificate ... -func (c DpsCertificateClient) VerifyCertificate(ctx context.Context, id CertificateId, input VerificationCodeRequest, options VerifyCertificateOperationOptions) (result VerifyCertificateOperationResponse, err error) { - req, err := c.preparerForVerifyCertificate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "dpscertificate.DpsCertificateClient", "VerifyCertificate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "dpscertificate.DpsCertificateClient", "VerifyCertificate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForVerifyCertificate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "dpscertificate.DpsCertificateClient", "VerifyCertificate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForVerifyCertificate prepares the VerifyCertificate request. -func (c DpsCertificateClient) preparerForVerifyCertificate(ctx context.Context, id CertificateId, input VerificationCodeRequest, options VerifyCertificateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/verify", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForVerifyCertificate handles the response to the VerifyCertificate request. The method always -// closes the http.Response Body. -func (c DpsCertificateClient) responderForVerifyCertificate(resp *http.Response) (result VerifyCertificateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/client.go b/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/client.go index 6959319802b..3447cead3f5 100644 --- a/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/client.go +++ b/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/client.go @@ -1,18 +1,26 @@ package iotdpsresource -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 IotDpsResourceClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewIotDpsResourceClientWithBaseURI(endpoint string) IotDpsResourceClient { - return IotDpsResourceClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewIotDpsResourceClientWithBaseURI(api environments.Api) (*IotDpsResourceClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "iotdpsresource", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating IotDpsResourceClient: %+v", err) } + + return &IotDpsResourceClient{ + Client: client, + }, nil } diff --git a/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/constants.go b/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/constants.go index d9256dc2f8c..26b5ec77a1c 100644 --- a/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/constants.go +++ b/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/constants.go @@ -1,6 +1,10 @@ package iotdpsresource -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. @@ -27,6 +31,19 @@ func PossibleValuesForAccessRightsDescription() []string { } } +func (s *AccessRightsDescription) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAccessRightsDescription(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAccessRightsDescription(input string) (*AccessRightsDescription, error) { vals := map[string]AccessRightsDescription{ "deviceconnect": AccessRightsDescriptionDeviceConnect, @@ -61,6 +78,19 @@ func PossibleValuesForAllocationPolicy() []string { } } +func (s *AllocationPolicy) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAllocationPolicy(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAllocationPolicy(input string) (*AllocationPolicy, error) { vals := map[string]AllocationPolicy{ "geolatency": AllocationPolicyGeoLatency, @@ -90,6 +120,19 @@ func PossibleValuesForIPFilterActionType() []string { } } +func (s *IPFilterActionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPFilterActionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseIPFilterActionType(input string) (*IPFilterActionType, error) { vals := map[string]IPFilterActionType{ "accept": IPFilterActionTypeAccept, @@ -120,6 +163,19 @@ func PossibleValuesForIPFilterTargetType() []string { } } +func (s *IPFilterTargetType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPFilterTargetType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseIPFilterTargetType(input string) (*IPFilterTargetType, error) { vals := map[string]IPFilterTargetType{ "all": IPFilterTargetTypeAll, @@ -147,6 +203,19 @@ func PossibleValuesForIotDpsSku() []string { } } +func (s *IotDpsSku) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIotDpsSku(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseIotDpsSku(input string) (*IotDpsSku, error) { vals := map[string]IotDpsSku{ "s1": IotDpsSkuSOne, @@ -174,6 +243,19 @@ func PossibleValuesForNameUnavailabilityReason() []string { } } +func (s *NameUnavailabilityReason) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNameUnavailabilityReason(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseNameUnavailabilityReason(input string) (*NameUnavailabilityReason, error) { vals := map[string]NameUnavailabilityReason{ "alreadyexists": NameUnavailabilityReasonAlreadyExists, @@ -206,6 +288,19 @@ func PossibleValuesForPrivateLinkServiceConnectionStatus() []string { } } +func (s *PrivateLinkServiceConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateLinkServiceConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePrivateLinkServiceConnectionStatus(input string) (*PrivateLinkServiceConnectionStatus, error) { vals := map[string]PrivateLinkServiceConnectionStatus{ "approved": PrivateLinkServiceConnectionStatusApproved, @@ -236,6 +331,19 @@ func PossibleValuesForPublicNetworkAccess() []string { } } +func (s *PublicNetworkAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicNetworkAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePublicNetworkAccess(input string) (*PublicNetworkAccess, error) { vals := map[string]PublicNetworkAccess{ "disabled": PublicNetworkAccessDisabled, @@ -284,6 +392,19 @@ func PossibleValuesForState() []string { } } +func (s *State) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseState(input string) (*State, error) { vals := map[string]State{ "activating": StateActivating, diff --git a/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_checkprovisioningservicenameavailability.go b/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_checkprovisioningservicenameavailability.go new file mode 100644 index 00000000000..5592ded2095 --- /dev/null +++ b/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_checkprovisioningservicenameavailability.go @@ -0,0 +1,57 @@ +package iotdpsresource + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 CheckProvisioningServiceNameAvailabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NameAvailabilityInfo +} + +// CheckProvisioningServiceNameAvailability ... +func (c IotDpsResourceClient) CheckProvisioningServiceNameAvailability(ctx context.Context, id commonids.SubscriptionId, input OperationInputs) (result CheckProvisioningServiceNameAvailabilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.Devices/checkProvisioningServiceNameAvailability", 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 +} diff --git a/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_checkprovisioningservicenameavailability_autorest.go b/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_checkprovisioningservicenameavailability_autorest.go deleted file mode 100644 index c1dd869540d..00000000000 --- a/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_checkprovisioningservicenameavailability_autorest.go +++ /dev/null @@ -1,71 +0,0 @@ -package iotdpsresource - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CheckProvisioningServiceNameAvailabilityOperationResponse struct { - HttpResponse *http.Response - Model *NameAvailabilityInfo -} - -// CheckProvisioningServiceNameAvailability ... -func (c IotDpsResourceClient) CheckProvisioningServiceNameAvailability(ctx context.Context, id commonids.SubscriptionId, input OperationInputs) (result CheckProvisioningServiceNameAvailabilityOperationResponse, err error) { - req, err := c.preparerForCheckProvisioningServiceNameAvailability(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "CheckProvisioningServiceNameAvailability", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "CheckProvisioningServiceNameAvailability", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCheckProvisioningServiceNameAvailability(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "CheckProvisioningServiceNameAvailability", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCheckProvisioningServiceNameAvailability prepares the CheckProvisioningServiceNameAvailability request. -func (c IotDpsResourceClient) preparerForCheckProvisioningServiceNameAvailability(ctx context.Context, id commonids.SubscriptionId, input OperationInputs) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Devices/checkProvisioningServiceNameAvailability", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCheckProvisioningServiceNameAvailability handles the response to the CheckProvisioningServiceNameAvailability request. The method always -// closes the http.Response Body. -func (c IotDpsResourceClient) responderForCheckProvisioningServiceNameAvailability(resp *http.Response) (result CheckProvisioningServiceNameAvailabilityOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_createorupdate.go b/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_createorupdate.go new file mode 100644 index 00000000000..6ef8f4a0a16 --- /dev/null +++ b/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_createorupdate.go @@ -0,0 +1,75 @@ +package iotdpsresource + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 +} + +// CreateOrUpdate ... +func (c IotDpsResourceClient) CreateOrUpdate(ctx context.Context, id commonids.ProvisioningServiceId, input ProvisioningServiceDescription) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 IotDpsResourceClient) CreateOrUpdateThenPoll(ctx context.Context, id commonids.ProvisioningServiceId, input ProvisioningServiceDescription) 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 +} diff --git a/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_createorupdate_autorest.go b/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_createorupdate_autorest.go deleted file mode 100644 index f14ba7d8aee..00000000000 --- a/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_createorupdate_autorest.go +++ /dev/null @@ -1,80 +0,0 @@ -package iotdpsresource - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateOrUpdate ... -func (c IotDpsResourceClient) CreateOrUpdate(ctx context.Context, id commonids.ProvisioningServiceId, input ProvisioningServiceDescription) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c IotDpsResourceClient) CreateOrUpdateThenPoll(ctx context.Context, id commonids.ProvisioningServiceId, input ProvisioningServiceDescription) error { - result, err := c.CreateOrUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateOrUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateOrUpdate: %+v", err) - } - - return nil -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c IotDpsResourceClient) preparerForCreateOrUpdate(ctx context.Context, id commonids.ProvisioningServiceId, input ProvisioningServiceDescription) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateOrUpdate sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c IotDpsResourceClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_createorupdateprivateendpointconnection.go b/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_createorupdateprivateendpointconnection.go new file mode 100644 index 00000000000..d5f2706c3e4 --- /dev/null +++ b/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_createorupdateprivateendpointconnection.go @@ -0,0 +1,74 @@ +package iotdpsresource + +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 CreateOrUpdatePrivateEndpointConnectionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// CreateOrUpdatePrivateEndpointConnection ... +func (c IotDpsResourceClient) CreateOrUpdatePrivateEndpointConnection(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) (result CreateOrUpdatePrivateEndpointConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 +} + +// CreateOrUpdatePrivateEndpointConnectionThenPoll performs CreateOrUpdatePrivateEndpointConnection then polls until it's completed +func (c IotDpsResourceClient) CreateOrUpdatePrivateEndpointConnectionThenPoll(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) error { + result, err := c.CreateOrUpdatePrivateEndpointConnection(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdatePrivateEndpointConnection: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdatePrivateEndpointConnection: %+v", err) + } + + return nil +} diff --git a/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_createorupdateprivateendpointconnection_autorest.go b/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_createorupdateprivateendpointconnection_autorest.go deleted file mode 100644 index d88ede94baa..00000000000 --- a/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_createorupdateprivateendpointconnection_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package iotdpsresource - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdatePrivateEndpointConnectionOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateOrUpdatePrivateEndpointConnection ... -func (c IotDpsResourceClient) CreateOrUpdatePrivateEndpointConnection(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) (result CreateOrUpdatePrivateEndpointConnectionOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdatePrivateEndpointConnection(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "CreateOrUpdatePrivateEndpointConnection", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdatePrivateEndpointConnection(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "CreateOrUpdatePrivateEndpointConnection", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdatePrivateEndpointConnectionThenPoll performs CreateOrUpdatePrivateEndpointConnection then polls until it's completed -func (c IotDpsResourceClient) CreateOrUpdatePrivateEndpointConnectionThenPoll(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) error { - result, err := c.CreateOrUpdatePrivateEndpointConnection(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateOrUpdatePrivateEndpointConnection: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateOrUpdatePrivateEndpointConnection: %+v", err) - } - - return nil -} - -// preparerForCreateOrUpdatePrivateEndpointConnection prepares the CreateOrUpdatePrivateEndpointConnection request. -func (c IotDpsResourceClient) preparerForCreateOrUpdatePrivateEndpointConnection(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateOrUpdatePrivateEndpointConnection sends the CreateOrUpdatePrivateEndpointConnection request. The method will close the -// http.Response Body if it receives an error. -func (c IotDpsResourceClient) senderForCreateOrUpdatePrivateEndpointConnection(ctx context.Context, req *http.Request) (future CreateOrUpdatePrivateEndpointConnectionOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_delete.go b/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_delete.go new file mode 100644 index 00000000000..ab37010b6bb --- /dev/null +++ b/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_delete.go @@ -0,0 +1,72 @@ +package iotdpsresource + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 IotDpsResourceClient) Delete(ctx context.Context, id commonids.ProvisioningServiceId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 IotDpsResourceClient) DeleteThenPoll(ctx context.Context, id commonids.ProvisioningServiceId) 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 +} diff --git a/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_delete_autorest.go b/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_delete_autorest.go deleted file mode 100644 index cbce43eece2..00000000000 --- a/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_delete_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package iotdpsresource - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// Delete ... -func (c IotDpsResourceClient) Delete(ctx context.Context, id commonids.ProvisioningServiceId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c IotDpsResourceClient) DeleteThenPoll(ctx context.Context, id commonids.ProvisioningServiceId) error { - result, err := c.Delete(ctx, id) - if err != nil { - return fmt.Errorf("performing Delete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Delete: %+v", err) - } - - return nil -} - -// preparerForDelete prepares the Delete request. -func (c IotDpsResourceClient) preparerForDelete(ctx context.Context, id commonids.ProvisioningServiceId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDelete sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (c IotDpsResourceClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_deleteprivateendpointconnection.go b/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_deleteprivateendpointconnection.go new file mode 100644 index 00000000000..f756bbb533f --- /dev/null +++ b/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_deleteprivateendpointconnection.go @@ -0,0 +1,71 @@ +package iotdpsresource + +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 DeletePrivateEndpointConnectionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// DeletePrivateEndpointConnection ... +func (c IotDpsResourceClient) DeletePrivateEndpointConnection(ctx context.Context, id PrivateEndpointConnectionId) (result DeletePrivateEndpointConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 +} + +// DeletePrivateEndpointConnectionThenPoll performs DeletePrivateEndpointConnection then polls until it's completed +func (c IotDpsResourceClient) DeletePrivateEndpointConnectionThenPoll(ctx context.Context, id PrivateEndpointConnectionId) error { + result, err := c.DeletePrivateEndpointConnection(ctx, id) + if err != nil { + return fmt.Errorf("performing DeletePrivateEndpointConnection: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DeletePrivateEndpointConnection: %+v", err) + } + + return nil +} diff --git a/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_deleteprivateendpointconnection_autorest.go b/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_deleteprivateendpointconnection_autorest.go deleted file mode 100644 index 47c1a6717cb..00000000000 --- a/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_deleteprivateendpointconnection_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package iotdpsresource - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeletePrivateEndpointConnectionOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// DeletePrivateEndpointConnection ... -func (c IotDpsResourceClient) DeletePrivateEndpointConnection(ctx context.Context, id PrivateEndpointConnectionId) (result DeletePrivateEndpointConnectionOperationResponse, err error) { - req, err := c.preparerForDeletePrivateEndpointConnection(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "DeletePrivateEndpointConnection", nil, "Failure preparing request") - return - } - - result, err = c.senderForDeletePrivateEndpointConnection(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "DeletePrivateEndpointConnection", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeletePrivateEndpointConnectionThenPoll performs DeletePrivateEndpointConnection then polls until it's completed -func (c IotDpsResourceClient) DeletePrivateEndpointConnectionThenPoll(ctx context.Context, id PrivateEndpointConnectionId) error { - result, err := c.DeletePrivateEndpointConnection(ctx, id) - if err != nil { - return fmt.Errorf("performing DeletePrivateEndpointConnection: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after DeletePrivateEndpointConnection: %+v", err) - } - - return nil -} - -// preparerForDeletePrivateEndpointConnection prepares the DeletePrivateEndpointConnection request. -func (c IotDpsResourceClient) preparerForDeletePrivateEndpointConnection(ctx context.Context, id PrivateEndpointConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDeletePrivateEndpointConnection sends the DeletePrivateEndpointConnection request. The method will close the -// http.Response Body if it receives an error. -func (c IotDpsResourceClient) senderForDeletePrivateEndpointConnection(ctx context.Context, req *http.Request) (future DeletePrivateEndpointConnectionOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_get.go b/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_get.go new file mode 100644 index 00000000000..84c4f5acd69 --- /dev/null +++ b/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_get.go @@ -0,0 +1,52 @@ +package iotdpsresource + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ProvisioningServiceDescription +} + +// Get ... +func (c IotDpsResourceClient) Get(ctx context.Context, id commonids.ProvisioningServiceId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_get_autorest.go b/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_get_autorest.go deleted file mode 100644 index 3c9cb772f57..00000000000 --- a/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_get_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package iotdpsresource - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *ProvisioningServiceDescription -} - -// Get ... -func (c IotDpsResourceClient) Get(ctx context.Context, id commonids.ProvisioningServiceId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c IotDpsResourceClient) preparerForGet(ctx context.Context, id commonids.ProvisioningServiceId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c IotDpsResourceClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_getprivateendpointconnection.go b/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_getprivateendpointconnection.go new file mode 100644 index 00000000000..a9efb50aba3 --- /dev/null +++ b/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_getprivateendpointconnection.go @@ -0,0 +1,51 @@ +package iotdpsresource + +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 GetPrivateEndpointConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateEndpointConnection +} + +// GetPrivateEndpointConnection ... +func (c IotDpsResourceClient) GetPrivateEndpointConnection(ctx context.Context, id PrivateEndpointConnectionId) (result GetPrivateEndpointConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_getprivateendpointconnection_autorest.go b/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_getprivateendpointconnection_autorest.go deleted file mode 100644 index 263ab973d8f..00000000000 --- a/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_getprivateendpointconnection_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package iotdpsresource - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetPrivateEndpointConnectionOperationResponse struct { - HttpResponse *http.Response - Model *PrivateEndpointConnection -} - -// GetPrivateEndpointConnection ... -func (c IotDpsResourceClient) GetPrivateEndpointConnection(ctx context.Context, id PrivateEndpointConnectionId) (result GetPrivateEndpointConnectionOperationResponse, err error) { - req, err := c.preparerForGetPrivateEndpointConnection(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "GetPrivateEndpointConnection", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "GetPrivateEndpointConnection", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetPrivateEndpointConnection(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "GetPrivateEndpointConnection", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetPrivateEndpointConnection prepares the GetPrivateEndpointConnection request. -func (c IotDpsResourceClient) preparerForGetPrivateEndpointConnection(ctx context.Context, id PrivateEndpointConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetPrivateEndpointConnection handles the response to the GetPrivateEndpointConnection request. The method always -// closes the http.Response Body. -func (c IotDpsResourceClient) responderForGetPrivateEndpointConnection(resp *http.Response) (result GetPrivateEndpointConnectionOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_getprivatelinkresources.go b/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_getprivatelinkresources.go new file mode 100644 index 00000000000..df474196652 --- /dev/null +++ b/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_getprivatelinkresources.go @@ -0,0 +1,51 @@ +package iotdpsresource + +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 GetPrivateLinkResourcesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *GroupIdInformation +} + +// GetPrivateLinkResources ... +func (c IotDpsResourceClient) GetPrivateLinkResources(ctx context.Context, id PrivateLinkResourceId) (result GetPrivateLinkResourcesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_getprivatelinkresources_autorest.go b/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_getprivatelinkresources_autorest.go deleted file mode 100644 index 37f80ffc338..00000000000 --- a/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_getprivatelinkresources_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package iotdpsresource - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetPrivateLinkResourcesOperationResponse struct { - HttpResponse *http.Response - Model *GroupIdInformation -} - -// GetPrivateLinkResources ... -func (c IotDpsResourceClient) GetPrivateLinkResources(ctx context.Context, id PrivateLinkResourceId) (result GetPrivateLinkResourcesOperationResponse, err error) { - req, err := c.preparerForGetPrivateLinkResources(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "GetPrivateLinkResources", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "GetPrivateLinkResources", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetPrivateLinkResources(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "GetPrivateLinkResources", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetPrivateLinkResources prepares the GetPrivateLinkResources request. -func (c IotDpsResourceClient) preparerForGetPrivateLinkResources(ctx context.Context, id PrivateLinkResourceId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetPrivateLinkResources handles the response to the GetPrivateLinkResources request. The method always -// closes the http.Response Body. -func (c IotDpsResourceClient) responderForGetPrivateLinkResources(resp *http.Response) (result GetPrivateLinkResourcesOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_listbyresourcegroup.go b/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_listbyresourcegroup.go new file mode 100644 index 00000000000..5149f6de916 --- /dev/null +++ b/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_listbyresourcegroup.go @@ -0,0 +1,90 @@ +package iotdpsresource + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProvisioningServiceDescription +} + +type ListByResourceGroupCompleteResult struct { + Items []ProvisioningServiceDescription +} + +// ListByResourceGroup ... +func (c IotDpsResourceClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Devices/provisioningServices", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ProvisioningServiceDescription `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c IotDpsResourceClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, ProvisioningServiceDescriptionOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c IotDpsResourceClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ProvisioningServiceDescriptionOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]ProvisioningServiceDescription, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_listbyresourcegroup_autorest.go b/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_listbyresourcegroup_autorest.go deleted file mode 100644 index a56e2ebc039..00000000000 --- a/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_listbyresourcegroup_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package iotdpsresource - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByResourceGroupOperationResponse struct { - HttpResponse *http.Response - Model *[]ProvisioningServiceDescription - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByResourceGroupOperationResponse, error) -} - -type ListByResourceGroupCompleteResult struct { - Items []ProvisioningServiceDescription -} - -func (r ListByResourceGroupOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByResourceGroupOperationResponse) LoadMore(ctx context.Context) (resp ListByResourceGroupOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByResourceGroup ... -func (c IotDpsResourceClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (resp ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroup(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListByResourceGroup", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByResourceGroup(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListByResourceGroup", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByResourceGroup prepares the ListByResourceGroup request. -func (c IotDpsResourceClient) preparerForListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Devices/provisioningServices", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByResourceGroupWithNextLink prepares the ListByResourceGroup request with the given nextLink token. -func (c IotDpsResourceClient) preparerForListByResourceGroupWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByResourceGroup handles the response to the ListByResourceGroup request. The method always -// closes the http.Response Body. -func (c IotDpsResourceClient) responderForListByResourceGroup(resp *http.Response) (result ListByResourceGroupOperationResponse, err error) { - type page struct { - Values []ProvisioningServiceDescription `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroupWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListByResourceGroup", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByResourceGroup(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListByResourceGroup", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByResourceGroupComplete retrieves all of the results into a single object -func (c IotDpsResourceClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { - return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, ProvisioningServiceDescriptionOperationPredicate{}) -} - -// ListByResourceGroupCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c IotDpsResourceClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ProvisioningServiceDescriptionOperationPredicate) (resp ListByResourceGroupCompleteResult, err error) { - items := make([]ProvisioningServiceDescription, 0) - - page, err := c.ListByResourceGroup(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByResourceGroupCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_listbysubscription.go b/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_listbysubscription.go new file mode 100644 index 00000000000..55e4cc17533 --- /dev/null +++ b/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_listbysubscription.go @@ -0,0 +1,90 @@ +package iotdpsresource + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProvisioningServiceDescription +} + +type ListBySubscriptionCompleteResult struct { + Items []ProvisioningServiceDescription +} + +// ListBySubscription ... +func (c IotDpsResourceClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Devices/provisioningServices", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ProvisioningServiceDescription `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c IotDpsResourceClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, ProvisioningServiceDescriptionOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c IotDpsResourceClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ProvisioningServiceDescriptionOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]ProvisioningServiceDescription, 0) + + resp, err := c.ListBySubscription(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListBySubscriptionCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_listbysubscription_autorest.go b/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_listbysubscription_autorest.go deleted file mode 100644 index d14ae2fb27b..00000000000 --- a/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_listbysubscription_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package iotdpsresource - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListBySubscriptionOperationResponse struct { - HttpResponse *http.Response - Model *[]ProvisioningServiceDescription - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListBySubscriptionOperationResponse, error) -} - -type ListBySubscriptionCompleteResult struct { - Items []ProvisioningServiceDescription -} - -func (r ListBySubscriptionOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListBySubscriptionOperationResponse) LoadMore(ctx context.Context) (resp ListBySubscriptionOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListBySubscription ... -func (c IotDpsResourceClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (resp ListBySubscriptionOperationResponse, err error) { - req, err := c.preparerForListBySubscription(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListBySubscription", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListBySubscription", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListBySubscription(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListBySubscription", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListBySubscription prepares the ListBySubscription request. -func (c IotDpsResourceClient) preparerForListBySubscription(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Devices/provisioningServices", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListBySubscriptionWithNextLink prepares the ListBySubscription request with the given nextLink token. -func (c IotDpsResourceClient) preparerForListBySubscriptionWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListBySubscription handles the response to the ListBySubscription request. The method always -// closes the http.Response Body. -func (c IotDpsResourceClient) responderForListBySubscription(resp *http.Response) (result ListBySubscriptionOperationResponse, err error) { - type page struct { - Values []ProvisioningServiceDescription `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListBySubscriptionOperationResponse, err error) { - req, err := c.preparerForListBySubscriptionWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListBySubscription", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListBySubscription", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListBySubscription(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListBySubscription", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListBySubscriptionComplete retrieves all of the results into a single object -func (c IotDpsResourceClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { - return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, ProvisioningServiceDescriptionOperationPredicate{}) -} - -// ListBySubscriptionCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c IotDpsResourceClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ProvisioningServiceDescriptionOperationPredicate) (resp ListBySubscriptionCompleteResult, err error) { - items := make([]ProvisioningServiceDescription, 0) - - page, err := c.ListBySubscription(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListBySubscriptionCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_listkeys.go b/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_listkeys.go new file mode 100644 index 00000000000..aee09b0e095 --- /dev/null +++ b/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_listkeys.go @@ -0,0 +1,90 @@ +package iotdpsresource + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListKeysOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SharedAccessSignatureAuthorizationRuleAccessRightsDescription +} + +type ListKeysCompleteResult struct { + Items []SharedAccessSignatureAuthorizationRuleAccessRightsDescription +} + +// ListKeys ... +func (c IotDpsResourceClient) ListKeys(ctx context.Context, id commonids.ProvisioningServiceId) (result ListKeysOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listkeys", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]SharedAccessSignatureAuthorizationRuleAccessRightsDescription `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListKeysComplete retrieves all the results into a single object +func (c IotDpsResourceClient) ListKeysComplete(ctx context.Context, id commonids.ProvisioningServiceId) (ListKeysCompleteResult, error) { + return c.ListKeysCompleteMatchingPredicate(ctx, id, SharedAccessSignatureAuthorizationRuleAccessRightsDescriptionOperationPredicate{}) +} + +// ListKeysCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c IotDpsResourceClient) ListKeysCompleteMatchingPredicate(ctx context.Context, id commonids.ProvisioningServiceId, predicate SharedAccessSignatureAuthorizationRuleAccessRightsDescriptionOperationPredicate) (result ListKeysCompleteResult, err error) { + items := make([]SharedAccessSignatureAuthorizationRuleAccessRightsDescription, 0) + + resp, err := c.ListKeys(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListKeysCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_listkeys_autorest.go b/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_listkeys_autorest.go deleted file mode 100644 index dfd0377cde2..00000000000 --- a/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_listkeys_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package iotdpsresource - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListKeysOperationResponse struct { - HttpResponse *http.Response - Model *[]SharedAccessSignatureAuthorizationRuleAccessRightsDescription - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListKeysOperationResponse, error) -} - -type ListKeysCompleteResult struct { - Items []SharedAccessSignatureAuthorizationRuleAccessRightsDescription -} - -func (r ListKeysOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListKeysOperationResponse) LoadMore(ctx context.Context) (resp ListKeysOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListKeys ... -func (c IotDpsResourceClient) ListKeys(ctx context.Context, id commonids.ProvisioningServiceId) (resp ListKeysOperationResponse, err error) { - req, err := c.preparerForListKeys(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListKeys", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListKeys", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListKeys(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListKeys", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListKeys prepares the ListKeys request. -func (c IotDpsResourceClient) preparerForListKeys(ctx context.Context, id commonids.ProvisioningServiceId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/listkeys", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListKeysWithNextLink prepares the ListKeys request with the given nextLink token. -func (c IotDpsResourceClient) preparerForListKeysWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListKeys handles the response to the ListKeys request. The method always -// closes the http.Response Body. -func (c IotDpsResourceClient) responderForListKeys(resp *http.Response) (result ListKeysOperationResponse, err error) { - type page struct { - Values []SharedAccessSignatureAuthorizationRuleAccessRightsDescription `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListKeysOperationResponse, err error) { - req, err := c.preparerForListKeysWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListKeys", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListKeys", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListKeys(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListKeys", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListKeysComplete retrieves all of the results into a single object -func (c IotDpsResourceClient) ListKeysComplete(ctx context.Context, id commonids.ProvisioningServiceId) (ListKeysCompleteResult, error) { - return c.ListKeysCompleteMatchingPredicate(ctx, id, SharedAccessSignatureAuthorizationRuleAccessRightsDescriptionOperationPredicate{}) -} - -// ListKeysCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c IotDpsResourceClient) ListKeysCompleteMatchingPredicate(ctx context.Context, id commonids.ProvisioningServiceId, predicate SharedAccessSignatureAuthorizationRuleAccessRightsDescriptionOperationPredicate) (resp ListKeysCompleteResult, err error) { - items := make([]SharedAccessSignatureAuthorizationRuleAccessRightsDescription, 0) - - page, err := c.ListKeys(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListKeysCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_listkeysforkeyname.go b/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_listkeysforkeyname.go new file mode 100644 index 00000000000..f9bdd960052 --- /dev/null +++ b/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_listkeysforkeyname.go @@ -0,0 +1,52 @@ +package iotdpsresource + +import ( + "context" + "fmt" + "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 ListKeysForKeyNameOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SharedAccessSignatureAuthorizationRuleAccessRightsDescription +} + +// ListKeysForKeyName ... +func (c IotDpsResourceClient) ListKeysForKeyName(ctx context.Context, id KeyId) (result ListKeysForKeyNameOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listkeys", 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 +} diff --git a/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_listkeysforkeyname_autorest.go b/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_listkeysforkeyname_autorest.go deleted file mode 100644 index 9c42234978c..00000000000 --- a/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_listkeysforkeyname_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package iotdpsresource - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListKeysForKeyNameOperationResponse struct { - HttpResponse *http.Response - Model *SharedAccessSignatureAuthorizationRuleAccessRightsDescription -} - -// ListKeysForKeyName ... -func (c IotDpsResourceClient) ListKeysForKeyName(ctx context.Context, id KeyId) (result ListKeysForKeyNameOperationResponse, err error) { - req, err := c.preparerForListKeysForKeyName(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListKeysForKeyName", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListKeysForKeyName", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListKeysForKeyName(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListKeysForKeyName", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListKeysForKeyName prepares the ListKeysForKeyName request. -func (c IotDpsResourceClient) preparerForListKeysForKeyName(ctx context.Context, id KeyId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/listkeys", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListKeysForKeyName handles the response to the ListKeysForKeyName request. The method always -// closes the http.Response Body. -func (c IotDpsResourceClient) responderForListKeysForKeyName(resp *http.Response) (result ListKeysForKeyNameOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_listprivateendpointconnections.go b/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_listprivateendpointconnections.go new file mode 100644 index 00000000000..1f20a68e5f0 --- /dev/null +++ b/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_listprivateendpointconnections.go @@ -0,0 +1,53 @@ +package iotdpsresource + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListPrivateEndpointConnectionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PrivateEndpointConnection +} + +// ListPrivateEndpointConnections ... +func (c IotDpsResourceClient) ListPrivateEndpointConnections(ctx context.Context, id commonids.ProvisioningServiceId) (result ListPrivateEndpointConnectionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateEndpointConnections", 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 +} diff --git a/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_listprivateendpointconnections_autorest.go b/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_listprivateendpointconnections_autorest.go deleted file mode 100644 index b3bdd0f766a..00000000000 --- a/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_listprivateendpointconnections_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package iotdpsresource - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListPrivateEndpointConnectionsOperationResponse struct { - HttpResponse *http.Response - Model *[]PrivateEndpointConnection -} - -// ListPrivateEndpointConnections ... -func (c IotDpsResourceClient) ListPrivateEndpointConnections(ctx context.Context, id commonids.ProvisioningServiceId) (result ListPrivateEndpointConnectionsOperationResponse, err error) { - req, err := c.preparerForListPrivateEndpointConnections(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListPrivateEndpointConnections", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListPrivateEndpointConnections", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListPrivateEndpointConnections(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListPrivateEndpointConnections", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListPrivateEndpointConnections prepares the ListPrivateEndpointConnections request. -func (c IotDpsResourceClient) preparerForListPrivateEndpointConnections(ctx context.Context, id commonids.ProvisioningServiceId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/privateEndpointConnections", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListPrivateEndpointConnections handles the response to the ListPrivateEndpointConnections request. The method always -// closes the http.Response Body. -func (c IotDpsResourceClient) responderForListPrivateEndpointConnections(resp *http.Response) (result ListPrivateEndpointConnectionsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_listprivatelinkresources.go b/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_listprivatelinkresources.go new file mode 100644 index 00000000000..6c55400c101 --- /dev/null +++ b/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_listprivatelinkresources.go @@ -0,0 +1,53 @@ +package iotdpsresource + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListPrivateLinkResourcesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateLinkResources +} + +// ListPrivateLinkResources ... +func (c IotDpsResourceClient) ListPrivateLinkResources(ctx context.Context, id commonids.ProvisioningServiceId) (result ListPrivateLinkResourcesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateLinkResources", 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 +} diff --git a/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_listprivatelinkresources_autorest.go b/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_listprivatelinkresources_autorest.go deleted file mode 100644 index 290a19b7812..00000000000 --- a/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_listprivatelinkresources_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package iotdpsresource - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListPrivateLinkResourcesOperationResponse struct { - HttpResponse *http.Response - Model *PrivateLinkResources -} - -// ListPrivateLinkResources ... -func (c IotDpsResourceClient) ListPrivateLinkResources(ctx context.Context, id commonids.ProvisioningServiceId) (result ListPrivateLinkResourcesOperationResponse, err error) { - req, err := c.preparerForListPrivateLinkResources(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListPrivateLinkResources", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListPrivateLinkResources", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListPrivateLinkResources(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListPrivateLinkResources", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListPrivateLinkResources prepares the ListPrivateLinkResources request. -func (c IotDpsResourceClient) preparerForListPrivateLinkResources(ctx context.Context, id commonids.ProvisioningServiceId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/privateLinkResources", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListPrivateLinkResources handles the response to the ListPrivateLinkResources request. The method always -// closes the http.Response Body. -func (c IotDpsResourceClient) responderForListPrivateLinkResources(resp *http.Response) (result ListPrivateLinkResourcesOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_listvalidskus.go b/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_listvalidskus.go new file mode 100644 index 00000000000..e856a0ddef6 --- /dev/null +++ b/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_listvalidskus.go @@ -0,0 +1,90 @@ +package iotdpsresource + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListValidSkusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]IotDpsSkuDefinition +} + +type ListValidSkusCompleteResult struct { + Items []IotDpsSkuDefinition +} + +// ListValidSkus ... +func (c IotDpsResourceClient) ListValidSkus(ctx context.Context, id commonids.ProvisioningServiceId) (result ListValidSkusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/skus", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]IotDpsSkuDefinition `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListValidSkusComplete retrieves all the results into a single object +func (c IotDpsResourceClient) ListValidSkusComplete(ctx context.Context, id commonids.ProvisioningServiceId) (ListValidSkusCompleteResult, error) { + return c.ListValidSkusCompleteMatchingPredicate(ctx, id, IotDpsSkuDefinitionOperationPredicate{}) +} + +// ListValidSkusCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c IotDpsResourceClient) ListValidSkusCompleteMatchingPredicate(ctx context.Context, id commonids.ProvisioningServiceId, predicate IotDpsSkuDefinitionOperationPredicate) (result ListValidSkusCompleteResult, err error) { + items := make([]IotDpsSkuDefinition, 0) + + resp, err := c.ListValidSkus(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListValidSkusCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_listvalidskus_autorest.go b/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_listvalidskus_autorest.go deleted file mode 100644 index 59b8b6a312f..00000000000 --- a/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_listvalidskus_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package iotdpsresource - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListValidSkusOperationResponse struct { - HttpResponse *http.Response - Model *[]IotDpsSkuDefinition - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListValidSkusOperationResponse, error) -} - -type ListValidSkusCompleteResult struct { - Items []IotDpsSkuDefinition -} - -func (r ListValidSkusOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListValidSkusOperationResponse) LoadMore(ctx context.Context) (resp ListValidSkusOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListValidSkus ... -func (c IotDpsResourceClient) ListValidSkus(ctx context.Context, id commonids.ProvisioningServiceId) (resp ListValidSkusOperationResponse, err error) { - req, err := c.preparerForListValidSkus(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListValidSkus", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListValidSkus", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListValidSkus(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListValidSkus", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListValidSkus prepares the ListValidSkus request. -func (c IotDpsResourceClient) preparerForListValidSkus(ctx context.Context, id commonids.ProvisioningServiceId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/skus", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListValidSkusWithNextLink prepares the ListValidSkus request with the given nextLink token. -func (c IotDpsResourceClient) preparerForListValidSkusWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListValidSkus handles the response to the ListValidSkus request. The method always -// closes the http.Response Body. -func (c IotDpsResourceClient) responderForListValidSkus(resp *http.Response) (result ListValidSkusOperationResponse, err error) { - type page struct { - Values []IotDpsSkuDefinition `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListValidSkusOperationResponse, err error) { - req, err := c.preparerForListValidSkusWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListValidSkus", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListValidSkus", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListValidSkus(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "ListValidSkus", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListValidSkusComplete retrieves all of the results into a single object -func (c IotDpsResourceClient) ListValidSkusComplete(ctx context.Context, id commonids.ProvisioningServiceId) (ListValidSkusCompleteResult, error) { - return c.ListValidSkusCompleteMatchingPredicate(ctx, id, IotDpsSkuDefinitionOperationPredicate{}) -} - -// ListValidSkusCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c IotDpsResourceClient) ListValidSkusCompleteMatchingPredicate(ctx context.Context, id commonids.ProvisioningServiceId, predicate IotDpsSkuDefinitionOperationPredicate) (resp ListValidSkusCompleteResult, err error) { - items := make([]IotDpsSkuDefinition, 0) - - page, err := c.ListValidSkus(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListValidSkusCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_update.go b/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_update.go new file mode 100644 index 00000000000..f5a5248296a --- /dev/null +++ b/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_update.go @@ -0,0 +1,74 @@ +package iotdpsresource + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Update ... +func (c IotDpsResourceClient) Update(ctx context.Context, id commonids.ProvisioningServiceId, input TagsResource) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + 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 +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c IotDpsResourceClient) UpdateThenPoll(ctx context.Context, id commonids.ProvisioningServiceId, input TagsResource) error { + result, err := c.Update(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_update_autorest.go b/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_update_autorest.go deleted file mode 100644 index 4f4e60344e8..00000000000 --- a/resource-manager/deviceprovisioningservices/2022-12-12/iotdpsresource/method_update_autorest.go +++ /dev/null @@ -1,80 +0,0 @@ -package iotdpsresource - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Update ... -func (c IotDpsResourceClient) Update(ctx context.Context, id commonids.ProvisioningServiceId, input TagsResource) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "Update", nil, "Failure preparing request") - return - } - - result, err = c.senderForUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "iotdpsresource.IotDpsResourceClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// UpdateThenPoll performs Update then polls until it's completed -func (c IotDpsResourceClient) UpdateThenPoll(ctx context.Context, id commonids.ProvisioningServiceId, input TagsResource) error { - result, err := c.Update(ctx, id, input) - if err != nil { - return fmt.Errorf("performing Update: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Update: %+v", err) - } - - return nil -} - -// preparerForUpdate prepares the Update request. -func (c IotDpsResourceClient) preparerForUpdate(ctx context.Context, id commonids.ProvisioningServiceId, input TagsResource) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForUpdate sends the Update request. The method will close the -// http.Response Body if it receives an error. -func (c IotDpsResourceClient) senderForUpdate(ctx context.Context, req *http.Request) (future UpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/deviceupdate/2022-10-01/client.go b/resource-manager/deviceupdate/2022-10-01/client.go index e68f3ce7a96..d8ac55322b3 100644 --- a/resource-manager/deviceupdate/2022-10-01/client.go +++ b/resource-manager/deviceupdate/2022-10-01/client.go @@ -4,11 +4,14 @@ package v2022_10_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/deviceupdate/2022-10-01/deviceupdates" "github.com/hashicorp/go-azure-sdk/resource-manager/deviceupdate/2022-10-01/privateendpointconnectionproxies" "github.com/hashicorp/go-azure-sdk/resource-manager/deviceupdate/2022-10-01/privateendpointconnections" "github.com/hashicorp/go-azure-sdk/resource-manager/deviceupdate/2022-10-01/privatelinkresources" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/environments" ) type Client struct { @@ -18,24 +21,35 @@ type Client struct { PrivateLinkResources *privatelinkresources.PrivateLinkResourcesClient } -func NewClientWithBaseURI(endpoint string, configureAuthFunc func(c *autorest.Client)) Client { - - deviceupdatesClient := deviceupdates.NewDeviceupdatesClientWithBaseURI(endpoint) - configureAuthFunc(&deviceupdatesClient.Client) - - privateEndpointConnectionProxiesClient := privateendpointconnectionproxies.NewPrivateEndpointConnectionProxiesClientWithBaseURI(endpoint) - configureAuthFunc(&privateEndpointConnectionProxiesClient.Client) +func NewClientWithBaseURI(api environments.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + deviceupdatesClient, err := deviceupdates.NewDeviceupdatesClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Deviceupdates client: %+v", err) + } + configureFunc(deviceupdatesClient.Client) - privateEndpointConnectionsClient := privateendpointconnections.NewPrivateEndpointConnectionsClientWithBaseURI(endpoint) - configureAuthFunc(&privateEndpointConnectionsClient.Client) + privateEndpointConnectionProxiesClient, err := privateendpointconnectionproxies.NewPrivateEndpointConnectionProxiesClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building PrivateEndpointConnectionProxies client: %+v", err) + } + configureFunc(privateEndpointConnectionProxiesClient.Client) - privateLinkResourcesClient := privatelinkresources.NewPrivateLinkResourcesClientWithBaseURI(endpoint) - configureAuthFunc(&privateLinkResourcesClient.Client) + privateEndpointConnectionsClient, err := privateendpointconnections.NewPrivateEndpointConnectionsClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building PrivateEndpointConnections client: %+v", err) + } + configureFunc(privateEndpointConnectionsClient.Client) - return Client{ - Deviceupdates: &deviceupdatesClient, - PrivateEndpointConnectionProxies: &privateEndpointConnectionProxiesClient, - PrivateEndpointConnections: &privateEndpointConnectionsClient, - PrivateLinkResources: &privateLinkResourcesClient, + privateLinkResourcesClient, err := privatelinkresources.NewPrivateLinkResourcesClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building PrivateLinkResources client: %+v", err) } + configureFunc(privateLinkResourcesClient.Client) + + return &Client{ + Deviceupdates: deviceupdatesClient, + PrivateEndpointConnectionProxies: privateEndpointConnectionProxiesClient, + PrivateEndpointConnections: privateEndpointConnectionsClient, + PrivateLinkResources: privateLinkResourcesClient, + }, nil } diff --git a/resource-manager/deviceupdate/2022-10-01/deviceupdates/client.go b/resource-manager/deviceupdate/2022-10-01/deviceupdates/client.go index affade9d5b4..1823789119d 100644 --- a/resource-manager/deviceupdate/2022-10-01/deviceupdates/client.go +++ b/resource-manager/deviceupdate/2022-10-01/deviceupdates/client.go @@ -1,18 +1,26 @@ package deviceupdates -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 DeviceupdatesClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewDeviceupdatesClientWithBaseURI(endpoint string) DeviceupdatesClient { - return DeviceupdatesClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewDeviceupdatesClientWithBaseURI(api environments.Api) (*DeviceupdatesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "deviceupdates", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DeviceupdatesClient: %+v", err) } + + return &DeviceupdatesClient{ + Client: client, + }, nil } diff --git a/resource-manager/deviceupdate/2022-10-01/deviceupdates/constants.go b/resource-manager/deviceupdate/2022-10-01/deviceupdates/constants.go index fdc9b86bb24..a7fa4ca7c76 100644 --- a/resource-manager/deviceupdate/2022-10-01/deviceupdates/constants.go +++ b/resource-manager/deviceupdate/2022-10-01/deviceupdates/constants.go @@ -1,6 +1,10 @@ package deviceupdates -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. @@ -17,6 +21,19 @@ func PossibleValuesForAuthenticationType() []string { } } +func (s *AuthenticationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAuthenticationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAuthenticationType(input string) (*AuthenticationType, error) { vals := map[string]AuthenticationType{ "keybased": AuthenticationTypeKeyBased, @@ -44,6 +61,19 @@ func PossibleValuesForCheckNameAvailabilityReason() []string { } } +func (s *CheckNameAvailabilityReason) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCheckNameAvailabilityReason(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseCheckNameAvailabilityReason(input string) (*CheckNameAvailabilityReason, error) { vals := map[string]CheckNameAvailabilityReason{ "alreadyexists": CheckNameAvailabilityReasonAlreadyExists, @@ -76,6 +106,19 @@ func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { } } +func (s *PrivateEndpointConnectionProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointConnectionProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { vals := map[string]PrivateEndpointConnectionProvisioningState{ "creating": PrivateEndpointConnectionProvisioningStateCreating, @@ -110,6 +153,19 @@ func PossibleValuesForPrivateEndpointConnectionProxyProvisioningState() []string } } +func (s *PrivateEndpointConnectionProxyProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointConnectionProxyProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePrivateEndpointConnectionProxyProvisioningState(input string) (*PrivateEndpointConnectionProxyProvisioningState, error) { vals := map[string]PrivateEndpointConnectionProxyProvisioningState{ "creating": PrivateEndpointConnectionProxyProvisioningStateCreating, @@ -142,6 +198,19 @@ func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { } } +func (s *PrivateEndpointServiceConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointServiceConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { vals := map[string]PrivateEndpointServiceConnectionStatus{ "approved": PrivateEndpointServiceConnectionStatusApproved, @@ -179,6 +248,19 @@ func PossibleValuesForProvisioningState() []string { } } +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseProvisioningState(input string) (*ProvisioningState, error) { vals := map[string]ProvisioningState{ "accepted": ProvisioningStateAccepted, @@ -211,6 +293,19 @@ func PossibleValuesForPublicNetworkAccess() []string { } } +func (s *PublicNetworkAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicNetworkAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePublicNetworkAccess(input string) (*PublicNetworkAccess, error) { vals := map[string]PublicNetworkAccess{ "disabled": PublicNetworkAccessDisabled, @@ -239,6 +334,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{ "failover": RoleFailover, @@ -267,6 +375,19 @@ func PossibleValuesForSKU() []string { } } +func (s *SKU) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSKU(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseSKU(input string) (*SKU, error) { vals := map[string]SKU{ "free": SKUFree, diff --git a/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_accountscreate.go b/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_accountscreate.go new file mode 100644 index 00000000000..1e920e78d74 --- /dev/null +++ b/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_accountscreate.go @@ -0,0 +1,73 @@ +package deviceupdates + +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 AccountsCreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// AccountsCreate ... +func (c DeviceupdatesClient) AccountsCreate(ctx context.Context, id AccountId, input Account) (result AccountsCreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + 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 +} + +// AccountsCreateThenPoll performs AccountsCreate then polls until it's completed +func (c DeviceupdatesClient) AccountsCreateThenPoll(ctx context.Context, id AccountId, input Account) error { + result, err := c.AccountsCreate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing AccountsCreate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after AccountsCreate: %+v", err) + } + + return nil +} diff --git a/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_accountscreate_autorest.go b/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_accountscreate_autorest.go deleted file mode 100644 index 100da51a1da..00000000000 --- a/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_accountscreate_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package deviceupdates - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type AccountsCreateOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// AccountsCreate ... -func (c DeviceupdatesClient) AccountsCreate(ctx context.Context, id AccountId, input Account) (result AccountsCreateOperationResponse, err error) { - req, err := c.preparerForAccountsCreate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "AccountsCreate", nil, "Failure preparing request") - return - } - - result, err = c.senderForAccountsCreate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "AccountsCreate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// AccountsCreateThenPoll performs AccountsCreate then polls until it's completed -func (c DeviceupdatesClient) AccountsCreateThenPoll(ctx context.Context, id AccountId, input Account) error { - result, err := c.AccountsCreate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing AccountsCreate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after AccountsCreate: %+v", err) - } - - return nil -} - -// preparerForAccountsCreate prepares the AccountsCreate request. -func (c DeviceupdatesClient) preparerForAccountsCreate(ctx context.Context, id AccountId, input Account) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForAccountsCreate sends the AccountsCreate request. The method will close the -// http.Response Body if it receives an error. -func (c DeviceupdatesClient) senderForAccountsCreate(ctx context.Context, req *http.Request) (future AccountsCreateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_accountsdelete.go b/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_accountsdelete.go new file mode 100644 index 00000000000..92d0922688a --- /dev/null +++ b/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_accountsdelete.go @@ -0,0 +1,71 @@ +package deviceupdates + +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 AccountsDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// AccountsDelete ... +func (c DeviceupdatesClient) AccountsDelete(ctx context.Context, id AccountId) (result AccountsDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 +} + +// AccountsDeleteThenPoll performs AccountsDelete then polls until it's completed +func (c DeviceupdatesClient) AccountsDeleteThenPoll(ctx context.Context, id AccountId) error { + result, err := c.AccountsDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing AccountsDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after AccountsDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_accountsdelete_autorest.go b/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_accountsdelete_autorest.go deleted file mode 100644 index 59bcdb557b0..00000000000 --- a/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_accountsdelete_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package deviceupdates - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type AccountsDeleteOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// AccountsDelete ... -func (c DeviceupdatesClient) AccountsDelete(ctx context.Context, id AccountId) (result AccountsDeleteOperationResponse, err error) { - req, err := c.preparerForAccountsDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "AccountsDelete", nil, "Failure preparing request") - return - } - - result, err = c.senderForAccountsDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "AccountsDelete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// AccountsDeleteThenPoll performs AccountsDelete then polls until it's completed -func (c DeviceupdatesClient) AccountsDeleteThenPoll(ctx context.Context, id AccountId) error { - result, err := c.AccountsDelete(ctx, id) - if err != nil { - return fmt.Errorf("performing AccountsDelete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after AccountsDelete: %+v", err) - } - - return nil -} - -// preparerForAccountsDelete prepares the AccountsDelete request. -func (c DeviceupdatesClient) preparerForAccountsDelete(ctx context.Context, id AccountId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForAccountsDelete sends the AccountsDelete request. The method will close the -// http.Response Body if it receives an error. -func (c DeviceupdatesClient) senderForAccountsDelete(ctx context.Context, req *http.Request) (future AccountsDeleteOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_accountsget.go b/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_accountsget.go new file mode 100644 index 00000000000..7a9ca60b35e --- /dev/null +++ b/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_accountsget.go @@ -0,0 +1,51 @@ +package deviceupdates + +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 AccountsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Account +} + +// AccountsGet ... +func (c DeviceupdatesClient) AccountsGet(ctx context.Context, id AccountId) (result AccountsGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_accountsget_autorest.go b/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_accountsget_autorest.go deleted file mode 100644 index 49c91d940c5..00000000000 --- a/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_accountsget_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package deviceupdates - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type AccountsGetOperationResponse struct { - HttpResponse *http.Response - Model *Account -} - -// AccountsGet ... -func (c DeviceupdatesClient) AccountsGet(ctx context.Context, id AccountId) (result AccountsGetOperationResponse, err error) { - req, err := c.preparerForAccountsGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "AccountsGet", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "AccountsGet", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForAccountsGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "AccountsGet", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForAccountsGet prepares the AccountsGet request. -func (c DeviceupdatesClient) preparerForAccountsGet(ctx context.Context, id AccountId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForAccountsGet handles the response to the AccountsGet request. The method always -// closes the http.Response Body. -func (c DeviceupdatesClient) responderForAccountsGet(resp *http.Response) (result AccountsGetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_accountshead.go b/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_accountshead.go new file mode 100644 index 00000000000..60e33d54ad5 --- /dev/null +++ b/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_accountshead.go @@ -0,0 +1,46 @@ +package deviceupdates + +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 AccountsHeadOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// AccountsHead ... +func (c DeviceupdatesClient) AccountsHead(ctx context.Context, id AccountId) (result AccountsHeadOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + 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 + } + + return +} diff --git a/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_accountshead_autorest.go b/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_accountshead_autorest.go deleted file mode 100644 index f626397ac4e..00000000000 --- a/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_accountshead_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package deviceupdates - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type AccountsHeadOperationResponse struct { - HttpResponse *http.Response -} - -// AccountsHead ... -func (c DeviceupdatesClient) AccountsHead(ctx context.Context, id AccountId) (result AccountsHeadOperationResponse, err error) { - req, err := c.preparerForAccountsHead(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "AccountsHead", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "AccountsHead", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForAccountsHead(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "AccountsHead", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForAccountsHead prepares the AccountsHead request. -func (c DeviceupdatesClient) preparerForAccountsHead(ctx context.Context, id AccountId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForAccountsHead handles the response to the AccountsHead request. The method always -// closes the http.Response Body. -func (c DeviceupdatesClient) responderForAccountsHead(resp *http.Response) (result AccountsHeadOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_accountslistbyresourcegroup.go b/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_accountslistbyresourcegroup.go new file mode 100644 index 00000000000..fe00ccdcc56 --- /dev/null +++ b/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_accountslistbyresourcegroup.go @@ -0,0 +1,90 @@ +package deviceupdates + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 AccountsListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Account +} + +type AccountsListByResourceGroupCompleteResult struct { + Items []Account +} + +// AccountsListByResourceGroup ... +func (c DeviceupdatesClient) AccountsListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result AccountsListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.DeviceUpdate/accounts", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Account `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// AccountsListByResourceGroupComplete retrieves all the results into a single object +func (c DeviceupdatesClient) AccountsListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (AccountsListByResourceGroupCompleteResult, error) { + return c.AccountsListByResourceGroupCompleteMatchingPredicate(ctx, id, AccountOperationPredicate{}) +} + +// AccountsListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DeviceupdatesClient) AccountsListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate AccountOperationPredicate) (result AccountsListByResourceGroupCompleteResult, err error) { + items := make([]Account, 0) + + resp, err := c.AccountsListByResourceGroup(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = AccountsListByResourceGroupCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_accountslistbyresourcegroup_autorest.go b/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_accountslistbyresourcegroup_autorest.go deleted file mode 100644 index 38bb4a9dd4f..00000000000 --- a/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_accountslistbyresourcegroup_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package deviceupdates - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type AccountsListByResourceGroupOperationResponse struct { - HttpResponse *http.Response - Model *[]Account - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (AccountsListByResourceGroupOperationResponse, error) -} - -type AccountsListByResourceGroupCompleteResult struct { - Items []Account -} - -func (r AccountsListByResourceGroupOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r AccountsListByResourceGroupOperationResponse) LoadMore(ctx context.Context) (resp AccountsListByResourceGroupOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// AccountsListByResourceGroup ... -func (c DeviceupdatesClient) AccountsListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (resp AccountsListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForAccountsListByResourceGroup(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "AccountsListByResourceGroup", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "AccountsListByResourceGroup", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForAccountsListByResourceGroup(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "AccountsListByResourceGroup", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForAccountsListByResourceGroup prepares the AccountsListByResourceGroup request. -func (c DeviceupdatesClient) preparerForAccountsListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.DeviceUpdate/accounts", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForAccountsListByResourceGroupWithNextLink prepares the AccountsListByResourceGroup request with the given nextLink token. -func (c DeviceupdatesClient) preparerForAccountsListByResourceGroupWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForAccountsListByResourceGroup handles the response to the AccountsListByResourceGroup request. The method always -// closes the http.Response Body. -func (c DeviceupdatesClient) responderForAccountsListByResourceGroup(resp *http.Response) (result AccountsListByResourceGroupOperationResponse, err error) { - type page struct { - Values []Account `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result AccountsListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForAccountsListByResourceGroupWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "AccountsListByResourceGroup", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "AccountsListByResourceGroup", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForAccountsListByResourceGroup(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "AccountsListByResourceGroup", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// AccountsListByResourceGroupComplete retrieves all of the results into a single object -func (c DeviceupdatesClient) AccountsListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (AccountsListByResourceGroupCompleteResult, error) { - return c.AccountsListByResourceGroupCompleteMatchingPredicate(ctx, id, AccountOperationPredicate{}) -} - -// AccountsListByResourceGroupCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c DeviceupdatesClient) AccountsListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate AccountOperationPredicate) (resp AccountsListByResourceGroupCompleteResult, err error) { - items := make([]Account, 0) - - page, err := c.AccountsListByResourceGroup(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := AccountsListByResourceGroupCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_accountslistbysubscription.go b/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_accountslistbysubscription.go new file mode 100644 index 00000000000..35ae14b0782 --- /dev/null +++ b/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_accountslistbysubscription.go @@ -0,0 +1,90 @@ +package deviceupdates + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 AccountsListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Account +} + +type AccountsListBySubscriptionCompleteResult struct { + Items []Account +} + +// AccountsListBySubscription ... +func (c DeviceupdatesClient) AccountsListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result AccountsListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.DeviceUpdate/accounts", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Account `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// AccountsListBySubscriptionComplete retrieves all the results into a single object +func (c DeviceupdatesClient) AccountsListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (AccountsListBySubscriptionCompleteResult, error) { + return c.AccountsListBySubscriptionCompleteMatchingPredicate(ctx, id, AccountOperationPredicate{}) +} + +// AccountsListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DeviceupdatesClient) AccountsListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate AccountOperationPredicate) (result AccountsListBySubscriptionCompleteResult, err error) { + items := make([]Account, 0) + + resp, err := c.AccountsListBySubscription(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = AccountsListBySubscriptionCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_accountslistbysubscription_autorest.go b/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_accountslistbysubscription_autorest.go deleted file mode 100644 index 71982e43572..00000000000 --- a/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_accountslistbysubscription_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package deviceupdates - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type AccountsListBySubscriptionOperationResponse struct { - HttpResponse *http.Response - Model *[]Account - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (AccountsListBySubscriptionOperationResponse, error) -} - -type AccountsListBySubscriptionCompleteResult struct { - Items []Account -} - -func (r AccountsListBySubscriptionOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r AccountsListBySubscriptionOperationResponse) LoadMore(ctx context.Context) (resp AccountsListBySubscriptionOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// AccountsListBySubscription ... -func (c DeviceupdatesClient) AccountsListBySubscription(ctx context.Context, id commonids.SubscriptionId) (resp AccountsListBySubscriptionOperationResponse, err error) { - req, err := c.preparerForAccountsListBySubscription(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "AccountsListBySubscription", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "AccountsListBySubscription", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForAccountsListBySubscription(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "AccountsListBySubscription", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForAccountsListBySubscription prepares the AccountsListBySubscription request. -func (c DeviceupdatesClient) preparerForAccountsListBySubscription(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.DeviceUpdate/accounts", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForAccountsListBySubscriptionWithNextLink prepares the AccountsListBySubscription request with the given nextLink token. -func (c DeviceupdatesClient) preparerForAccountsListBySubscriptionWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForAccountsListBySubscription handles the response to the AccountsListBySubscription request. The method always -// closes the http.Response Body. -func (c DeviceupdatesClient) responderForAccountsListBySubscription(resp *http.Response) (result AccountsListBySubscriptionOperationResponse, err error) { - type page struct { - Values []Account `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result AccountsListBySubscriptionOperationResponse, err error) { - req, err := c.preparerForAccountsListBySubscriptionWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "AccountsListBySubscription", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "AccountsListBySubscription", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForAccountsListBySubscription(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "AccountsListBySubscription", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// AccountsListBySubscriptionComplete retrieves all of the results into a single object -func (c DeviceupdatesClient) AccountsListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (AccountsListBySubscriptionCompleteResult, error) { - return c.AccountsListBySubscriptionCompleteMatchingPredicate(ctx, id, AccountOperationPredicate{}) -} - -// AccountsListBySubscriptionCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c DeviceupdatesClient) AccountsListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate AccountOperationPredicate) (resp AccountsListBySubscriptionCompleteResult, err error) { - items := make([]Account, 0) - - page, err := c.AccountsListBySubscription(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := AccountsListBySubscriptionCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_accountsupdate.go b/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_accountsupdate.go new file mode 100644 index 00000000000..254dda12522 --- /dev/null +++ b/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_accountsupdate.go @@ -0,0 +1,74 @@ +package deviceupdates + +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 AccountsUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// AccountsUpdate ... +func (c DeviceupdatesClient) AccountsUpdate(ctx context.Context, id AccountId, input AccountUpdate) (result AccountsUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + 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 +} + +// AccountsUpdateThenPoll performs AccountsUpdate then polls until it's completed +func (c DeviceupdatesClient) AccountsUpdateThenPoll(ctx context.Context, id AccountId, input AccountUpdate) error { + result, err := c.AccountsUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing AccountsUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after AccountsUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_accountsupdate_autorest.go b/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_accountsupdate_autorest.go deleted file mode 100644 index 02782a52cd8..00000000000 --- a/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_accountsupdate_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package deviceupdates - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type AccountsUpdateOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// AccountsUpdate ... -func (c DeviceupdatesClient) AccountsUpdate(ctx context.Context, id AccountId, input AccountUpdate) (result AccountsUpdateOperationResponse, err error) { - req, err := c.preparerForAccountsUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "AccountsUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForAccountsUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "AccountsUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// AccountsUpdateThenPoll performs AccountsUpdate then polls until it's completed -func (c DeviceupdatesClient) AccountsUpdateThenPoll(ctx context.Context, id AccountId, input AccountUpdate) error { - result, err := c.AccountsUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing AccountsUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after AccountsUpdate: %+v", err) - } - - return nil -} - -// preparerForAccountsUpdate prepares the AccountsUpdate request. -func (c DeviceupdatesClient) preparerForAccountsUpdate(ctx context.Context, id AccountId, input AccountUpdate) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForAccountsUpdate sends the AccountsUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c DeviceupdatesClient) senderForAccountsUpdate(ctx context.Context, req *http.Request) (future AccountsUpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_checknameavailability.go b/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_checknameavailability.go new file mode 100644 index 00000000000..efc22f96ee3 --- /dev/null +++ b/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_checknameavailability.go @@ -0,0 +1,57 @@ +package deviceupdates + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 CheckNameAvailabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CheckNameAvailabilityResponse +} + +// CheckNameAvailability ... +func (c DeviceupdatesClient) CheckNameAvailability(ctx context.Context, id commonids.SubscriptionId, input CheckNameAvailabilityRequest) (result CheckNameAvailabilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.DeviceUpdate/checknameavailability", 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 +} diff --git a/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_checknameavailability_autorest.go b/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_checknameavailability_autorest.go deleted file mode 100644 index 9ae34262cf3..00000000000 --- a/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_checknameavailability_autorest.go +++ /dev/null @@ -1,71 +0,0 @@ -package deviceupdates - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CheckNameAvailabilityOperationResponse struct { - HttpResponse *http.Response - Model *CheckNameAvailabilityResponse -} - -// CheckNameAvailability ... -func (c DeviceupdatesClient) CheckNameAvailability(ctx context.Context, id commonids.SubscriptionId, input CheckNameAvailabilityRequest) (result CheckNameAvailabilityOperationResponse, err error) { - req, err := c.preparerForCheckNameAvailability(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "CheckNameAvailability", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "CheckNameAvailability", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCheckNameAvailability(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "CheckNameAvailability", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCheckNameAvailability prepares the CheckNameAvailability request. -func (c DeviceupdatesClient) preparerForCheckNameAvailability(ctx context.Context, id commonids.SubscriptionId, input CheckNameAvailabilityRequest) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.DeviceUpdate/checknameavailability", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCheckNameAvailability handles the response to the CheckNameAvailability request. The method always -// closes the http.Response Body. -func (c DeviceupdatesClient) responderForCheckNameAvailability(resp *http.Response) (result CheckNameAvailabilityOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_instancescreate.go b/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_instancescreate.go new file mode 100644 index 00000000000..7725a156955 --- /dev/null +++ b/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_instancescreate.go @@ -0,0 +1,73 @@ +package deviceupdates + +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 InstancesCreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// InstancesCreate ... +func (c DeviceupdatesClient) InstancesCreate(ctx context.Context, id InstanceId, input Instance) (result InstancesCreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + 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 +} + +// InstancesCreateThenPoll performs InstancesCreate then polls until it's completed +func (c DeviceupdatesClient) InstancesCreateThenPoll(ctx context.Context, id InstanceId, input Instance) error { + result, err := c.InstancesCreate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing InstancesCreate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after InstancesCreate: %+v", err) + } + + return nil +} diff --git a/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_instancescreate_autorest.go b/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_instancescreate_autorest.go deleted file mode 100644 index b426d6ed181..00000000000 --- a/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_instancescreate_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package deviceupdates - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type InstancesCreateOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// InstancesCreate ... -func (c DeviceupdatesClient) InstancesCreate(ctx context.Context, id InstanceId, input Instance) (result InstancesCreateOperationResponse, err error) { - req, err := c.preparerForInstancesCreate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "InstancesCreate", nil, "Failure preparing request") - return - } - - result, err = c.senderForInstancesCreate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "InstancesCreate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// InstancesCreateThenPoll performs InstancesCreate then polls until it's completed -func (c DeviceupdatesClient) InstancesCreateThenPoll(ctx context.Context, id InstanceId, input Instance) error { - result, err := c.InstancesCreate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing InstancesCreate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after InstancesCreate: %+v", err) - } - - return nil -} - -// preparerForInstancesCreate prepares the InstancesCreate request. -func (c DeviceupdatesClient) preparerForInstancesCreate(ctx context.Context, id InstanceId, input Instance) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForInstancesCreate sends the InstancesCreate request. The method will close the -// http.Response Body if it receives an error. -func (c DeviceupdatesClient) senderForInstancesCreate(ctx context.Context, req *http.Request) (future InstancesCreateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_instancesdelete.go b/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_instancesdelete.go new file mode 100644 index 00000000000..2ba678c4a4c --- /dev/null +++ b/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_instancesdelete.go @@ -0,0 +1,71 @@ +package deviceupdates + +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 InstancesDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// InstancesDelete ... +func (c DeviceupdatesClient) InstancesDelete(ctx context.Context, id InstanceId) (result InstancesDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 +} + +// InstancesDeleteThenPoll performs InstancesDelete then polls until it's completed +func (c DeviceupdatesClient) InstancesDeleteThenPoll(ctx context.Context, id InstanceId) error { + result, err := c.InstancesDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing InstancesDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after InstancesDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_instancesdelete_autorest.go b/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_instancesdelete_autorest.go deleted file mode 100644 index 7d645e87538..00000000000 --- a/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_instancesdelete_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package deviceupdates - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type InstancesDeleteOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// InstancesDelete ... -func (c DeviceupdatesClient) InstancesDelete(ctx context.Context, id InstanceId) (result InstancesDeleteOperationResponse, err error) { - req, err := c.preparerForInstancesDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "InstancesDelete", nil, "Failure preparing request") - return - } - - result, err = c.senderForInstancesDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "InstancesDelete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// InstancesDeleteThenPoll performs InstancesDelete then polls until it's completed -func (c DeviceupdatesClient) InstancesDeleteThenPoll(ctx context.Context, id InstanceId) error { - result, err := c.InstancesDelete(ctx, id) - if err != nil { - return fmt.Errorf("performing InstancesDelete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after InstancesDelete: %+v", err) - } - - return nil -} - -// preparerForInstancesDelete prepares the InstancesDelete request. -func (c DeviceupdatesClient) preparerForInstancesDelete(ctx context.Context, id InstanceId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForInstancesDelete sends the InstancesDelete request. The method will close the -// http.Response Body if it receives an error. -func (c DeviceupdatesClient) senderForInstancesDelete(ctx context.Context, req *http.Request) (future InstancesDeleteOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_instancesget.go b/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_instancesget.go new file mode 100644 index 00000000000..aca7a849c6f --- /dev/null +++ b/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_instancesget.go @@ -0,0 +1,51 @@ +package deviceupdates + +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 InstancesGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Instance +} + +// InstancesGet ... +func (c DeviceupdatesClient) InstancesGet(ctx context.Context, id InstanceId) (result InstancesGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_instancesget_autorest.go b/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_instancesget_autorest.go deleted file mode 100644 index 0847285a3c5..00000000000 --- a/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_instancesget_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package deviceupdates - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type InstancesGetOperationResponse struct { - HttpResponse *http.Response - Model *Instance -} - -// InstancesGet ... -func (c DeviceupdatesClient) InstancesGet(ctx context.Context, id InstanceId) (result InstancesGetOperationResponse, err error) { - req, err := c.preparerForInstancesGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "InstancesGet", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "InstancesGet", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForInstancesGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "InstancesGet", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForInstancesGet prepares the InstancesGet request. -func (c DeviceupdatesClient) preparerForInstancesGet(ctx context.Context, id InstanceId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForInstancesGet handles the response to the InstancesGet request. The method always -// closes the http.Response Body. -func (c DeviceupdatesClient) responderForInstancesGet(resp *http.Response) (result InstancesGetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_instanceshead.go b/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_instanceshead.go new file mode 100644 index 00000000000..46766df9329 --- /dev/null +++ b/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_instanceshead.go @@ -0,0 +1,46 @@ +package deviceupdates + +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 InstancesHeadOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// InstancesHead ... +func (c DeviceupdatesClient) InstancesHead(ctx context.Context, id InstanceId) (result InstancesHeadOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + 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 + } + + return +} diff --git a/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_instanceshead_autorest.go b/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_instanceshead_autorest.go deleted file mode 100644 index 9d201943799..00000000000 --- a/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_instanceshead_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package deviceupdates - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type InstancesHeadOperationResponse struct { - HttpResponse *http.Response -} - -// InstancesHead ... -func (c DeviceupdatesClient) InstancesHead(ctx context.Context, id InstanceId) (result InstancesHeadOperationResponse, err error) { - req, err := c.preparerForInstancesHead(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "InstancesHead", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "InstancesHead", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForInstancesHead(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "InstancesHead", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForInstancesHead prepares the InstancesHead request. -func (c DeviceupdatesClient) preparerForInstancesHead(ctx context.Context, id InstanceId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForInstancesHead handles the response to the InstancesHead request. The method always -// closes the http.Response Body. -func (c DeviceupdatesClient) responderForInstancesHead(resp *http.Response) (result InstancesHeadOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_instanceslistbyaccount.go b/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_instanceslistbyaccount.go new file mode 100644 index 00000000000..2728c8ac749 --- /dev/null +++ b/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_instanceslistbyaccount.go @@ -0,0 +1,89 @@ +package deviceupdates + +import ( + "context" + "fmt" + "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 InstancesListByAccountOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Instance +} + +type InstancesListByAccountCompleteResult struct { + Items []Instance +} + +// InstancesListByAccount ... +func (c DeviceupdatesClient) InstancesListByAccount(ctx context.Context, id AccountId) (result InstancesListByAccountOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/instances", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Instance `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// InstancesListByAccountComplete retrieves all the results into a single object +func (c DeviceupdatesClient) InstancesListByAccountComplete(ctx context.Context, id AccountId) (InstancesListByAccountCompleteResult, error) { + return c.InstancesListByAccountCompleteMatchingPredicate(ctx, id, InstanceOperationPredicate{}) +} + +// InstancesListByAccountCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DeviceupdatesClient) InstancesListByAccountCompleteMatchingPredicate(ctx context.Context, id AccountId, predicate InstanceOperationPredicate) (result InstancesListByAccountCompleteResult, err error) { + items := make([]Instance, 0) + + resp, err := c.InstancesListByAccount(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = InstancesListByAccountCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_instanceslistbyaccount_autorest.go b/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_instanceslistbyaccount_autorest.go deleted file mode 100644 index a5feff5dea3..00000000000 --- a/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_instanceslistbyaccount_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package deviceupdates - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type InstancesListByAccountOperationResponse struct { - HttpResponse *http.Response - Model *[]Instance - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (InstancesListByAccountOperationResponse, error) -} - -type InstancesListByAccountCompleteResult struct { - Items []Instance -} - -func (r InstancesListByAccountOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r InstancesListByAccountOperationResponse) LoadMore(ctx context.Context) (resp InstancesListByAccountOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// InstancesListByAccount ... -func (c DeviceupdatesClient) InstancesListByAccount(ctx context.Context, id AccountId) (resp InstancesListByAccountOperationResponse, err error) { - req, err := c.preparerForInstancesListByAccount(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "InstancesListByAccount", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "InstancesListByAccount", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForInstancesListByAccount(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "InstancesListByAccount", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForInstancesListByAccount prepares the InstancesListByAccount request. -func (c DeviceupdatesClient) preparerForInstancesListByAccount(ctx context.Context, id AccountId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/instances", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForInstancesListByAccountWithNextLink prepares the InstancesListByAccount request with the given nextLink token. -func (c DeviceupdatesClient) preparerForInstancesListByAccountWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForInstancesListByAccount handles the response to the InstancesListByAccount request. The method always -// closes the http.Response Body. -func (c DeviceupdatesClient) responderForInstancesListByAccount(resp *http.Response) (result InstancesListByAccountOperationResponse, err error) { - type page struct { - Values []Instance `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result InstancesListByAccountOperationResponse, err error) { - req, err := c.preparerForInstancesListByAccountWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "InstancesListByAccount", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "InstancesListByAccount", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForInstancesListByAccount(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "InstancesListByAccount", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// InstancesListByAccountComplete retrieves all of the results into a single object -func (c DeviceupdatesClient) InstancesListByAccountComplete(ctx context.Context, id AccountId) (InstancesListByAccountCompleteResult, error) { - return c.InstancesListByAccountCompleteMatchingPredicate(ctx, id, InstanceOperationPredicate{}) -} - -// InstancesListByAccountCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c DeviceupdatesClient) InstancesListByAccountCompleteMatchingPredicate(ctx context.Context, id AccountId, predicate InstanceOperationPredicate) (resp InstancesListByAccountCompleteResult, err error) { - items := make([]Instance, 0) - - page, err := c.InstancesListByAccount(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := InstancesListByAccountCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_instancesupdate.go b/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_instancesupdate.go new file mode 100644 index 00000000000..d3cc3569818 --- /dev/null +++ b/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_instancesupdate.go @@ -0,0 +1,55 @@ +package deviceupdates + +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 InstancesUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Instance +} + +// InstancesUpdate ... +func (c DeviceupdatesClient) InstancesUpdate(ctx context.Context, id InstanceId, input TagUpdate) (result InstancesUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + 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 +} diff --git a/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_instancesupdate_autorest.go b/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_instancesupdate_autorest.go deleted file mode 100644 index 33d41cc6d92..00000000000 --- a/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_instancesupdate_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package deviceupdates - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type InstancesUpdateOperationResponse struct { - HttpResponse *http.Response - Model *Instance -} - -// InstancesUpdate ... -func (c DeviceupdatesClient) InstancesUpdate(ctx context.Context, id InstanceId, input TagUpdate) (result InstancesUpdateOperationResponse, err error) { - req, err := c.preparerForInstancesUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "InstancesUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "InstancesUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForInstancesUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "InstancesUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForInstancesUpdate prepares the InstancesUpdate request. -func (c DeviceupdatesClient) preparerForInstancesUpdate(ctx context.Context, id InstanceId, input TagUpdate) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForInstancesUpdate handles the response to the InstancesUpdate request. The method always -// closes the http.Response Body. -func (c DeviceupdatesClient) responderForInstancesUpdate(resp *http.Response) (result InstancesUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_privateendpointconnectionproxiesupdateprivateendpointproperties.go b/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_privateendpointconnectionproxiesupdateprivateendpointproperties.go new file mode 100644 index 00000000000..22883bbdc5b --- /dev/null +++ b/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_privateendpointconnectionproxiesupdateprivateendpointproperties.go @@ -0,0 +1,51 @@ +package deviceupdates + +import ( + "context" + "fmt" + "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 PrivateEndpointConnectionProxiesUpdatePrivateEndpointPropertiesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// PrivateEndpointConnectionProxiesUpdatePrivateEndpointProperties ... +func (c DeviceupdatesClient) PrivateEndpointConnectionProxiesUpdatePrivateEndpointProperties(ctx context.Context, id PrivateEndpointConnectionProxyId, input PrivateEndpointUpdate) (result PrivateEndpointConnectionProxiesUpdatePrivateEndpointPropertiesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/updatePrivateEndpointProperties", 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 + } + + return +} diff --git a/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_privateendpointconnectionproxiesupdateprivateendpointproperties_autorest.go b/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_privateendpointconnectionproxiesupdateprivateendpointproperties_autorest.go deleted file mode 100644 index 761917d2be7..00000000000 --- a/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_privateendpointconnectionproxiesupdateprivateendpointproperties_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package deviceupdates - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PrivateEndpointConnectionProxiesUpdatePrivateEndpointPropertiesOperationResponse struct { - HttpResponse *http.Response -} - -// PrivateEndpointConnectionProxiesUpdatePrivateEndpointProperties ... -func (c DeviceupdatesClient) PrivateEndpointConnectionProxiesUpdatePrivateEndpointProperties(ctx context.Context, id PrivateEndpointConnectionProxyId, input PrivateEndpointUpdate) (result PrivateEndpointConnectionProxiesUpdatePrivateEndpointPropertiesOperationResponse, err error) { - req, err := c.preparerForPrivateEndpointConnectionProxiesUpdatePrivateEndpointProperties(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "PrivateEndpointConnectionProxiesUpdatePrivateEndpointProperties", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "PrivateEndpointConnectionProxiesUpdatePrivateEndpointProperties", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForPrivateEndpointConnectionProxiesUpdatePrivateEndpointProperties(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "PrivateEndpointConnectionProxiesUpdatePrivateEndpointProperties", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForPrivateEndpointConnectionProxiesUpdatePrivateEndpointProperties prepares the PrivateEndpointConnectionProxiesUpdatePrivateEndpointProperties request. -func (c DeviceupdatesClient) preparerForPrivateEndpointConnectionProxiesUpdatePrivateEndpointProperties(ctx context.Context, id PrivateEndpointConnectionProxyId, input PrivateEndpointUpdate) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/updatePrivateEndpointProperties", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForPrivateEndpointConnectionProxiesUpdatePrivateEndpointProperties handles the response to the PrivateEndpointConnectionProxiesUpdatePrivateEndpointProperties request. The method always -// closes the http.Response Body. -func (c DeviceupdatesClient) responderForPrivateEndpointConnectionProxiesUpdatePrivateEndpointProperties(resp *http.Response) (result PrivateEndpointConnectionProxiesUpdatePrivateEndpointPropertiesOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_privateendpointconnectionproxiesvalidate.go b/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_privateendpointconnectionproxiesvalidate.go new file mode 100644 index 00000000000..8f1157ee164 --- /dev/null +++ b/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_privateendpointconnectionproxiesvalidate.go @@ -0,0 +1,51 @@ +package deviceupdates + +import ( + "context" + "fmt" + "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 PrivateEndpointConnectionProxiesValidateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// PrivateEndpointConnectionProxiesValidate ... +func (c DeviceupdatesClient) PrivateEndpointConnectionProxiesValidate(ctx context.Context, id PrivateEndpointConnectionProxyId, input PrivateEndpointConnectionProxy) (result PrivateEndpointConnectionProxiesValidateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/validate", 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 + } + + return +} diff --git a/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_privateendpointconnectionproxiesvalidate_autorest.go b/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_privateendpointconnectionproxiesvalidate_autorest.go deleted file mode 100644 index 042f5b8df68..00000000000 --- a/resource-manager/deviceupdate/2022-10-01/deviceupdates/method_privateendpointconnectionproxiesvalidate_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package deviceupdates - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PrivateEndpointConnectionProxiesValidateOperationResponse struct { - HttpResponse *http.Response -} - -// PrivateEndpointConnectionProxiesValidate ... -func (c DeviceupdatesClient) PrivateEndpointConnectionProxiesValidate(ctx context.Context, id PrivateEndpointConnectionProxyId, input PrivateEndpointConnectionProxy) (result PrivateEndpointConnectionProxiesValidateOperationResponse, err error) { - req, err := c.preparerForPrivateEndpointConnectionProxiesValidate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "PrivateEndpointConnectionProxiesValidate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "PrivateEndpointConnectionProxiesValidate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForPrivateEndpointConnectionProxiesValidate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "PrivateEndpointConnectionProxiesValidate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForPrivateEndpointConnectionProxiesValidate prepares the PrivateEndpointConnectionProxiesValidate request. -func (c DeviceupdatesClient) preparerForPrivateEndpointConnectionProxiesValidate(ctx context.Context, id PrivateEndpointConnectionProxyId, input PrivateEndpointConnectionProxy) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/validate", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForPrivateEndpointConnectionProxiesValidate handles the response to the PrivateEndpointConnectionProxiesValidate request. The method always -// closes the http.Response Body. -func (c DeviceupdatesClient) responderForPrivateEndpointConnectionProxiesValidate(resp *http.Response) (result PrivateEndpointConnectionProxiesValidateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/deviceupdate/2022-10-01/privateendpointconnectionproxies/client.go b/resource-manager/deviceupdate/2022-10-01/privateendpointconnectionproxies/client.go index fdf29cf94c6..2c9fe576728 100644 --- a/resource-manager/deviceupdate/2022-10-01/privateendpointconnectionproxies/client.go +++ b/resource-manager/deviceupdate/2022-10-01/privateendpointconnectionproxies/client.go @@ -1,18 +1,26 @@ package privateendpointconnectionproxies -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 PrivateEndpointConnectionProxiesClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewPrivateEndpointConnectionProxiesClientWithBaseURI(endpoint string) PrivateEndpointConnectionProxiesClient { - return PrivateEndpointConnectionProxiesClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewPrivateEndpointConnectionProxiesClientWithBaseURI(api environments.Api) (*PrivateEndpointConnectionProxiesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "privateendpointconnectionproxies", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PrivateEndpointConnectionProxiesClient: %+v", err) } + + return &PrivateEndpointConnectionProxiesClient{ + Client: client, + }, nil } diff --git a/resource-manager/deviceupdate/2022-10-01/privateendpointconnectionproxies/constants.go b/resource-manager/deviceupdate/2022-10-01/privateendpointconnectionproxies/constants.go index 5f012dd63ac..f7f189eeb11 100644 --- a/resource-manager/deviceupdate/2022-10-01/privateendpointconnectionproxies/constants.go +++ b/resource-manager/deviceupdate/2022-10-01/privateendpointconnectionproxies/constants.go @@ -1,6 +1,10 @@ package privateendpointconnectionproxies -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. @@ -23,6 +27,19 @@ func PossibleValuesForPrivateEndpointConnectionProxyProvisioningState() []string } } +func (s *PrivateEndpointConnectionProxyProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointConnectionProxyProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePrivateEndpointConnectionProxyProvisioningState(input string) (*PrivateEndpointConnectionProxyProvisioningState, error) { vals := map[string]PrivateEndpointConnectionProxyProvisioningState{ "creating": PrivateEndpointConnectionProxyProvisioningStateCreating, @@ -55,6 +72,19 @@ func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { } } +func (s *PrivateEndpointServiceConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointServiceConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { vals := map[string]PrivateEndpointServiceConnectionStatus{ "approved": PrivateEndpointServiceConnectionStatusApproved, diff --git a/resource-manager/deviceupdate/2022-10-01/privateendpointconnectionproxies/method_createorupdate.go b/resource-manager/deviceupdate/2022-10-01/privateendpointconnectionproxies/method_createorupdate.go new file mode 100644 index 00000000000..1d5a0bf3aeb --- /dev/null +++ b/resource-manager/deviceupdate/2022-10-01/privateendpointconnectionproxies/method_createorupdate.go @@ -0,0 +1,73 @@ +package privateendpointconnectionproxies + +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 +} + +// CreateOrUpdate ... +func (c PrivateEndpointConnectionProxiesClient) CreateOrUpdate(ctx context.Context, id PrivateEndpointConnectionProxyId, input PrivateEndpointConnectionProxy) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + 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 PrivateEndpointConnectionProxiesClient) CreateOrUpdateThenPoll(ctx context.Context, id PrivateEndpointConnectionProxyId, input PrivateEndpointConnectionProxy) 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 +} diff --git a/resource-manager/deviceupdate/2022-10-01/privateendpointconnectionproxies/method_createorupdate_autorest.go b/resource-manager/deviceupdate/2022-10-01/privateendpointconnectionproxies/method_createorupdate_autorest.go deleted file mode 100644 index 68567545fb6..00000000000 --- a/resource-manager/deviceupdate/2022-10-01/privateendpointconnectionproxies/method_createorupdate_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package privateendpointconnectionproxies - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateOrUpdate ... -func (c PrivateEndpointConnectionProxiesClient) CreateOrUpdate(ctx context.Context, id PrivateEndpointConnectionProxyId, input PrivateEndpointConnectionProxy) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnectionproxies.PrivateEndpointConnectionProxiesClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnectionproxies.PrivateEndpointConnectionProxiesClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c PrivateEndpointConnectionProxiesClient) CreateOrUpdateThenPoll(ctx context.Context, id PrivateEndpointConnectionProxyId, input PrivateEndpointConnectionProxy) error { - result, err := c.CreateOrUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateOrUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateOrUpdate: %+v", err) - } - - return nil -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c PrivateEndpointConnectionProxiesClient) preparerForCreateOrUpdate(ctx context.Context, id PrivateEndpointConnectionProxyId, input PrivateEndpointConnectionProxy) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateOrUpdate sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c PrivateEndpointConnectionProxiesClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/deviceupdate/2022-10-01/privateendpointconnectionproxies/method_delete.go b/resource-manager/deviceupdate/2022-10-01/privateendpointconnectionproxies/method_delete.go new file mode 100644 index 00000000000..0d6c1c64207 --- /dev/null +++ b/resource-manager/deviceupdate/2022-10-01/privateendpointconnectionproxies/method_delete.go @@ -0,0 +1,71 @@ +package privateendpointconnectionproxies + +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 PrivateEndpointConnectionProxiesClient) Delete(ctx context.Context, id PrivateEndpointConnectionProxyId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 PrivateEndpointConnectionProxiesClient) DeleteThenPoll(ctx context.Context, id PrivateEndpointConnectionProxyId) 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 +} diff --git a/resource-manager/deviceupdate/2022-10-01/privateendpointconnectionproxies/method_delete_autorest.go b/resource-manager/deviceupdate/2022-10-01/privateendpointconnectionproxies/method_delete_autorest.go deleted file mode 100644 index d04511d3cd0..00000000000 --- a/resource-manager/deviceupdate/2022-10-01/privateendpointconnectionproxies/method_delete_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package privateendpointconnectionproxies - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// Delete ... -func (c PrivateEndpointConnectionProxiesClient) Delete(ctx context.Context, id PrivateEndpointConnectionProxyId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnectionproxies.PrivateEndpointConnectionProxiesClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnectionproxies.PrivateEndpointConnectionProxiesClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c PrivateEndpointConnectionProxiesClient) DeleteThenPoll(ctx context.Context, id PrivateEndpointConnectionProxyId) error { - result, err := c.Delete(ctx, id) - if err != nil { - return fmt.Errorf("performing Delete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Delete: %+v", err) - } - - return nil -} - -// preparerForDelete prepares the Delete request. -func (c PrivateEndpointConnectionProxiesClient) preparerForDelete(ctx context.Context, id PrivateEndpointConnectionProxyId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDelete sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (c PrivateEndpointConnectionProxiesClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/deviceupdate/2022-10-01/privateendpointconnectionproxies/method_listbyaccount.go b/resource-manager/deviceupdate/2022-10-01/privateendpointconnectionproxies/method_listbyaccount.go new file mode 100644 index 00000000000..d96815302a8 --- /dev/null +++ b/resource-manager/deviceupdate/2022-10-01/privateendpointconnectionproxies/method_listbyaccount.go @@ -0,0 +1,52 @@ +package privateendpointconnectionproxies + +import ( + "context" + "fmt" + "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 ListByAccountOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateEndpointConnectionProxyListResult +} + +// ListByAccount ... +func (c PrivateEndpointConnectionProxiesClient) ListByAccount(ctx context.Context, id AccountId) (result ListByAccountOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateEndpointConnectionProxies", 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 +} diff --git a/resource-manager/deviceupdate/2022-10-01/privateendpointconnectionproxies/method_listbyaccount_autorest.go b/resource-manager/deviceupdate/2022-10-01/privateendpointconnectionproxies/method_listbyaccount_autorest.go deleted file mode 100644 index ba230a126fb..00000000000 --- a/resource-manager/deviceupdate/2022-10-01/privateendpointconnectionproxies/method_listbyaccount_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package privateendpointconnectionproxies - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByAccountOperationResponse struct { - HttpResponse *http.Response - Model *PrivateEndpointConnectionProxyListResult -} - -// ListByAccount ... -func (c PrivateEndpointConnectionProxiesClient) ListByAccount(ctx context.Context, id AccountId) (result ListByAccountOperationResponse, err error) { - req, err := c.preparerForListByAccount(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnectionproxies.PrivateEndpointConnectionProxiesClient", "ListByAccount", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnectionproxies.PrivateEndpointConnectionProxiesClient", "ListByAccount", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByAccount(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnectionproxies.PrivateEndpointConnectionProxiesClient", "ListByAccount", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListByAccount prepares the ListByAccount request. -func (c PrivateEndpointConnectionProxiesClient) preparerForListByAccount(ctx context.Context, id AccountId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/privateEndpointConnectionProxies", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByAccount handles the response to the ListByAccount request. The method always -// closes the http.Response Body. -func (c PrivateEndpointConnectionProxiesClient) responderForListByAccount(resp *http.Response) (result ListByAccountOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/deviceupdate/2022-10-01/privateendpointconnections/client.go b/resource-manager/deviceupdate/2022-10-01/privateendpointconnections/client.go index 1de584406fe..05a6653dc59 100644 --- a/resource-manager/deviceupdate/2022-10-01/privateendpointconnections/client.go +++ b/resource-manager/deviceupdate/2022-10-01/privateendpointconnections/client.go @@ -1,18 +1,26 @@ package privateendpointconnections -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 PrivateEndpointConnectionsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewPrivateEndpointConnectionsClientWithBaseURI(endpoint string) PrivateEndpointConnectionsClient { - return PrivateEndpointConnectionsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewPrivateEndpointConnectionsClientWithBaseURI(api environments.Api) (*PrivateEndpointConnectionsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "privateendpointconnections", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PrivateEndpointConnectionsClient: %+v", err) } + + return &PrivateEndpointConnectionsClient{ + Client: client, + }, nil } diff --git a/resource-manager/deviceupdate/2022-10-01/privateendpointconnections/constants.go b/resource-manager/deviceupdate/2022-10-01/privateendpointconnections/constants.go index 9da3f799bea..f860cc47f58 100644 --- a/resource-manager/deviceupdate/2022-10-01/privateendpointconnections/constants.go +++ b/resource-manager/deviceupdate/2022-10-01/privateendpointconnections/constants.go @@ -1,6 +1,10 @@ package privateendpointconnections -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. @@ -23,6 +27,19 @@ func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { } } +func (s *PrivateEndpointConnectionProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointConnectionProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { vals := map[string]PrivateEndpointConnectionProvisioningState{ "creating": PrivateEndpointConnectionProvisioningStateCreating, @@ -57,6 +74,19 @@ func PossibleValuesForPrivateEndpointConnectionProxyProvisioningState() []string } } +func (s *PrivateEndpointConnectionProxyProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointConnectionProxyProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePrivateEndpointConnectionProxyProvisioningState(input string) (*PrivateEndpointConnectionProxyProvisioningState, error) { vals := map[string]PrivateEndpointConnectionProxyProvisioningState{ "creating": PrivateEndpointConnectionProxyProvisioningStateCreating, @@ -89,6 +119,19 @@ func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { } } +func (s *PrivateEndpointServiceConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointServiceConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { vals := map[string]PrivateEndpointServiceConnectionStatus{ "approved": PrivateEndpointServiceConnectionStatusApproved, diff --git a/resource-manager/deviceupdate/2022-10-01/privateendpointconnections/method_createorupdate.go b/resource-manager/deviceupdate/2022-10-01/privateendpointconnections/method_createorupdate.go new file mode 100644 index 00000000000..0cdbbdceac5 --- /dev/null +++ b/resource-manager/deviceupdate/2022-10-01/privateendpointconnections/method_createorupdate.go @@ -0,0 +1,73 @@ +package privateendpointconnections + +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 +} + +// CreateOrUpdate ... +func (c PrivateEndpointConnectionsClient) CreateOrUpdate(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + 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 PrivateEndpointConnectionsClient) CreateOrUpdateThenPoll(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) 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 +} diff --git a/resource-manager/deviceupdate/2022-10-01/privateendpointconnections/method_createorupdate_autorest.go b/resource-manager/deviceupdate/2022-10-01/privateendpointconnections/method_createorupdate_autorest.go deleted file mode 100644 index 08aac1fbfa7..00000000000 --- a/resource-manager/deviceupdate/2022-10-01/privateendpointconnections/method_createorupdate_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package privateendpointconnections - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateOrUpdate ... -func (c PrivateEndpointConnectionsClient) CreateOrUpdate(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c PrivateEndpointConnectionsClient) CreateOrUpdateThenPoll(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) error { - result, err := c.CreateOrUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateOrUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateOrUpdate: %+v", err) - } - - return nil -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c PrivateEndpointConnectionsClient) preparerForCreateOrUpdate(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateOrUpdate sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c PrivateEndpointConnectionsClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/deviceupdate/2022-10-01/privateendpointconnections/method_delete.go b/resource-manager/deviceupdate/2022-10-01/privateendpointconnections/method_delete.go new file mode 100644 index 00000000000..4ae0907ed97 --- /dev/null +++ b/resource-manager/deviceupdate/2022-10-01/privateendpointconnections/method_delete.go @@ -0,0 +1,71 @@ +package privateendpointconnections + +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 PrivateEndpointConnectionsClient) Delete(ctx context.Context, id PrivateEndpointConnectionId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 PrivateEndpointConnectionsClient) DeleteThenPoll(ctx context.Context, id PrivateEndpointConnectionId) 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 +} diff --git a/resource-manager/deviceupdate/2022-10-01/privateendpointconnections/method_delete_autorest.go b/resource-manager/deviceupdate/2022-10-01/privateendpointconnections/method_delete_autorest.go deleted file mode 100644 index ef4fd3d8e66..00000000000 --- a/resource-manager/deviceupdate/2022-10-01/privateendpointconnections/method_delete_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package privateendpointconnections - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// Delete ... -func (c PrivateEndpointConnectionsClient) Delete(ctx context.Context, id PrivateEndpointConnectionId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c PrivateEndpointConnectionsClient) DeleteThenPoll(ctx context.Context, id PrivateEndpointConnectionId) error { - result, err := c.Delete(ctx, id) - if err != nil { - return fmt.Errorf("performing Delete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Delete: %+v", err) - } - - return nil -} - -// preparerForDelete prepares the Delete request. -func (c PrivateEndpointConnectionsClient) preparerForDelete(ctx context.Context, id PrivateEndpointConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDelete sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (c PrivateEndpointConnectionsClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/deviceupdate/2022-10-01/privateendpointconnections/method_get.go b/resource-manager/deviceupdate/2022-10-01/privateendpointconnections/method_get.go new file mode 100644 index 00000000000..713c7e2c836 --- /dev/null +++ b/resource-manager/deviceupdate/2022-10-01/privateendpointconnections/method_get.go @@ -0,0 +1,51 @@ +package privateendpointconnections + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateEndpointConnection +} + +// Get ... +func (c PrivateEndpointConnectionsClient) Get(ctx context.Context, id PrivateEndpointConnectionId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/deviceupdate/2022-10-01/privateendpointconnections/method_get_autorest.go b/resource-manager/deviceupdate/2022-10-01/privateendpointconnections/method_get_autorest.go deleted file mode 100644 index 44bbdcb8f0b..00000000000 --- a/resource-manager/deviceupdate/2022-10-01/privateendpointconnections/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package privateendpointconnections - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *PrivateEndpointConnection -} - -// Get ... -func (c PrivateEndpointConnectionsClient) Get(ctx context.Context, id PrivateEndpointConnectionId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c PrivateEndpointConnectionsClient) preparerForGet(ctx context.Context, id PrivateEndpointConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c PrivateEndpointConnectionsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/deviceupdate/2022-10-01/privateendpointconnections/method_listbyaccount.go b/resource-manager/deviceupdate/2022-10-01/privateendpointconnections/method_listbyaccount.go new file mode 100644 index 00000000000..cbf56e6d246 --- /dev/null +++ b/resource-manager/deviceupdate/2022-10-01/privateendpointconnections/method_listbyaccount.go @@ -0,0 +1,52 @@ +package privateendpointconnections + +import ( + "context" + "fmt" + "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 ListByAccountOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateEndpointConnectionListResult +} + +// ListByAccount ... +func (c PrivateEndpointConnectionsClient) ListByAccount(ctx context.Context, id AccountId) (result ListByAccountOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateEndpointConnections", 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 +} diff --git a/resource-manager/deviceupdate/2022-10-01/privateendpointconnections/method_listbyaccount_autorest.go b/resource-manager/deviceupdate/2022-10-01/privateendpointconnections/method_listbyaccount_autorest.go deleted file mode 100644 index c5fb27a461f..00000000000 --- a/resource-manager/deviceupdate/2022-10-01/privateendpointconnections/method_listbyaccount_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package privateendpointconnections - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByAccountOperationResponse struct { - HttpResponse *http.Response - Model *PrivateEndpointConnectionListResult -} - -// ListByAccount ... -func (c PrivateEndpointConnectionsClient) ListByAccount(ctx context.Context, id AccountId) (result ListByAccountOperationResponse, err error) { - req, err := c.preparerForListByAccount(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "ListByAccount", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "ListByAccount", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByAccount(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "ListByAccount", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListByAccount prepares the ListByAccount request. -func (c PrivateEndpointConnectionsClient) preparerForListByAccount(ctx context.Context, id AccountId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/privateEndpointConnections", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByAccount handles the response to the ListByAccount request. The method always -// closes the http.Response Body. -func (c PrivateEndpointConnectionsClient) responderForListByAccount(resp *http.Response) (result ListByAccountOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/deviceupdate/2022-10-01/privateendpointconnections/method_privateendpointconnectionproxiesget.go b/resource-manager/deviceupdate/2022-10-01/privateendpointconnections/method_privateendpointconnectionproxiesget.go new file mode 100644 index 00000000000..0a87b86d0ca --- /dev/null +++ b/resource-manager/deviceupdate/2022-10-01/privateendpointconnections/method_privateendpointconnectionproxiesget.go @@ -0,0 +1,51 @@ +package privateendpointconnections + +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 PrivateEndpointConnectionProxiesGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateEndpointConnectionProxy +} + +// PrivateEndpointConnectionProxiesGet ... +func (c PrivateEndpointConnectionsClient) PrivateEndpointConnectionProxiesGet(ctx context.Context, id PrivateEndpointConnectionProxyId) (result PrivateEndpointConnectionProxiesGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/deviceupdate/2022-10-01/privateendpointconnections/method_privateendpointconnectionproxiesget_autorest.go b/resource-manager/deviceupdate/2022-10-01/privateendpointconnections/method_privateendpointconnectionproxiesget_autorest.go deleted file mode 100644 index 709f2b988bb..00000000000 --- a/resource-manager/deviceupdate/2022-10-01/privateendpointconnections/method_privateendpointconnectionproxiesget_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package privateendpointconnections - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PrivateEndpointConnectionProxiesGetOperationResponse struct { - HttpResponse *http.Response - Model *PrivateEndpointConnectionProxy -} - -// PrivateEndpointConnectionProxiesGet ... -func (c PrivateEndpointConnectionsClient) PrivateEndpointConnectionProxiesGet(ctx context.Context, id PrivateEndpointConnectionProxyId) (result PrivateEndpointConnectionProxiesGetOperationResponse, err error) { - req, err := c.preparerForPrivateEndpointConnectionProxiesGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "PrivateEndpointConnectionProxiesGet", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "PrivateEndpointConnectionProxiesGet", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForPrivateEndpointConnectionProxiesGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "PrivateEndpointConnectionProxiesGet", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForPrivateEndpointConnectionProxiesGet prepares the PrivateEndpointConnectionProxiesGet request. -func (c PrivateEndpointConnectionsClient) preparerForPrivateEndpointConnectionProxiesGet(ctx context.Context, id PrivateEndpointConnectionProxyId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForPrivateEndpointConnectionProxiesGet handles the response to the PrivateEndpointConnectionProxiesGet request. The method always -// closes the http.Response Body. -func (c PrivateEndpointConnectionsClient) responderForPrivateEndpointConnectionProxiesGet(resp *http.Response) (result PrivateEndpointConnectionProxiesGetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/deviceupdate/2022-10-01/privatelinkresources/client.go b/resource-manager/deviceupdate/2022-10-01/privatelinkresources/client.go index 5f532940700..d331270c8f6 100644 --- a/resource-manager/deviceupdate/2022-10-01/privatelinkresources/client.go +++ b/resource-manager/deviceupdate/2022-10-01/privatelinkresources/client.go @@ -1,18 +1,26 @@ package privatelinkresources -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 PrivateLinkResourcesClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewPrivateLinkResourcesClientWithBaseURI(endpoint string) PrivateLinkResourcesClient { - return PrivateLinkResourcesClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewPrivateLinkResourcesClientWithBaseURI(api environments.Api) (*PrivateLinkResourcesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "privatelinkresources", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PrivateLinkResourcesClient: %+v", err) } + + return &PrivateLinkResourcesClient{ + Client: client, + }, nil } diff --git a/resource-manager/deviceupdate/2022-10-01/privatelinkresources/constants.go b/resource-manager/deviceupdate/2022-10-01/privatelinkresources/constants.go index 1b2a9353f36..79fe9f854e5 100644 --- a/resource-manager/deviceupdate/2022-10-01/privatelinkresources/constants.go +++ b/resource-manager/deviceupdate/2022-10-01/privatelinkresources/constants.go @@ -1,6 +1,10 @@ package privatelinkresources -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. @@ -21,6 +25,19 @@ func PossibleValuesForGroupIdProvisioningState() []string { } } +func (s *GroupIdProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGroupIdProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseGroupIdProvisioningState(input string) (*GroupIdProvisioningState, error) { vals := map[string]GroupIdProvisioningState{ "canceled": GroupIdProvisioningStateCanceled, diff --git a/resource-manager/deviceupdate/2022-10-01/privatelinkresources/method_get.go b/resource-manager/deviceupdate/2022-10-01/privatelinkresources/method_get.go new file mode 100644 index 00000000000..90b0434f7e4 --- /dev/null +++ b/resource-manager/deviceupdate/2022-10-01/privatelinkresources/method_get.go @@ -0,0 +1,51 @@ +package privatelinkresources + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *GroupInformation +} + +// Get ... +func (c PrivateLinkResourcesClient) Get(ctx context.Context, id PrivateLinkResourceId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/deviceupdate/2022-10-01/privatelinkresources/method_get_autorest.go b/resource-manager/deviceupdate/2022-10-01/privatelinkresources/method_get_autorest.go deleted file mode 100644 index accf0bbd7b0..00000000000 --- a/resource-manager/deviceupdate/2022-10-01/privatelinkresources/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package privatelinkresources - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *GroupInformation -} - -// Get ... -func (c PrivateLinkResourcesClient) Get(ctx context.Context, id PrivateLinkResourceId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresources.PrivateLinkResourcesClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresources.PrivateLinkResourcesClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresources.PrivateLinkResourcesClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c PrivateLinkResourcesClient) preparerForGet(ctx context.Context, id PrivateLinkResourceId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c PrivateLinkResourcesClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/deviceupdate/2022-10-01/privatelinkresources/method_listbyaccount.go b/resource-manager/deviceupdate/2022-10-01/privatelinkresources/method_listbyaccount.go new file mode 100644 index 00000000000..69e380c7442 --- /dev/null +++ b/resource-manager/deviceupdate/2022-10-01/privatelinkresources/method_listbyaccount.go @@ -0,0 +1,52 @@ +package privatelinkresources + +import ( + "context" + "fmt" + "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 ListByAccountOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateLinkResourceListResult +} + +// ListByAccount ... +func (c PrivateLinkResourcesClient) ListByAccount(ctx context.Context, id AccountId) (result ListByAccountOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateLinkResources", 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 +} diff --git a/resource-manager/deviceupdate/2022-10-01/privatelinkresources/method_listbyaccount_autorest.go b/resource-manager/deviceupdate/2022-10-01/privatelinkresources/method_listbyaccount_autorest.go deleted file mode 100644 index 6ffee9d5077..00000000000 --- a/resource-manager/deviceupdate/2022-10-01/privatelinkresources/method_listbyaccount_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package privatelinkresources - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByAccountOperationResponse struct { - HttpResponse *http.Response - Model *PrivateLinkResourceListResult -} - -// ListByAccount ... -func (c PrivateLinkResourcesClient) ListByAccount(ctx context.Context, id AccountId) (result ListByAccountOperationResponse, err error) { - req, err := c.preparerForListByAccount(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresources.PrivateLinkResourcesClient", "ListByAccount", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresources.PrivateLinkResourcesClient", "ListByAccount", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByAccount(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresources.PrivateLinkResourcesClient", "ListByAccount", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListByAccount prepares the ListByAccount request. -func (c PrivateLinkResourcesClient) preparerForListByAccount(ctx context.Context, id AccountId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/privateLinkResources", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByAccount handles the response to the ListByAccount request. The method always -// closes the http.Response Body. -func (c PrivateLinkResourcesClient) responderForListByAccount(resp *http.Response) (result ListByAccountOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/deviceupdate/2023-07-01/client.go b/resource-manager/deviceupdate/2023-07-01/client.go index 0b8d0da3c1a..1463c1732db 100644 --- a/resource-manager/deviceupdate/2023-07-01/client.go +++ b/resource-manager/deviceupdate/2023-07-01/client.go @@ -4,11 +4,14 @@ package v2023_07_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/deviceupdate/2023-07-01/deviceupdates" "github.com/hashicorp/go-azure-sdk/resource-manager/deviceupdate/2023-07-01/privateendpointconnectionproxies" "github.com/hashicorp/go-azure-sdk/resource-manager/deviceupdate/2023-07-01/privateendpointconnections" "github.com/hashicorp/go-azure-sdk/resource-manager/deviceupdate/2023-07-01/privatelinkresources" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/environments" ) type Client struct { @@ -18,24 +21,35 @@ type Client struct { PrivateLinkResources *privatelinkresources.PrivateLinkResourcesClient } -func NewClientWithBaseURI(endpoint string, configureAuthFunc func(c *autorest.Client)) Client { - - deviceupdatesClient := deviceupdates.NewDeviceupdatesClientWithBaseURI(endpoint) - configureAuthFunc(&deviceupdatesClient.Client) - - privateEndpointConnectionProxiesClient := privateendpointconnectionproxies.NewPrivateEndpointConnectionProxiesClientWithBaseURI(endpoint) - configureAuthFunc(&privateEndpointConnectionProxiesClient.Client) +func NewClientWithBaseURI(api environments.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + deviceupdatesClient, err := deviceupdates.NewDeviceupdatesClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Deviceupdates client: %+v", err) + } + configureFunc(deviceupdatesClient.Client) - privateEndpointConnectionsClient := privateendpointconnections.NewPrivateEndpointConnectionsClientWithBaseURI(endpoint) - configureAuthFunc(&privateEndpointConnectionsClient.Client) + privateEndpointConnectionProxiesClient, err := privateendpointconnectionproxies.NewPrivateEndpointConnectionProxiesClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building PrivateEndpointConnectionProxies client: %+v", err) + } + configureFunc(privateEndpointConnectionProxiesClient.Client) - privateLinkResourcesClient := privatelinkresources.NewPrivateLinkResourcesClientWithBaseURI(endpoint) - configureAuthFunc(&privateLinkResourcesClient.Client) + privateEndpointConnectionsClient, err := privateendpointconnections.NewPrivateEndpointConnectionsClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building PrivateEndpointConnections client: %+v", err) + } + configureFunc(privateEndpointConnectionsClient.Client) - return Client{ - Deviceupdates: &deviceupdatesClient, - PrivateEndpointConnectionProxies: &privateEndpointConnectionProxiesClient, - PrivateEndpointConnections: &privateEndpointConnectionsClient, - PrivateLinkResources: &privateLinkResourcesClient, + privateLinkResourcesClient, err := privatelinkresources.NewPrivateLinkResourcesClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building PrivateLinkResources client: %+v", err) } + configureFunc(privateLinkResourcesClient.Client) + + return &Client{ + Deviceupdates: deviceupdatesClient, + PrivateEndpointConnectionProxies: privateEndpointConnectionProxiesClient, + PrivateEndpointConnections: privateEndpointConnectionsClient, + PrivateLinkResources: privateLinkResourcesClient, + }, nil } diff --git a/resource-manager/deviceupdate/2023-07-01/deviceupdates/client.go b/resource-manager/deviceupdate/2023-07-01/deviceupdates/client.go index affade9d5b4..1823789119d 100644 --- a/resource-manager/deviceupdate/2023-07-01/deviceupdates/client.go +++ b/resource-manager/deviceupdate/2023-07-01/deviceupdates/client.go @@ -1,18 +1,26 @@ package deviceupdates -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 DeviceupdatesClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewDeviceupdatesClientWithBaseURI(endpoint string) DeviceupdatesClient { - return DeviceupdatesClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewDeviceupdatesClientWithBaseURI(api environments.Api) (*DeviceupdatesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "deviceupdates", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DeviceupdatesClient: %+v", err) } + + return &DeviceupdatesClient{ + Client: client, + }, nil } diff --git a/resource-manager/deviceupdate/2023-07-01/deviceupdates/constants.go b/resource-manager/deviceupdate/2023-07-01/deviceupdates/constants.go index fdc9b86bb24..a7fa4ca7c76 100644 --- a/resource-manager/deviceupdate/2023-07-01/deviceupdates/constants.go +++ b/resource-manager/deviceupdate/2023-07-01/deviceupdates/constants.go @@ -1,6 +1,10 @@ package deviceupdates -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. @@ -17,6 +21,19 @@ func PossibleValuesForAuthenticationType() []string { } } +func (s *AuthenticationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAuthenticationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAuthenticationType(input string) (*AuthenticationType, error) { vals := map[string]AuthenticationType{ "keybased": AuthenticationTypeKeyBased, @@ -44,6 +61,19 @@ func PossibleValuesForCheckNameAvailabilityReason() []string { } } +func (s *CheckNameAvailabilityReason) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCheckNameAvailabilityReason(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseCheckNameAvailabilityReason(input string) (*CheckNameAvailabilityReason, error) { vals := map[string]CheckNameAvailabilityReason{ "alreadyexists": CheckNameAvailabilityReasonAlreadyExists, @@ -76,6 +106,19 @@ func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { } } +func (s *PrivateEndpointConnectionProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointConnectionProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { vals := map[string]PrivateEndpointConnectionProvisioningState{ "creating": PrivateEndpointConnectionProvisioningStateCreating, @@ -110,6 +153,19 @@ func PossibleValuesForPrivateEndpointConnectionProxyProvisioningState() []string } } +func (s *PrivateEndpointConnectionProxyProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointConnectionProxyProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePrivateEndpointConnectionProxyProvisioningState(input string) (*PrivateEndpointConnectionProxyProvisioningState, error) { vals := map[string]PrivateEndpointConnectionProxyProvisioningState{ "creating": PrivateEndpointConnectionProxyProvisioningStateCreating, @@ -142,6 +198,19 @@ func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { } } +func (s *PrivateEndpointServiceConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointServiceConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { vals := map[string]PrivateEndpointServiceConnectionStatus{ "approved": PrivateEndpointServiceConnectionStatusApproved, @@ -179,6 +248,19 @@ func PossibleValuesForProvisioningState() []string { } } +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseProvisioningState(input string) (*ProvisioningState, error) { vals := map[string]ProvisioningState{ "accepted": ProvisioningStateAccepted, @@ -211,6 +293,19 @@ func PossibleValuesForPublicNetworkAccess() []string { } } +func (s *PublicNetworkAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicNetworkAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePublicNetworkAccess(input string) (*PublicNetworkAccess, error) { vals := map[string]PublicNetworkAccess{ "disabled": PublicNetworkAccessDisabled, @@ -239,6 +334,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{ "failover": RoleFailover, @@ -267,6 +375,19 @@ func PossibleValuesForSKU() []string { } } +func (s *SKU) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSKU(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseSKU(input string) (*SKU, error) { vals := map[string]SKU{ "free": SKUFree, diff --git a/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_accountscreate.go b/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_accountscreate.go new file mode 100644 index 00000000000..1e920e78d74 --- /dev/null +++ b/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_accountscreate.go @@ -0,0 +1,73 @@ +package deviceupdates + +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 AccountsCreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// AccountsCreate ... +func (c DeviceupdatesClient) AccountsCreate(ctx context.Context, id AccountId, input Account) (result AccountsCreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + 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 +} + +// AccountsCreateThenPoll performs AccountsCreate then polls until it's completed +func (c DeviceupdatesClient) AccountsCreateThenPoll(ctx context.Context, id AccountId, input Account) error { + result, err := c.AccountsCreate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing AccountsCreate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after AccountsCreate: %+v", err) + } + + return nil +} diff --git a/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_accountscreate_autorest.go b/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_accountscreate_autorest.go deleted file mode 100644 index 100da51a1da..00000000000 --- a/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_accountscreate_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package deviceupdates - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type AccountsCreateOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// AccountsCreate ... -func (c DeviceupdatesClient) AccountsCreate(ctx context.Context, id AccountId, input Account) (result AccountsCreateOperationResponse, err error) { - req, err := c.preparerForAccountsCreate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "AccountsCreate", nil, "Failure preparing request") - return - } - - result, err = c.senderForAccountsCreate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "AccountsCreate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// AccountsCreateThenPoll performs AccountsCreate then polls until it's completed -func (c DeviceupdatesClient) AccountsCreateThenPoll(ctx context.Context, id AccountId, input Account) error { - result, err := c.AccountsCreate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing AccountsCreate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after AccountsCreate: %+v", err) - } - - return nil -} - -// preparerForAccountsCreate prepares the AccountsCreate request. -func (c DeviceupdatesClient) preparerForAccountsCreate(ctx context.Context, id AccountId, input Account) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForAccountsCreate sends the AccountsCreate request. The method will close the -// http.Response Body if it receives an error. -func (c DeviceupdatesClient) senderForAccountsCreate(ctx context.Context, req *http.Request) (future AccountsCreateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_accountsdelete.go b/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_accountsdelete.go new file mode 100644 index 00000000000..92d0922688a --- /dev/null +++ b/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_accountsdelete.go @@ -0,0 +1,71 @@ +package deviceupdates + +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 AccountsDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// AccountsDelete ... +func (c DeviceupdatesClient) AccountsDelete(ctx context.Context, id AccountId) (result AccountsDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 +} + +// AccountsDeleteThenPoll performs AccountsDelete then polls until it's completed +func (c DeviceupdatesClient) AccountsDeleteThenPoll(ctx context.Context, id AccountId) error { + result, err := c.AccountsDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing AccountsDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after AccountsDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_accountsdelete_autorest.go b/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_accountsdelete_autorest.go deleted file mode 100644 index 59bcdb557b0..00000000000 --- a/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_accountsdelete_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package deviceupdates - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type AccountsDeleteOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// AccountsDelete ... -func (c DeviceupdatesClient) AccountsDelete(ctx context.Context, id AccountId) (result AccountsDeleteOperationResponse, err error) { - req, err := c.preparerForAccountsDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "AccountsDelete", nil, "Failure preparing request") - return - } - - result, err = c.senderForAccountsDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "AccountsDelete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// AccountsDeleteThenPoll performs AccountsDelete then polls until it's completed -func (c DeviceupdatesClient) AccountsDeleteThenPoll(ctx context.Context, id AccountId) error { - result, err := c.AccountsDelete(ctx, id) - if err != nil { - return fmt.Errorf("performing AccountsDelete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after AccountsDelete: %+v", err) - } - - return nil -} - -// preparerForAccountsDelete prepares the AccountsDelete request. -func (c DeviceupdatesClient) preparerForAccountsDelete(ctx context.Context, id AccountId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForAccountsDelete sends the AccountsDelete request. The method will close the -// http.Response Body if it receives an error. -func (c DeviceupdatesClient) senderForAccountsDelete(ctx context.Context, req *http.Request) (future AccountsDeleteOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_accountsget.go b/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_accountsget.go new file mode 100644 index 00000000000..7a9ca60b35e --- /dev/null +++ b/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_accountsget.go @@ -0,0 +1,51 @@ +package deviceupdates + +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 AccountsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Account +} + +// AccountsGet ... +func (c DeviceupdatesClient) AccountsGet(ctx context.Context, id AccountId) (result AccountsGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_accountsget_autorest.go b/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_accountsget_autorest.go deleted file mode 100644 index 49c91d940c5..00000000000 --- a/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_accountsget_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package deviceupdates - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type AccountsGetOperationResponse struct { - HttpResponse *http.Response - Model *Account -} - -// AccountsGet ... -func (c DeviceupdatesClient) AccountsGet(ctx context.Context, id AccountId) (result AccountsGetOperationResponse, err error) { - req, err := c.preparerForAccountsGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "AccountsGet", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "AccountsGet", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForAccountsGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "AccountsGet", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForAccountsGet prepares the AccountsGet request. -func (c DeviceupdatesClient) preparerForAccountsGet(ctx context.Context, id AccountId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForAccountsGet handles the response to the AccountsGet request. The method always -// closes the http.Response Body. -func (c DeviceupdatesClient) responderForAccountsGet(resp *http.Response) (result AccountsGetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_accountshead.go b/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_accountshead.go new file mode 100644 index 00000000000..60e33d54ad5 --- /dev/null +++ b/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_accountshead.go @@ -0,0 +1,46 @@ +package deviceupdates + +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 AccountsHeadOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// AccountsHead ... +func (c DeviceupdatesClient) AccountsHead(ctx context.Context, id AccountId) (result AccountsHeadOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + 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 + } + + return +} diff --git a/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_accountshead_autorest.go b/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_accountshead_autorest.go deleted file mode 100644 index f626397ac4e..00000000000 --- a/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_accountshead_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package deviceupdates - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type AccountsHeadOperationResponse struct { - HttpResponse *http.Response -} - -// AccountsHead ... -func (c DeviceupdatesClient) AccountsHead(ctx context.Context, id AccountId) (result AccountsHeadOperationResponse, err error) { - req, err := c.preparerForAccountsHead(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "AccountsHead", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "AccountsHead", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForAccountsHead(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "AccountsHead", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForAccountsHead prepares the AccountsHead request. -func (c DeviceupdatesClient) preparerForAccountsHead(ctx context.Context, id AccountId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForAccountsHead handles the response to the AccountsHead request. The method always -// closes the http.Response Body. -func (c DeviceupdatesClient) responderForAccountsHead(resp *http.Response) (result AccountsHeadOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_accountslistbyresourcegroup.go b/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_accountslistbyresourcegroup.go new file mode 100644 index 00000000000..fe00ccdcc56 --- /dev/null +++ b/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_accountslistbyresourcegroup.go @@ -0,0 +1,90 @@ +package deviceupdates + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 AccountsListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Account +} + +type AccountsListByResourceGroupCompleteResult struct { + Items []Account +} + +// AccountsListByResourceGroup ... +func (c DeviceupdatesClient) AccountsListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result AccountsListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.DeviceUpdate/accounts", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Account `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// AccountsListByResourceGroupComplete retrieves all the results into a single object +func (c DeviceupdatesClient) AccountsListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (AccountsListByResourceGroupCompleteResult, error) { + return c.AccountsListByResourceGroupCompleteMatchingPredicate(ctx, id, AccountOperationPredicate{}) +} + +// AccountsListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DeviceupdatesClient) AccountsListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate AccountOperationPredicate) (result AccountsListByResourceGroupCompleteResult, err error) { + items := make([]Account, 0) + + resp, err := c.AccountsListByResourceGroup(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = AccountsListByResourceGroupCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_accountslistbyresourcegroup_autorest.go b/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_accountslistbyresourcegroup_autorest.go deleted file mode 100644 index 38bb4a9dd4f..00000000000 --- a/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_accountslistbyresourcegroup_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package deviceupdates - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type AccountsListByResourceGroupOperationResponse struct { - HttpResponse *http.Response - Model *[]Account - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (AccountsListByResourceGroupOperationResponse, error) -} - -type AccountsListByResourceGroupCompleteResult struct { - Items []Account -} - -func (r AccountsListByResourceGroupOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r AccountsListByResourceGroupOperationResponse) LoadMore(ctx context.Context) (resp AccountsListByResourceGroupOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// AccountsListByResourceGroup ... -func (c DeviceupdatesClient) AccountsListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (resp AccountsListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForAccountsListByResourceGroup(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "AccountsListByResourceGroup", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "AccountsListByResourceGroup", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForAccountsListByResourceGroup(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "AccountsListByResourceGroup", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForAccountsListByResourceGroup prepares the AccountsListByResourceGroup request. -func (c DeviceupdatesClient) preparerForAccountsListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.DeviceUpdate/accounts", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForAccountsListByResourceGroupWithNextLink prepares the AccountsListByResourceGroup request with the given nextLink token. -func (c DeviceupdatesClient) preparerForAccountsListByResourceGroupWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForAccountsListByResourceGroup handles the response to the AccountsListByResourceGroup request. The method always -// closes the http.Response Body. -func (c DeviceupdatesClient) responderForAccountsListByResourceGroup(resp *http.Response) (result AccountsListByResourceGroupOperationResponse, err error) { - type page struct { - Values []Account `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result AccountsListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForAccountsListByResourceGroupWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "AccountsListByResourceGroup", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "AccountsListByResourceGroup", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForAccountsListByResourceGroup(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "AccountsListByResourceGroup", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// AccountsListByResourceGroupComplete retrieves all of the results into a single object -func (c DeviceupdatesClient) AccountsListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (AccountsListByResourceGroupCompleteResult, error) { - return c.AccountsListByResourceGroupCompleteMatchingPredicate(ctx, id, AccountOperationPredicate{}) -} - -// AccountsListByResourceGroupCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c DeviceupdatesClient) AccountsListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate AccountOperationPredicate) (resp AccountsListByResourceGroupCompleteResult, err error) { - items := make([]Account, 0) - - page, err := c.AccountsListByResourceGroup(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := AccountsListByResourceGroupCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_accountslistbysubscription.go b/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_accountslistbysubscription.go new file mode 100644 index 00000000000..35ae14b0782 --- /dev/null +++ b/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_accountslistbysubscription.go @@ -0,0 +1,90 @@ +package deviceupdates + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 AccountsListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Account +} + +type AccountsListBySubscriptionCompleteResult struct { + Items []Account +} + +// AccountsListBySubscription ... +func (c DeviceupdatesClient) AccountsListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result AccountsListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.DeviceUpdate/accounts", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Account `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// AccountsListBySubscriptionComplete retrieves all the results into a single object +func (c DeviceupdatesClient) AccountsListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (AccountsListBySubscriptionCompleteResult, error) { + return c.AccountsListBySubscriptionCompleteMatchingPredicate(ctx, id, AccountOperationPredicate{}) +} + +// AccountsListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DeviceupdatesClient) AccountsListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate AccountOperationPredicate) (result AccountsListBySubscriptionCompleteResult, err error) { + items := make([]Account, 0) + + resp, err := c.AccountsListBySubscription(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = AccountsListBySubscriptionCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_accountslistbysubscription_autorest.go b/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_accountslistbysubscription_autorest.go deleted file mode 100644 index 71982e43572..00000000000 --- a/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_accountslistbysubscription_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package deviceupdates - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type AccountsListBySubscriptionOperationResponse struct { - HttpResponse *http.Response - Model *[]Account - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (AccountsListBySubscriptionOperationResponse, error) -} - -type AccountsListBySubscriptionCompleteResult struct { - Items []Account -} - -func (r AccountsListBySubscriptionOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r AccountsListBySubscriptionOperationResponse) LoadMore(ctx context.Context) (resp AccountsListBySubscriptionOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// AccountsListBySubscription ... -func (c DeviceupdatesClient) AccountsListBySubscription(ctx context.Context, id commonids.SubscriptionId) (resp AccountsListBySubscriptionOperationResponse, err error) { - req, err := c.preparerForAccountsListBySubscription(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "AccountsListBySubscription", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "AccountsListBySubscription", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForAccountsListBySubscription(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "AccountsListBySubscription", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForAccountsListBySubscription prepares the AccountsListBySubscription request. -func (c DeviceupdatesClient) preparerForAccountsListBySubscription(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.DeviceUpdate/accounts", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForAccountsListBySubscriptionWithNextLink prepares the AccountsListBySubscription request with the given nextLink token. -func (c DeviceupdatesClient) preparerForAccountsListBySubscriptionWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForAccountsListBySubscription handles the response to the AccountsListBySubscription request. The method always -// closes the http.Response Body. -func (c DeviceupdatesClient) responderForAccountsListBySubscription(resp *http.Response) (result AccountsListBySubscriptionOperationResponse, err error) { - type page struct { - Values []Account `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result AccountsListBySubscriptionOperationResponse, err error) { - req, err := c.preparerForAccountsListBySubscriptionWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "AccountsListBySubscription", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "AccountsListBySubscription", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForAccountsListBySubscription(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "AccountsListBySubscription", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// AccountsListBySubscriptionComplete retrieves all of the results into a single object -func (c DeviceupdatesClient) AccountsListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (AccountsListBySubscriptionCompleteResult, error) { - return c.AccountsListBySubscriptionCompleteMatchingPredicate(ctx, id, AccountOperationPredicate{}) -} - -// AccountsListBySubscriptionCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c DeviceupdatesClient) AccountsListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate AccountOperationPredicate) (resp AccountsListBySubscriptionCompleteResult, err error) { - items := make([]Account, 0) - - page, err := c.AccountsListBySubscription(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := AccountsListBySubscriptionCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_accountsupdate.go b/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_accountsupdate.go new file mode 100644 index 00000000000..254dda12522 --- /dev/null +++ b/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_accountsupdate.go @@ -0,0 +1,74 @@ +package deviceupdates + +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 AccountsUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// AccountsUpdate ... +func (c DeviceupdatesClient) AccountsUpdate(ctx context.Context, id AccountId, input AccountUpdate) (result AccountsUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + 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 +} + +// AccountsUpdateThenPoll performs AccountsUpdate then polls until it's completed +func (c DeviceupdatesClient) AccountsUpdateThenPoll(ctx context.Context, id AccountId, input AccountUpdate) error { + result, err := c.AccountsUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing AccountsUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after AccountsUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_accountsupdate_autorest.go b/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_accountsupdate_autorest.go deleted file mode 100644 index 02782a52cd8..00000000000 --- a/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_accountsupdate_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package deviceupdates - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type AccountsUpdateOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// AccountsUpdate ... -func (c DeviceupdatesClient) AccountsUpdate(ctx context.Context, id AccountId, input AccountUpdate) (result AccountsUpdateOperationResponse, err error) { - req, err := c.preparerForAccountsUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "AccountsUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForAccountsUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "AccountsUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// AccountsUpdateThenPoll performs AccountsUpdate then polls until it's completed -func (c DeviceupdatesClient) AccountsUpdateThenPoll(ctx context.Context, id AccountId, input AccountUpdate) error { - result, err := c.AccountsUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing AccountsUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after AccountsUpdate: %+v", err) - } - - return nil -} - -// preparerForAccountsUpdate prepares the AccountsUpdate request. -func (c DeviceupdatesClient) preparerForAccountsUpdate(ctx context.Context, id AccountId, input AccountUpdate) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForAccountsUpdate sends the AccountsUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c DeviceupdatesClient) senderForAccountsUpdate(ctx context.Context, req *http.Request) (future AccountsUpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_checknameavailability.go b/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_checknameavailability.go new file mode 100644 index 00000000000..efc22f96ee3 --- /dev/null +++ b/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_checknameavailability.go @@ -0,0 +1,57 @@ +package deviceupdates + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 CheckNameAvailabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CheckNameAvailabilityResponse +} + +// CheckNameAvailability ... +func (c DeviceupdatesClient) CheckNameAvailability(ctx context.Context, id commonids.SubscriptionId, input CheckNameAvailabilityRequest) (result CheckNameAvailabilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.DeviceUpdate/checknameavailability", 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 +} diff --git a/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_checknameavailability_autorest.go b/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_checknameavailability_autorest.go deleted file mode 100644 index 9ae34262cf3..00000000000 --- a/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_checknameavailability_autorest.go +++ /dev/null @@ -1,71 +0,0 @@ -package deviceupdates - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CheckNameAvailabilityOperationResponse struct { - HttpResponse *http.Response - Model *CheckNameAvailabilityResponse -} - -// CheckNameAvailability ... -func (c DeviceupdatesClient) CheckNameAvailability(ctx context.Context, id commonids.SubscriptionId, input CheckNameAvailabilityRequest) (result CheckNameAvailabilityOperationResponse, err error) { - req, err := c.preparerForCheckNameAvailability(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "CheckNameAvailability", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "CheckNameAvailability", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCheckNameAvailability(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "CheckNameAvailability", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCheckNameAvailability prepares the CheckNameAvailability request. -func (c DeviceupdatesClient) preparerForCheckNameAvailability(ctx context.Context, id commonids.SubscriptionId, input CheckNameAvailabilityRequest) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.DeviceUpdate/checknameavailability", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCheckNameAvailability handles the response to the CheckNameAvailability request. The method always -// closes the http.Response Body. -func (c DeviceupdatesClient) responderForCheckNameAvailability(resp *http.Response) (result CheckNameAvailabilityOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_instancescreate.go b/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_instancescreate.go new file mode 100644 index 00000000000..7725a156955 --- /dev/null +++ b/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_instancescreate.go @@ -0,0 +1,73 @@ +package deviceupdates + +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 InstancesCreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// InstancesCreate ... +func (c DeviceupdatesClient) InstancesCreate(ctx context.Context, id InstanceId, input Instance) (result InstancesCreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + 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 +} + +// InstancesCreateThenPoll performs InstancesCreate then polls until it's completed +func (c DeviceupdatesClient) InstancesCreateThenPoll(ctx context.Context, id InstanceId, input Instance) error { + result, err := c.InstancesCreate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing InstancesCreate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after InstancesCreate: %+v", err) + } + + return nil +} diff --git a/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_instancescreate_autorest.go b/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_instancescreate_autorest.go deleted file mode 100644 index b426d6ed181..00000000000 --- a/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_instancescreate_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package deviceupdates - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type InstancesCreateOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// InstancesCreate ... -func (c DeviceupdatesClient) InstancesCreate(ctx context.Context, id InstanceId, input Instance) (result InstancesCreateOperationResponse, err error) { - req, err := c.preparerForInstancesCreate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "InstancesCreate", nil, "Failure preparing request") - return - } - - result, err = c.senderForInstancesCreate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "InstancesCreate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// InstancesCreateThenPoll performs InstancesCreate then polls until it's completed -func (c DeviceupdatesClient) InstancesCreateThenPoll(ctx context.Context, id InstanceId, input Instance) error { - result, err := c.InstancesCreate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing InstancesCreate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after InstancesCreate: %+v", err) - } - - return nil -} - -// preparerForInstancesCreate prepares the InstancesCreate request. -func (c DeviceupdatesClient) preparerForInstancesCreate(ctx context.Context, id InstanceId, input Instance) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForInstancesCreate sends the InstancesCreate request. The method will close the -// http.Response Body if it receives an error. -func (c DeviceupdatesClient) senderForInstancesCreate(ctx context.Context, req *http.Request) (future InstancesCreateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_instancesdelete.go b/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_instancesdelete.go new file mode 100644 index 00000000000..2ba678c4a4c --- /dev/null +++ b/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_instancesdelete.go @@ -0,0 +1,71 @@ +package deviceupdates + +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 InstancesDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// InstancesDelete ... +func (c DeviceupdatesClient) InstancesDelete(ctx context.Context, id InstanceId) (result InstancesDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 +} + +// InstancesDeleteThenPoll performs InstancesDelete then polls until it's completed +func (c DeviceupdatesClient) InstancesDeleteThenPoll(ctx context.Context, id InstanceId) error { + result, err := c.InstancesDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing InstancesDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after InstancesDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_instancesdelete_autorest.go b/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_instancesdelete_autorest.go deleted file mode 100644 index 7d645e87538..00000000000 --- a/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_instancesdelete_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package deviceupdates - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type InstancesDeleteOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// InstancesDelete ... -func (c DeviceupdatesClient) InstancesDelete(ctx context.Context, id InstanceId) (result InstancesDeleteOperationResponse, err error) { - req, err := c.preparerForInstancesDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "InstancesDelete", nil, "Failure preparing request") - return - } - - result, err = c.senderForInstancesDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "InstancesDelete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// InstancesDeleteThenPoll performs InstancesDelete then polls until it's completed -func (c DeviceupdatesClient) InstancesDeleteThenPoll(ctx context.Context, id InstanceId) error { - result, err := c.InstancesDelete(ctx, id) - if err != nil { - return fmt.Errorf("performing InstancesDelete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after InstancesDelete: %+v", err) - } - - return nil -} - -// preparerForInstancesDelete prepares the InstancesDelete request. -func (c DeviceupdatesClient) preparerForInstancesDelete(ctx context.Context, id InstanceId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForInstancesDelete sends the InstancesDelete request. The method will close the -// http.Response Body if it receives an error. -func (c DeviceupdatesClient) senderForInstancesDelete(ctx context.Context, req *http.Request) (future InstancesDeleteOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_instancesget.go b/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_instancesget.go new file mode 100644 index 00000000000..aca7a849c6f --- /dev/null +++ b/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_instancesget.go @@ -0,0 +1,51 @@ +package deviceupdates + +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 InstancesGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Instance +} + +// InstancesGet ... +func (c DeviceupdatesClient) InstancesGet(ctx context.Context, id InstanceId) (result InstancesGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_instancesget_autorest.go b/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_instancesget_autorest.go deleted file mode 100644 index 0847285a3c5..00000000000 --- a/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_instancesget_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package deviceupdates - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type InstancesGetOperationResponse struct { - HttpResponse *http.Response - Model *Instance -} - -// InstancesGet ... -func (c DeviceupdatesClient) InstancesGet(ctx context.Context, id InstanceId) (result InstancesGetOperationResponse, err error) { - req, err := c.preparerForInstancesGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "InstancesGet", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "InstancesGet", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForInstancesGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "InstancesGet", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForInstancesGet prepares the InstancesGet request. -func (c DeviceupdatesClient) preparerForInstancesGet(ctx context.Context, id InstanceId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForInstancesGet handles the response to the InstancesGet request. The method always -// closes the http.Response Body. -func (c DeviceupdatesClient) responderForInstancesGet(resp *http.Response) (result InstancesGetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_instanceshead.go b/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_instanceshead.go new file mode 100644 index 00000000000..46766df9329 --- /dev/null +++ b/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_instanceshead.go @@ -0,0 +1,46 @@ +package deviceupdates + +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 InstancesHeadOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// InstancesHead ... +func (c DeviceupdatesClient) InstancesHead(ctx context.Context, id InstanceId) (result InstancesHeadOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + 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 + } + + return +} diff --git a/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_instanceshead_autorest.go b/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_instanceshead_autorest.go deleted file mode 100644 index 9d201943799..00000000000 --- a/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_instanceshead_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package deviceupdates - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type InstancesHeadOperationResponse struct { - HttpResponse *http.Response -} - -// InstancesHead ... -func (c DeviceupdatesClient) InstancesHead(ctx context.Context, id InstanceId) (result InstancesHeadOperationResponse, err error) { - req, err := c.preparerForInstancesHead(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "InstancesHead", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "InstancesHead", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForInstancesHead(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "InstancesHead", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForInstancesHead prepares the InstancesHead request. -func (c DeviceupdatesClient) preparerForInstancesHead(ctx context.Context, id InstanceId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForInstancesHead handles the response to the InstancesHead request. The method always -// closes the http.Response Body. -func (c DeviceupdatesClient) responderForInstancesHead(resp *http.Response) (result InstancesHeadOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_instanceslistbyaccount.go b/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_instanceslistbyaccount.go new file mode 100644 index 00000000000..2728c8ac749 --- /dev/null +++ b/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_instanceslistbyaccount.go @@ -0,0 +1,89 @@ +package deviceupdates + +import ( + "context" + "fmt" + "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 InstancesListByAccountOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Instance +} + +type InstancesListByAccountCompleteResult struct { + Items []Instance +} + +// InstancesListByAccount ... +func (c DeviceupdatesClient) InstancesListByAccount(ctx context.Context, id AccountId) (result InstancesListByAccountOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/instances", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Instance `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// InstancesListByAccountComplete retrieves all the results into a single object +func (c DeviceupdatesClient) InstancesListByAccountComplete(ctx context.Context, id AccountId) (InstancesListByAccountCompleteResult, error) { + return c.InstancesListByAccountCompleteMatchingPredicate(ctx, id, InstanceOperationPredicate{}) +} + +// InstancesListByAccountCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DeviceupdatesClient) InstancesListByAccountCompleteMatchingPredicate(ctx context.Context, id AccountId, predicate InstanceOperationPredicate) (result InstancesListByAccountCompleteResult, err error) { + items := make([]Instance, 0) + + resp, err := c.InstancesListByAccount(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = InstancesListByAccountCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_instanceslistbyaccount_autorest.go b/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_instanceslistbyaccount_autorest.go deleted file mode 100644 index a5feff5dea3..00000000000 --- a/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_instanceslistbyaccount_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package deviceupdates - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type InstancesListByAccountOperationResponse struct { - HttpResponse *http.Response - Model *[]Instance - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (InstancesListByAccountOperationResponse, error) -} - -type InstancesListByAccountCompleteResult struct { - Items []Instance -} - -func (r InstancesListByAccountOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r InstancesListByAccountOperationResponse) LoadMore(ctx context.Context) (resp InstancesListByAccountOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// InstancesListByAccount ... -func (c DeviceupdatesClient) InstancesListByAccount(ctx context.Context, id AccountId) (resp InstancesListByAccountOperationResponse, err error) { - req, err := c.preparerForInstancesListByAccount(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "InstancesListByAccount", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "InstancesListByAccount", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForInstancesListByAccount(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "InstancesListByAccount", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForInstancesListByAccount prepares the InstancesListByAccount request. -func (c DeviceupdatesClient) preparerForInstancesListByAccount(ctx context.Context, id AccountId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/instances", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForInstancesListByAccountWithNextLink prepares the InstancesListByAccount request with the given nextLink token. -func (c DeviceupdatesClient) preparerForInstancesListByAccountWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForInstancesListByAccount handles the response to the InstancesListByAccount request. The method always -// closes the http.Response Body. -func (c DeviceupdatesClient) responderForInstancesListByAccount(resp *http.Response) (result InstancesListByAccountOperationResponse, err error) { - type page struct { - Values []Instance `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result InstancesListByAccountOperationResponse, err error) { - req, err := c.preparerForInstancesListByAccountWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "InstancesListByAccount", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "InstancesListByAccount", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForInstancesListByAccount(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "InstancesListByAccount", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// InstancesListByAccountComplete retrieves all of the results into a single object -func (c DeviceupdatesClient) InstancesListByAccountComplete(ctx context.Context, id AccountId) (InstancesListByAccountCompleteResult, error) { - return c.InstancesListByAccountCompleteMatchingPredicate(ctx, id, InstanceOperationPredicate{}) -} - -// InstancesListByAccountCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c DeviceupdatesClient) InstancesListByAccountCompleteMatchingPredicate(ctx context.Context, id AccountId, predicate InstanceOperationPredicate) (resp InstancesListByAccountCompleteResult, err error) { - items := make([]Instance, 0) - - page, err := c.InstancesListByAccount(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := InstancesListByAccountCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_instancesupdate.go b/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_instancesupdate.go new file mode 100644 index 00000000000..d3cc3569818 --- /dev/null +++ b/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_instancesupdate.go @@ -0,0 +1,55 @@ +package deviceupdates + +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 InstancesUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Instance +} + +// InstancesUpdate ... +func (c DeviceupdatesClient) InstancesUpdate(ctx context.Context, id InstanceId, input TagUpdate) (result InstancesUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + 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 +} diff --git a/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_instancesupdate_autorest.go b/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_instancesupdate_autorest.go deleted file mode 100644 index 33d41cc6d92..00000000000 --- a/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_instancesupdate_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package deviceupdates - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type InstancesUpdateOperationResponse struct { - HttpResponse *http.Response - Model *Instance -} - -// InstancesUpdate ... -func (c DeviceupdatesClient) InstancesUpdate(ctx context.Context, id InstanceId, input TagUpdate) (result InstancesUpdateOperationResponse, err error) { - req, err := c.preparerForInstancesUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "InstancesUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "InstancesUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForInstancesUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "InstancesUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForInstancesUpdate prepares the InstancesUpdate request. -func (c DeviceupdatesClient) preparerForInstancesUpdate(ctx context.Context, id InstanceId, input TagUpdate) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForInstancesUpdate handles the response to the InstancesUpdate request. The method always -// closes the http.Response Body. -func (c DeviceupdatesClient) responderForInstancesUpdate(resp *http.Response) (result InstancesUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_privateendpointconnectionproxiesupdateprivateendpointproperties.go b/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_privateendpointconnectionproxiesupdateprivateendpointproperties.go new file mode 100644 index 00000000000..22883bbdc5b --- /dev/null +++ b/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_privateendpointconnectionproxiesupdateprivateendpointproperties.go @@ -0,0 +1,51 @@ +package deviceupdates + +import ( + "context" + "fmt" + "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 PrivateEndpointConnectionProxiesUpdatePrivateEndpointPropertiesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// PrivateEndpointConnectionProxiesUpdatePrivateEndpointProperties ... +func (c DeviceupdatesClient) PrivateEndpointConnectionProxiesUpdatePrivateEndpointProperties(ctx context.Context, id PrivateEndpointConnectionProxyId, input PrivateEndpointUpdate) (result PrivateEndpointConnectionProxiesUpdatePrivateEndpointPropertiesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/updatePrivateEndpointProperties", 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 + } + + return +} diff --git a/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_privateendpointconnectionproxiesupdateprivateendpointproperties_autorest.go b/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_privateendpointconnectionproxiesupdateprivateendpointproperties_autorest.go deleted file mode 100644 index 761917d2be7..00000000000 --- a/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_privateendpointconnectionproxiesupdateprivateendpointproperties_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package deviceupdates - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PrivateEndpointConnectionProxiesUpdatePrivateEndpointPropertiesOperationResponse struct { - HttpResponse *http.Response -} - -// PrivateEndpointConnectionProxiesUpdatePrivateEndpointProperties ... -func (c DeviceupdatesClient) PrivateEndpointConnectionProxiesUpdatePrivateEndpointProperties(ctx context.Context, id PrivateEndpointConnectionProxyId, input PrivateEndpointUpdate) (result PrivateEndpointConnectionProxiesUpdatePrivateEndpointPropertiesOperationResponse, err error) { - req, err := c.preparerForPrivateEndpointConnectionProxiesUpdatePrivateEndpointProperties(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "PrivateEndpointConnectionProxiesUpdatePrivateEndpointProperties", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "PrivateEndpointConnectionProxiesUpdatePrivateEndpointProperties", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForPrivateEndpointConnectionProxiesUpdatePrivateEndpointProperties(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "PrivateEndpointConnectionProxiesUpdatePrivateEndpointProperties", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForPrivateEndpointConnectionProxiesUpdatePrivateEndpointProperties prepares the PrivateEndpointConnectionProxiesUpdatePrivateEndpointProperties request. -func (c DeviceupdatesClient) preparerForPrivateEndpointConnectionProxiesUpdatePrivateEndpointProperties(ctx context.Context, id PrivateEndpointConnectionProxyId, input PrivateEndpointUpdate) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/updatePrivateEndpointProperties", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForPrivateEndpointConnectionProxiesUpdatePrivateEndpointProperties handles the response to the PrivateEndpointConnectionProxiesUpdatePrivateEndpointProperties request. The method always -// closes the http.Response Body. -func (c DeviceupdatesClient) responderForPrivateEndpointConnectionProxiesUpdatePrivateEndpointProperties(resp *http.Response) (result PrivateEndpointConnectionProxiesUpdatePrivateEndpointPropertiesOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_privateendpointconnectionproxiesvalidate.go b/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_privateendpointconnectionproxiesvalidate.go new file mode 100644 index 00000000000..8f1157ee164 --- /dev/null +++ b/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_privateendpointconnectionproxiesvalidate.go @@ -0,0 +1,51 @@ +package deviceupdates + +import ( + "context" + "fmt" + "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 PrivateEndpointConnectionProxiesValidateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// PrivateEndpointConnectionProxiesValidate ... +func (c DeviceupdatesClient) PrivateEndpointConnectionProxiesValidate(ctx context.Context, id PrivateEndpointConnectionProxyId, input PrivateEndpointConnectionProxy) (result PrivateEndpointConnectionProxiesValidateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/validate", 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 + } + + return +} diff --git a/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_privateendpointconnectionproxiesvalidate_autorest.go b/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_privateendpointconnectionproxiesvalidate_autorest.go deleted file mode 100644 index 042f5b8df68..00000000000 --- a/resource-manager/deviceupdate/2023-07-01/deviceupdates/method_privateendpointconnectionproxiesvalidate_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package deviceupdates - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PrivateEndpointConnectionProxiesValidateOperationResponse struct { - HttpResponse *http.Response -} - -// PrivateEndpointConnectionProxiesValidate ... -func (c DeviceupdatesClient) PrivateEndpointConnectionProxiesValidate(ctx context.Context, id PrivateEndpointConnectionProxyId, input PrivateEndpointConnectionProxy) (result PrivateEndpointConnectionProxiesValidateOperationResponse, err error) { - req, err := c.preparerForPrivateEndpointConnectionProxiesValidate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "PrivateEndpointConnectionProxiesValidate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "PrivateEndpointConnectionProxiesValidate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForPrivateEndpointConnectionProxiesValidate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "deviceupdates.DeviceupdatesClient", "PrivateEndpointConnectionProxiesValidate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForPrivateEndpointConnectionProxiesValidate prepares the PrivateEndpointConnectionProxiesValidate request. -func (c DeviceupdatesClient) preparerForPrivateEndpointConnectionProxiesValidate(ctx context.Context, id PrivateEndpointConnectionProxyId, input PrivateEndpointConnectionProxy) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/validate", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForPrivateEndpointConnectionProxiesValidate handles the response to the PrivateEndpointConnectionProxiesValidate request. The method always -// closes the http.Response Body. -func (c DeviceupdatesClient) responderForPrivateEndpointConnectionProxiesValidate(resp *http.Response) (result PrivateEndpointConnectionProxiesValidateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/deviceupdate/2023-07-01/privateendpointconnectionproxies/client.go b/resource-manager/deviceupdate/2023-07-01/privateendpointconnectionproxies/client.go index fdf29cf94c6..2c9fe576728 100644 --- a/resource-manager/deviceupdate/2023-07-01/privateendpointconnectionproxies/client.go +++ b/resource-manager/deviceupdate/2023-07-01/privateendpointconnectionproxies/client.go @@ -1,18 +1,26 @@ package privateendpointconnectionproxies -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 PrivateEndpointConnectionProxiesClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewPrivateEndpointConnectionProxiesClientWithBaseURI(endpoint string) PrivateEndpointConnectionProxiesClient { - return PrivateEndpointConnectionProxiesClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewPrivateEndpointConnectionProxiesClientWithBaseURI(api environments.Api) (*PrivateEndpointConnectionProxiesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "privateendpointconnectionproxies", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PrivateEndpointConnectionProxiesClient: %+v", err) } + + return &PrivateEndpointConnectionProxiesClient{ + Client: client, + }, nil } diff --git a/resource-manager/deviceupdate/2023-07-01/privateendpointconnectionproxies/constants.go b/resource-manager/deviceupdate/2023-07-01/privateendpointconnectionproxies/constants.go index 5f012dd63ac..f7f189eeb11 100644 --- a/resource-manager/deviceupdate/2023-07-01/privateendpointconnectionproxies/constants.go +++ b/resource-manager/deviceupdate/2023-07-01/privateendpointconnectionproxies/constants.go @@ -1,6 +1,10 @@ package privateendpointconnectionproxies -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. @@ -23,6 +27,19 @@ func PossibleValuesForPrivateEndpointConnectionProxyProvisioningState() []string } } +func (s *PrivateEndpointConnectionProxyProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointConnectionProxyProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePrivateEndpointConnectionProxyProvisioningState(input string) (*PrivateEndpointConnectionProxyProvisioningState, error) { vals := map[string]PrivateEndpointConnectionProxyProvisioningState{ "creating": PrivateEndpointConnectionProxyProvisioningStateCreating, @@ -55,6 +72,19 @@ func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { } } +func (s *PrivateEndpointServiceConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointServiceConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { vals := map[string]PrivateEndpointServiceConnectionStatus{ "approved": PrivateEndpointServiceConnectionStatusApproved, diff --git a/resource-manager/deviceupdate/2023-07-01/privateendpointconnectionproxies/method_createorupdate.go b/resource-manager/deviceupdate/2023-07-01/privateendpointconnectionproxies/method_createorupdate.go new file mode 100644 index 00000000000..1d5a0bf3aeb --- /dev/null +++ b/resource-manager/deviceupdate/2023-07-01/privateendpointconnectionproxies/method_createorupdate.go @@ -0,0 +1,73 @@ +package privateendpointconnectionproxies + +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 +} + +// CreateOrUpdate ... +func (c PrivateEndpointConnectionProxiesClient) CreateOrUpdate(ctx context.Context, id PrivateEndpointConnectionProxyId, input PrivateEndpointConnectionProxy) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + 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 PrivateEndpointConnectionProxiesClient) CreateOrUpdateThenPoll(ctx context.Context, id PrivateEndpointConnectionProxyId, input PrivateEndpointConnectionProxy) 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 +} diff --git a/resource-manager/deviceupdate/2023-07-01/privateendpointconnectionproxies/method_createorupdate_autorest.go b/resource-manager/deviceupdate/2023-07-01/privateendpointconnectionproxies/method_createorupdate_autorest.go deleted file mode 100644 index 68567545fb6..00000000000 --- a/resource-manager/deviceupdate/2023-07-01/privateendpointconnectionproxies/method_createorupdate_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package privateendpointconnectionproxies - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateOrUpdate ... -func (c PrivateEndpointConnectionProxiesClient) CreateOrUpdate(ctx context.Context, id PrivateEndpointConnectionProxyId, input PrivateEndpointConnectionProxy) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnectionproxies.PrivateEndpointConnectionProxiesClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnectionproxies.PrivateEndpointConnectionProxiesClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c PrivateEndpointConnectionProxiesClient) CreateOrUpdateThenPoll(ctx context.Context, id PrivateEndpointConnectionProxyId, input PrivateEndpointConnectionProxy) error { - result, err := c.CreateOrUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateOrUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateOrUpdate: %+v", err) - } - - return nil -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c PrivateEndpointConnectionProxiesClient) preparerForCreateOrUpdate(ctx context.Context, id PrivateEndpointConnectionProxyId, input PrivateEndpointConnectionProxy) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateOrUpdate sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c PrivateEndpointConnectionProxiesClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/deviceupdate/2023-07-01/privateendpointconnectionproxies/method_delete.go b/resource-manager/deviceupdate/2023-07-01/privateendpointconnectionproxies/method_delete.go new file mode 100644 index 00000000000..0d6c1c64207 --- /dev/null +++ b/resource-manager/deviceupdate/2023-07-01/privateendpointconnectionproxies/method_delete.go @@ -0,0 +1,71 @@ +package privateendpointconnectionproxies + +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 PrivateEndpointConnectionProxiesClient) Delete(ctx context.Context, id PrivateEndpointConnectionProxyId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 PrivateEndpointConnectionProxiesClient) DeleteThenPoll(ctx context.Context, id PrivateEndpointConnectionProxyId) 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 +} diff --git a/resource-manager/deviceupdate/2023-07-01/privateendpointconnectionproxies/method_delete_autorest.go b/resource-manager/deviceupdate/2023-07-01/privateendpointconnectionproxies/method_delete_autorest.go deleted file mode 100644 index d04511d3cd0..00000000000 --- a/resource-manager/deviceupdate/2023-07-01/privateendpointconnectionproxies/method_delete_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package privateendpointconnectionproxies - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// Delete ... -func (c PrivateEndpointConnectionProxiesClient) Delete(ctx context.Context, id PrivateEndpointConnectionProxyId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnectionproxies.PrivateEndpointConnectionProxiesClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnectionproxies.PrivateEndpointConnectionProxiesClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c PrivateEndpointConnectionProxiesClient) DeleteThenPoll(ctx context.Context, id PrivateEndpointConnectionProxyId) error { - result, err := c.Delete(ctx, id) - if err != nil { - return fmt.Errorf("performing Delete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Delete: %+v", err) - } - - return nil -} - -// preparerForDelete prepares the Delete request. -func (c PrivateEndpointConnectionProxiesClient) preparerForDelete(ctx context.Context, id PrivateEndpointConnectionProxyId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDelete sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (c PrivateEndpointConnectionProxiesClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/deviceupdate/2023-07-01/privateendpointconnectionproxies/method_listbyaccount.go b/resource-manager/deviceupdate/2023-07-01/privateendpointconnectionproxies/method_listbyaccount.go new file mode 100644 index 00000000000..d96815302a8 --- /dev/null +++ b/resource-manager/deviceupdate/2023-07-01/privateendpointconnectionproxies/method_listbyaccount.go @@ -0,0 +1,52 @@ +package privateendpointconnectionproxies + +import ( + "context" + "fmt" + "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 ListByAccountOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateEndpointConnectionProxyListResult +} + +// ListByAccount ... +func (c PrivateEndpointConnectionProxiesClient) ListByAccount(ctx context.Context, id AccountId) (result ListByAccountOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateEndpointConnectionProxies", 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 +} diff --git a/resource-manager/deviceupdate/2023-07-01/privateendpointconnectionproxies/method_listbyaccount_autorest.go b/resource-manager/deviceupdate/2023-07-01/privateendpointconnectionproxies/method_listbyaccount_autorest.go deleted file mode 100644 index ba230a126fb..00000000000 --- a/resource-manager/deviceupdate/2023-07-01/privateendpointconnectionproxies/method_listbyaccount_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package privateendpointconnectionproxies - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByAccountOperationResponse struct { - HttpResponse *http.Response - Model *PrivateEndpointConnectionProxyListResult -} - -// ListByAccount ... -func (c PrivateEndpointConnectionProxiesClient) ListByAccount(ctx context.Context, id AccountId) (result ListByAccountOperationResponse, err error) { - req, err := c.preparerForListByAccount(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnectionproxies.PrivateEndpointConnectionProxiesClient", "ListByAccount", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnectionproxies.PrivateEndpointConnectionProxiesClient", "ListByAccount", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByAccount(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnectionproxies.PrivateEndpointConnectionProxiesClient", "ListByAccount", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListByAccount prepares the ListByAccount request. -func (c PrivateEndpointConnectionProxiesClient) preparerForListByAccount(ctx context.Context, id AccountId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/privateEndpointConnectionProxies", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByAccount handles the response to the ListByAccount request. The method always -// closes the http.Response Body. -func (c PrivateEndpointConnectionProxiesClient) responderForListByAccount(resp *http.Response) (result ListByAccountOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/deviceupdate/2023-07-01/privateendpointconnections/client.go b/resource-manager/deviceupdate/2023-07-01/privateendpointconnections/client.go index 1de584406fe..05a6653dc59 100644 --- a/resource-manager/deviceupdate/2023-07-01/privateendpointconnections/client.go +++ b/resource-manager/deviceupdate/2023-07-01/privateendpointconnections/client.go @@ -1,18 +1,26 @@ package privateendpointconnections -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 PrivateEndpointConnectionsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewPrivateEndpointConnectionsClientWithBaseURI(endpoint string) PrivateEndpointConnectionsClient { - return PrivateEndpointConnectionsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewPrivateEndpointConnectionsClientWithBaseURI(api environments.Api) (*PrivateEndpointConnectionsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "privateendpointconnections", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PrivateEndpointConnectionsClient: %+v", err) } + + return &PrivateEndpointConnectionsClient{ + Client: client, + }, nil } diff --git a/resource-manager/deviceupdate/2023-07-01/privateendpointconnections/constants.go b/resource-manager/deviceupdate/2023-07-01/privateendpointconnections/constants.go index 9da3f799bea..f860cc47f58 100644 --- a/resource-manager/deviceupdate/2023-07-01/privateendpointconnections/constants.go +++ b/resource-manager/deviceupdate/2023-07-01/privateendpointconnections/constants.go @@ -1,6 +1,10 @@ package privateendpointconnections -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. @@ -23,6 +27,19 @@ func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { } } +func (s *PrivateEndpointConnectionProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointConnectionProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { vals := map[string]PrivateEndpointConnectionProvisioningState{ "creating": PrivateEndpointConnectionProvisioningStateCreating, @@ -57,6 +74,19 @@ func PossibleValuesForPrivateEndpointConnectionProxyProvisioningState() []string } } +func (s *PrivateEndpointConnectionProxyProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointConnectionProxyProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePrivateEndpointConnectionProxyProvisioningState(input string) (*PrivateEndpointConnectionProxyProvisioningState, error) { vals := map[string]PrivateEndpointConnectionProxyProvisioningState{ "creating": PrivateEndpointConnectionProxyProvisioningStateCreating, @@ -89,6 +119,19 @@ func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { } } +func (s *PrivateEndpointServiceConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointServiceConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { vals := map[string]PrivateEndpointServiceConnectionStatus{ "approved": PrivateEndpointServiceConnectionStatusApproved, diff --git a/resource-manager/deviceupdate/2023-07-01/privateendpointconnections/method_createorupdate.go b/resource-manager/deviceupdate/2023-07-01/privateendpointconnections/method_createorupdate.go new file mode 100644 index 00000000000..0cdbbdceac5 --- /dev/null +++ b/resource-manager/deviceupdate/2023-07-01/privateendpointconnections/method_createorupdate.go @@ -0,0 +1,73 @@ +package privateendpointconnections + +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 +} + +// CreateOrUpdate ... +func (c PrivateEndpointConnectionsClient) CreateOrUpdate(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + 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 PrivateEndpointConnectionsClient) CreateOrUpdateThenPoll(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) 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 +} diff --git a/resource-manager/deviceupdate/2023-07-01/privateendpointconnections/method_createorupdate_autorest.go b/resource-manager/deviceupdate/2023-07-01/privateendpointconnections/method_createorupdate_autorest.go deleted file mode 100644 index 08aac1fbfa7..00000000000 --- a/resource-manager/deviceupdate/2023-07-01/privateendpointconnections/method_createorupdate_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package privateendpointconnections - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateOrUpdate ... -func (c PrivateEndpointConnectionsClient) CreateOrUpdate(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c PrivateEndpointConnectionsClient) CreateOrUpdateThenPoll(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) error { - result, err := c.CreateOrUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateOrUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateOrUpdate: %+v", err) - } - - return nil -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c PrivateEndpointConnectionsClient) preparerForCreateOrUpdate(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateOrUpdate sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c PrivateEndpointConnectionsClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/deviceupdate/2023-07-01/privateendpointconnections/method_delete.go b/resource-manager/deviceupdate/2023-07-01/privateendpointconnections/method_delete.go new file mode 100644 index 00000000000..4ae0907ed97 --- /dev/null +++ b/resource-manager/deviceupdate/2023-07-01/privateendpointconnections/method_delete.go @@ -0,0 +1,71 @@ +package privateendpointconnections + +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 PrivateEndpointConnectionsClient) Delete(ctx context.Context, id PrivateEndpointConnectionId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 PrivateEndpointConnectionsClient) DeleteThenPoll(ctx context.Context, id PrivateEndpointConnectionId) 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 +} diff --git a/resource-manager/deviceupdate/2023-07-01/privateendpointconnections/method_delete_autorest.go b/resource-manager/deviceupdate/2023-07-01/privateendpointconnections/method_delete_autorest.go deleted file mode 100644 index ef4fd3d8e66..00000000000 --- a/resource-manager/deviceupdate/2023-07-01/privateendpointconnections/method_delete_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package privateendpointconnections - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// Delete ... -func (c PrivateEndpointConnectionsClient) Delete(ctx context.Context, id PrivateEndpointConnectionId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c PrivateEndpointConnectionsClient) DeleteThenPoll(ctx context.Context, id PrivateEndpointConnectionId) error { - result, err := c.Delete(ctx, id) - if err != nil { - return fmt.Errorf("performing Delete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Delete: %+v", err) - } - - return nil -} - -// preparerForDelete prepares the Delete request. -func (c PrivateEndpointConnectionsClient) preparerForDelete(ctx context.Context, id PrivateEndpointConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDelete sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (c PrivateEndpointConnectionsClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/deviceupdate/2023-07-01/privateendpointconnections/method_get.go b/resource-manager/deviceupdate/2023-07-01/privateendpointconnections/method_get.go new file mode 100644 index 00000000000..713c7e2c836 --- /dev/null +++ b/resource-manager/deviceupdate/2023-07-01/privateendpointconnections/method_get.go @@ -0,0 +1,51 @@ +package privateendpointconnections + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateEndpointConnection +} + +// Get ... +func (c PrivateEndpointConnectionsClient) Get(ctx context.Context, id PrivateEndpointConnectionId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/deviceupdate/2023-07-01/privateendpointconnections/method_get_autorest.go b/resource-manager/deviceupdate/2023-07-01/privateendpointconnections/method_get_autorest.go deleted file mode 100644 index 44bbdcb8f0b..00000000000 --- a/resource-manager/deviceupdate/2023-07-01/privateendpointconnections/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package privateendpointconnections - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *PrivateEndpointConnection -} - -// Get ... -func (c PrivateEndpointConnectionsClient) Get(ctx context.Context, id PrivateEndpointConnectionId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c PrivateEndpointConnectionsClient) preparerForGet(ctx context.Context, id PrivateEndpointConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c PrivateEndpointConnectionsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/deviceupdate/2023-07-01/privateendpointconnections/method_listbyaccount.go b/resource-manager/deviceupdate/2023-07-01/privateendpointconnections/method_listbyaccount.go new file mode 100644 index 00000000000..cbf56e6d246 --- /dev/null +++ b/resource-manager/deviceupdate/2023-07-01/privateendpointconnections/method_listbyaccount.go @@ -0,0 +1,52 @@ +package privateendpointconnections + +import ( + "context" + "fmt" + "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 ListByAccountOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateEndpointConnectionListResult +} + +// ListByAccount ... +func (c PrivateEndpointConnectionsClient) ListByAccount(ctx context.Context, id AccountId) (result ListByAccountOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateEndpointConnections", 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 +} diff --git a/resource-manager/deviceupdate/2023-07-01/privateendpointconnections/method_listbyaccount_autorest.go b/resource-manager/deviceupdate/2023-07-01/privateendpointconnections/method_listbyaccount_autorest.go deleted file mode 100644 index c5fb27a461f..00000000000 --- a/resource-manager/deviceupdate/2023-07-01/privateendpointconnections/method_listbyaccount_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package privateendpointconnections - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByAccountOperationResponse struct { - HttpResponse *http.Response - Model *PrivateEndpointConnectionListResult -} - -// ListByAccount ... -func (c PrivateEndpointConnectionsClient) ListByAccount(ctx context.Context, id AccountId) (result ListByAccountOperationResponse, err error) { - req, err := c.preparerForListByAccount(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "ListByAccount", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "ListByAccount", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByAccount(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "ListByAccount", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListByAccount prepares the ListByAccount request. -func (c PrivateEndpointConnectionsClient) preparerForListByAccount(ctx context.Context, id AccountId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/privateEndpointConnections", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByAccount handles the response to the ListByAccount request. The method always -// closes the http.Response Body. -func (c PrivateEndpointConnectionsClient) responderForListByAccount(resp *http.Response) (result ListByAccountOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/deviceupdate/2023-07-01/privateendpointconnections/method_privateendpointconnectionproxiesget.go b/resource-manager/deviceupdate/2023-07-01/privateendpointconnections/method_privateendpointconnectionproxiesget.go new file mode 100644 index 00000000000..0a87b86d0ca --- /dev/null +++ b/resource-manager/deviceupdate/2023-07-01/privateendpointconnections/method_privateendpointconnectionproxiesget.go @@ -0,0 +1,51 @@ +package privateendpointconnections + +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 PrivateEndpointConnectionProxiesGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateEndpointConnectionProxy +} + +// PrivateEndpointConnectionProxiesGet ... +func (c PrivateEndpointConnectionsClient) PrivateEndpointConnectionProxiesGet(ctx context.Context, id PrivateEndpointConnectionProxyId) (result PrivateEndpointConnectionProxiesGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/deviceupdate/2023-07-01/privateendpointconnections/method_privateendpointconnectionproxiesget_autorest.go b/resource-manager/deviceupdate/2023-07-01/privateendpointconnections/method_privateendpointconnectionproxiesget_autorest.go deleted file mode 100644 index 709f2b988bb..00000000000 --- a/resource-manager/deviceupdate/2023-07-01/privateendpointconnections/method_privateendpointconnectionproxiesget_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package privateendpointconnections - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PrivateEndpointConnectionProxiesGetOperationResponse struct { - HttpResponse *http.Response - Model *PrivateEndpointConnectionProxy -} - -// PrivateEndpointConnectionProxiesGet ... -func (c PrivateEndpointConnectionsClient) PrivateEndpointConnectionProxiesGet(ctx context.Context, id PrivateEndpointConnectionProxyId) (result PrivateEndpointConnectionProxiesGetOperationResponse, err error) { - req, err := c.preparerForPrivateEndpointConnectionProxiesGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "PrivateEndpointConnectionProxiesGet", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "PrivateEndpointConnectionProxiesGet", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForPrivateEndpointConnectionProxiesGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnections.PrivateEndpointConnectionsClient", "PrivateEndpointConnectionProxiesGet", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForPrivateEndpointConnectionProxiesGet prepares the PrivateEndpointConnectionProxiesGet request. -func (c PrivateEndpointConnectionsClient) preparerForPrivateEndpointConnectionProxiesGet(ctx context.Context, id PrivateEndpointConnectionProxyId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForPrivateEndpointConnectionProxiesGet handles the response to the PrivateEndpointConnectionProxiesGet request. The method always -// closes the http.Response Body. -func (c PrivateEndpointConnectionsClient) responderForPrivateEndpointConnectionProxiesGet(resp *http.Response) (result PrivateEndpointConnectionProxiesGetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/deviceupdate/2023-07-01/privatelinkresources/client.go b/resource-manager/deviceupdate/2023-07-01/privatelinkresources/client.go index 5f532940700..d331270c8f6 100644 --- a/resource-manager/deviceupdate/2023-07-01/privatelinkresources/client.go +++ b/resource-manager/deviceupdate/2023-07-01/privatelinkresources/client.go @@ -1,18 +1,26 @@ package privatelinkresources -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 PrivateLinkResourcesClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewPrivateLinkResourcesClientWithBaseURI(endpoint string) PrivateLinkResourcesClient { - return PrivateLinkResourcesClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewPrivateLinkResourcesClientWithBaseURI(api environments.Api) (*PrivateLinkResourcesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "privatelinkresources", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PrivateLinkResourcesClient: %+v", err) } + + return &PrivateLinkResourcesClient{ + Client: client, + }, nil } diff --git a/resource-manager/deviceupdate/2023-07-01/privatelinkresources/constants.go b/resource-manager/deviceupdate/2023-07-01/privatelinkresources/constants.go index 1b2a9353f36..79fe9f854e5 100644 --- a/resource-manager/deviceupdate/2023-07-01/privatelinkresources/constants.go +++ b/resource-manager/deviceupdate/2023-07-01/privatelinkresources/constants.go @@ -1,6 +1,10 @@ package privatelinkresources -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. @@ -21,6 +25,19 @@ func PossibleValuesForGroupIdProvisioningState() []string { } } +func (s *GroupIdProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGroupIdProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseGroupIdProvisioningState(input string) (*GroupIdProvisioningState, error) { vals := map[string]GroupIdProvisioningState{ "canceled": GroupIdProvisioningStateCanceled, diff --git a/resource-manager/deviceupdate/2023-07-01/privatelinkresources/method_get.go b/resource-manager/deviceupdate/2023-07-01/privatelinkresources/method_get.go new file mode 100644 index 00000000000..90b0434f7e4 --- /dev/null +++ b/resource-manager/deviceupdate/2023-07-01/privatelinkresources/method_get.go @@ -0,0 +1,51 @@ +package privatelinkresources + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *GroupInformation +} + +// Get ... +func (c PrivateLinkResourcesClient) Get(ctx context.Context, id PrivateLinkResourceId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/deviceupdate/2023-07-01/privatelinkresources/method_get_autorest.go b/resource-manager/deviceupdate/2023-07-01/privatelinkresources/method_get_autorest.go deleted file mode 100644 index accf0bbd7b0..00000000000 --- a/resource-manager/deviceupdate/2023-07-01/privatelinkresources/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package privatelinkresources - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *GroupInformation -} - -// Get ... -func (c PrivateLinkResourcesClient) Get(ctx context.Context, id PrivateLinkResourceId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresources.PrivateLinkResourcesClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresources.PrivateLinkResourcesClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresources.PrivateLinkResourcesClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c PrivateLinkResourcesClient) preparerForGet(ctx context.Context, id PrivateLinkResourceId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c PrivateLinkResourcesClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/deviceupdate/2023-07-01/privatelinkresources/method_listbyaccount.go b/resource-manager/deviceupdate/2023-07-01/privatelinkresources/method_listbyaccount.go new file mode 100644 index 00000000000..69e380c7442 --- /dev/null +++ b/resource-manager/deviceupdate/2023-07-01/privatelinkresources/method_listbyaccount.go @@ -0,0 +1,52 @@ +package privatelinkresources + +import ( + "context" + "fmt" + "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 ListByAccountOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateLinkResourceListResult +} + +// ListByAccount ... +func (c PrivateLinkResourcesClient) ListByAccount(ctx context.Context, id AccountId) (result ListByAccountOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateLinkResources", 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 +} diff --git a/resource-manager/deviceupdate/2023-07-01/privatelinkresources/method_listbyaccount_autorest.go b/resource-manager/deviceupdate/2023-07-01/privatelinkresources/method_listbyaccount_autorest.go deleted file mode 100644 index 6ffee9d5077..00000000000 --- a/resource-manager/deviceupdate/2023-07-01/privatelinkresources/method_listbyaccount_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package privatelinkresources - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByAccountOperationResponse struct { - HttpResponse *http.Response - Model *PrivateLinkResourceListResult -} - -// ListByAccount ... -func (c PrivateLinkResourcesClient) ListByAccount(ctx context.Context, id AccountId) (result ListByAccountOperationResponse, err error) { - req, err := c.preparerForListByAccount(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresources.PrivateLinkResourcesClient", "ListByAccount", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresources.PrivateLinkResourcesClient", "ListByAccount", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByAccount(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresources.PrivateLinkResourcesClient", "ListByAccount", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListByAccount prepares the ListByAccount request. -func (c PrivateLinkResourcesClient) preparerForListByAccount(ctx context.Context, id AccountId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/privateLinkResources", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByAccount handles the response to the ListByAccount request. The method always -// closes the http.Response Body. -func (c PrivateLinkResourcesClient) responderForListByAccount(resp *http.Response) (result ListByAccountOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/mysql/2021-05-01/backups/client.go b/resource-manager/mysql/2021-05-01/backups/client.go index 8669bac74ee..ae4432efd22 100644 --- a/resource-manager/mysql/2021-05-01/backups/client.go +++ b/resource-manager/mysql/2021-05-01/backups/client.go @@ -1,18 +1,26 @@ package backups -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 BackupsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewBackupsClientWithBaseURI(endpoint string) BackupsClient { - return BackupsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewBackupsClientWithBaseURI(api environments.Api) (*BackupsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "backups", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating BackupsClient: %+v", err) } + + return &BackupsClient{ + Client: client, + }, nil } diff --git a/resource-manager/mysql/2021-05-01/backups/method_get.go b/resource-manager/mysql/2021-05-01/backups/method_get.go new file mode 100644 index 00000000000..161afc45282 --- /dev/null +++ b/resource-manager/mysql/2021-05-01/backups/method_get.go @@ -0,0 +1,51 @@ +package backups + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ServerBackup +} + +// Get ... +func (c BackupsClient) Get(ctx context.Context, id BackupId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/mysql/2021-05-01/backups/method_get_autorest.go b/resource-manager/mysql/2021-05-01/backups/method_get_autorest.go deleted file mode 100644 index 932c6ce0d6c..00000000000 --- a/resource-manager/mysql/2021-05-01/backups/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package backups - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *ServerBackup -} - -// Get ... -func (c BackupsClient) Get(ctx context.Context, id BackupId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "backups.BackupsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "backups.BackupsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "backups.BackupsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c BackupsClient) preparerForGet(ctx context.Context, id BackupId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c BackupsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/mysql/2021-05-01/backups/method_listbyserver.go b/resource-manager/mysql/2021-05-01/backups/method_listbyserver.go new file mode 100644 index 00000000000..baab7e30266 --- /dev/null +++ b/resource-manager/mysql/2021-05-01/backups/method_listbyserver.go @@ -0,0 +1,89 @@ +package backups + +import ( + "context" + "fmt" + "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 ListByServerOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ServerBackup +} + +type ListByServerCompleteResult struct { + Items []ServerBackup +} + +// ListByServer ... +func (c BackupsClient) ListByServer(ctx context.Context, id FlexibleServerId) (result ListByServerOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/backups", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ServerBackup `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServerComplete retrieves all the results into a single object +func (c BackupsClient) ListByServerComplete(ctx context.Context, id FlexibleServerId) (ListByServerCompleteResult, error) { + return c.ListByServerCompleteMatchingPredicate(ctx, id, ServerBackupOperationPredicate{}) +} + +// ListByServerCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c BackupsClient) ListByServerCompleteMatchingPredicate(ctx context.Context, id FlexibleServerId, predicate ServerBackupOperationPredicate) (result ListByServerCompleteResult, err error) { + items := make([]ServerBackup, 0) + + resp, err := c.ListByServer(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServerCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/mysql/2021-05-01/backups/method_listbyserver_autorest.go b/resource-manager/mysql/2021-05-01/backups/method_listbyserver_autorest.go deleted file mode 100644 index 998090174cf..00000000000 --- a/resource-manager/mysql/2021-05-01/backups/method_listbyserver_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package backups - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByServerOperationResponse struct { - HttpResponse *http.Response - Model *[]ServerBackup - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServerOperationResponse, error) -} - -type ListByServerCompleteResult struct { - Items []ServerBackup -} - -func (r ListByServerOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServerOperationResponse) LoadMore(ctx context.Context) (resp ListByServerOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByServer ... -func (c BackupsClient) ListByServer(ctx context.Context, id FlexibleServerId) (resp ListByServerOperationResponse, err error) { - req, err := c.preparerForListByServer(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "backups.BackupsClient", "ListByServer", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "backups.BackupsClient", "ListByServer", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByServer(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "backups.BackupsClient", "ListByServer", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByServer prepares the ListByServer request. -func (c BackupsClient) preparerForListByServer(ctx context.Context, id FlexibleServerId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/backups", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServerWithNextLink prepares the ListByServer request with the given nextLink token. -func (c BackupsClient) preparerForListByServerWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByServer handles the response to the ListByServer request. The method always -// closes the http.Response Body. -func (c BackupsClient) responderForListByServer(resp *http.Response) (result ListByServerOperationResponse, err error) { - type page struct { - Values []ServerBackup `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByServerOperationResponse, err error) { - req, err := c.preparerForListByServerWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "backups.BackupsClient", "ListByServer", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "backups.BackupsClient", "ListByServer", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByServer(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "backups.BackupsClient", "ListByServer", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServerComplete retrieves all of the results into a single object -func (c BackupsClient) ListByServerComplete(ctx context.Context, id FlexibleServerId) (ListByServerCompleteResult, error) { - return c.ListByServerCompleteMatchingPredicate(ctx, id, ServerBackupOperationPredicate{}) -} - -// ListByServerCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c BackupsClient) ListByServerCompleteMatchingPredicate(ctx context.Context, id FlexibleServerId, predicate ServerBackupOperationPredicate) (resp ListByServerCompleteResult, err error) { - items := make([]ServerBackup, 0) - - page, err := c.ListByServer(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServerCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/mysql/2021-05-01/checknameavailability/client.go b/resource-manager/mysql/2021-05-01/checknameavailability/client.go index a8ea1dabf11..81c73505778 100644 --- a/resource-manager/mysql/2021-05-01/checknameavailability/client.go +++ b/resource-manager/mysql/2021-05-01/checknameavailability/client.go @@ -1,18 +1,26 @@ package checknameavailability -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 CheckNameAvailabilityClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewCheckNameAvailabilityClientWithBaseURI(endpoint string) CheckNameAvailabilityClient { - return CheckNameAvailabilityClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewCheckNameAvailabilityClientWithBaseURI(api environments.Api) (*CheckNameAvailabilityClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "checknameavailability", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CheckNameAvailabilityClient: %+v", err) } + + return &CheckNameAvailabilityClient{ + Client: client, + }, nil } diff --git a/resource-manager/mysql/2021-05-01/checknameavailability/method_execute.go b/resource-manager/mysql/2021-05-01/checknameavailability/method_execute.go new file mode 100644 index 00000000000..319ad5d298b --- /dev/null +++ b/resource-manager/mysql/2021-05-01/checknameavailability/method_execute.go @@ -0,0 +1,56 @@ +package checknameavailability + +import ( + "context" + "fmt" + "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 ExecuteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NameAvailability +} + +// Execute ... +func (c CheckNameAvailabilityClient) Execute(ctx context.Context, id LocationId, input NameAvailabilityRequest) (result ExecuteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/checkNameAvailability", 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 +} diff --git a/resource-manager/mysql/2021-05-01/checknameavailability/method_execute_autorest.go b/resource-manager/mysql/2021-05-01/checknameavailability/method_execute_autorest.go deleted file mode 100644 index abe034c4edd..00000000000 --- a/resource-manager/mysql/2021-05-01/checknameavailability/method_execute_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package checknameavailability - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ExecuteOperationResponse struct { - HttpResponse *http.Response - Model *NameAvailability -} - -// Execute ... -func (c CheckNameAvailabilityClient) Execute(ctx context.Context, id LocationId, input NameAvailabilityRequest) (result ExecuteOperationResponse, err error) { - req, err := c.preparerForExecute(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "checknameavailability.CheckNameAvailabilityClient", "Execute", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "checknameavailability.CheckNameAvailabilityClient", "Execute", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForExecute(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "checknameavailability.CheckNameAvailabilityClient", "Execute", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForExecute prepares the Execute request. -func (c CheckNameAvailabilityClient) preparerForExecute(ctx context.Context, id LocationId, input NameAvailabilityRequest) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/checkNameAvailability", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForExecute handles the response to the Execute request. The method always -// closes the http.Response Body. -func (c CheckNameAvailabilityClient) responderForExecute(resp *http.Response) (result ExecuteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/mysql/2021-05-01/checknameavailability/method_withoutlocationexecute.go b/resource-manager/mysql/2021-05-01/checknameavailability/method_withoutlocationexecute.go new file mode 100644 index 00000000000..875573b0386 --- /dev/null +++ b/resource-manager/mysql/2021-05-01/checknameavailability/method_withoutlocationexecute.go @@ -0,0 +1,57 @@ +package checknameavailability + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 WithoutLocationExecuteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NameAvailability +} + +// WithoutLocationExecute ... +func (c CheckNameAvailabilityClient) WithoutLocationExecute(ctx context.Context, id commonids.SubscriptionId, input NameAvailabilityRequest) (result WithoutLocationExecuteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.DBforMySQL/checkNameAvailability", 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 +} diff --git a/resource-manager/mysql/2021-05-01/checknameavailability/method_withoutlocationexecute_autorest.go b/resource-manager/mysql/2021-05-01/checknameavailability/method_withoutlocationexecute_autorest.go deleted file mode 100644 index ec031b0c323..00000000000 --- a/resource-manager/mysql/2021-05-01/checknameavailability/method_withoutlocationexecute_autorest.go +++ /dev/null @@ -1,71 +0,0 @@ -package checknameavailability - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type WithoutLocationExecuteOperationResponse struct { - HttpResponse *http.Response - Model *NameAvailability -} - -// WithoutLocationExecute ... -func (c CheckNameAvailabilityClient) WithoutLocationExecute(ctx context.Context, id commonids.SubscriptionId, input NameAvailabilityRequest) (result WithoutLocationExecuteOperationResponse, err error) { - req, err := c.preparerForWithoutLocationExecute(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "checknameavailability.CheckNameAvailabilityClient", "WithoutLocationExecute", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "checknameavailability.CheckNameAvailabilityClient", "WithoutLocationExecute", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForWithoutLocationExecute(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "checknameavailability.CheckNameAvailabilityClient", "WithoutLocationExecute", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForWithoutLocationExecute prepares the WithoutLocationExecute request. -func (c CheckNameAvailabilityClient) preparerForWithoutLocationExecute(ctx context.Context, id commonids.SubscriptionId, input NameAvailabilityRequest) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.DBforMySQL/checkNameAvailability", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForWithoutLocationExecute handles the response to the WithoutLocationExecute request. The method always -// closes the http.Response Body. -func (c CheckNameAvailabilityClient) responderForWithoutLocationExecute(resp *http.Response) (result WithoutLocationExecuteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/mysql/2021-05-01/client.go b/resource-manager/mysql/2021-05-01/client.go index eb3389bc2d9..0da79cf67c2 100644 --- a/resource-manager/mysql/2021-05-01/client.go +++ b/resource-manager/mysql/2021-05-01/client.go @@ -4,7 +4,8 @@ package v2021_05_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/mysql/2021-05-01/backups" "github.com/hashicorp/go-azure-sdk/resource-manager/mysql/2021-05-01/checknameavailability" "github.com/hashicorp/go-azure-sdk/resource-manager/mysql/2021-05-01/configurations" @@ -17,6 +18,8 @@ import ( "github.com/hashicorp/go-azure-sdk/resource-manager/mysql/2021-05-01/servers" "github.com/hashicorp/go-azure-sdk/resource-manager/mysql/2021-05-01/serverstart" "github.com/hashicorp/go-azure-sdk/resource-manager/mysql/2021-05-01/serverstop" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/environments" ) type Client struct { @@ -34,56 +37,91 @@ type Client struct { Servers *servers.ServersClient } -func NewClientWithBaseURI(endpoint string, configureAuthFunc func(c *autorest.Client)) Client { - - backupsClient := backups.NewBackupsClientWithBaseURI(endpoint) - configureAuthFunc(&backupsClient.Client) - - checkNameAvailabilityClient := checknameavailability.NewCheckNameAvailabilityClientWithBaseURI(endpoint) - configureAuthFunc(&checkNameAvailabilityClient.Client) +func NewClientWithBaseURI(api environments.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + backupsClient, err := backups.NewBackupsClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Backups client: %+v", err) + } + configureFunc(backupsClient.Client) - configurationsClient := configurations.NewConfigurationsClientWithBaseURI(endpoint) - configureAuthFunc(&configurationsClient.Client) + checkNameAvailabilityClient, err := checknameavailability.NewCheckNameAvailabilityClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building CheckNameAvailability client: %+v", err) + } + configureFunc(checkNameAvailabilityClient.Client) - databasesClient := databases.NewDatabasesClientWithBaseURI(endpoint) - configureAuthFunc(&databasesClient.Client) + configurationsClient, err := configurations.NewConfigurationsClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Configurations client: %+v", err) + } + configureFunc(configurationsClient.Client) - firewallRulesClient := firewallrules.NewFirewallRulesClientWithBaseURI(endpoint) - configureAuthFunc(&firewallRulesClient.Client) + databasesClient, err := databases.NewDatabasesClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Databases client: %+v", err) + } + configureFunc(databasesClient.Client) - getPrivateDnsZoneSuffixClient := getprivatednszonesuffix.NewGetPrivateDnsZoneSuffixClientWithBaseURI(endpoint) - configureAuthFunc(&getPrivateDnsZoneSuffixClient.Client) + firewallRulesClient, err := firewallrules.NewFirewallRulesClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building FirewallRules client: %+v", err) + } + configureFunc(firewallRulesClient.Client) - locationBasedCapabilitiesClient := locationbasedcapabilities.NewLocationBasedCapabilitiesClientWithBaseURI(endpoint) - configureAuthFunc(&locationBasedCapabilitiesClient.Client) + getPrivateDnsZoneSuffixClient, err := getprivatednszonesuffix.NewGetPrivateDnsZoneSuffixClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building GetPrivateDnsZoneSuffix client: %+v", err) + } + configureFunc(getPrivateDnsZoneSuffixClient.Client) - serverFailoverClient := serverfailover.NewServerFailoverClientWithBaseURI(endpoint) - configureAuthFunc(&serverFailoverClient.Client) + locationBasedCapabilitiesClient, err := locationbasedcapabilities.NewLocationBasedCapabilitiesClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building LocationBasedCapabilities client: %+v", err) + } + configureFunc(locationBasedCapabilitiesClient.Client) - serverRestartClient := serverrestart.NewServerRestartClientWithBaseURI(endpoint) - configureAuthFunc(&serverRestartClient.Client) + serverFailoverClient, err := serverfailover.NewServerFailoverClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ServerFailover client: %+v", err) + } + configureFunc(serverFailoverClient.Client) - serverStartClient := serverstart.NewServerStartClientWithBaseURI(endpoint) - configureAuthFunc(&serverStartClient.Client) + serverRestartClient, err := serverrestart.NewServerRestartClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ServerRestart client: %+v", err) + } + configureFunc(serverRestartClient.Client) - serverStopClient := serverstop.NewServerStopClientWithBaseURI(endpoint) - configureAuthFunc(&serverStopClient.Client) + serverStartClient, err := serverstart.NewServerStartClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ServerStart client: %+v", err) + } + configureFunc(serverStartClient.Client) - serversClient := servers.NewServersClientWithBaseURI(endpoint) - configureAuthFunc(&serversClient.Client) + serverStopClient, err := serverstop.NewServerStopClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ServerStop client: %+v", err) + } + configureFunc(serverStopClient.Client) - return Client{ - Backups: &backupsClient, - CheckNameAvailability: &checkNameAvailabilityClient, - Configurations: &configurationsClient, - Databases: &databasesClient, - FirewallRules: &firewallRulesClient, - GetPrivateDnsZoneSuffix: &getPrivateDnsZoneSuffixClient, - LocationBasedCapabilities: &locationBasedCapabilitiesClient, - ServerFailover: &serverFailoverClient, - ServerRestart: &serverRestartClient, - ServerStart: &serverStartClient, - ServerStop: &serverStopClient, - Servers: &serversClient, + serversClient, err := servers.NewServersClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Servers client: %+v", err) } + configureFunc(serversClient.Client) + + return &Client{ + Backups: backupsClient, + CheckNameAvailability: checkNameAvailabilityClient, + Configurations: configurationsClient, + Databases: databasesClient, + FirewallRules: firewallRulesClient, + GetPrivateDnsZoneSuffix: getPrivateDnsZoneSuffixClient, + LocationBasedCapabilities: locationBasedCapabilitiesClient, + ServerFailover: serverFailoverClient, + ServerRestart: serverRestartClient, + ServerStart: serverStartClient, + ServerStop: serverStopClient, + Servers: serversClient, + }, nil } diff --git a/resource-manager/mysql/2021-05-01/configurations/client.go b/resource-manager/mysql/2021-05-01/configurations/client.go index bbe813edd98..c2b3df6d8b8 100644 --- a/resource-manager/mysql/2021-05-01/configurations/client.go +++ b/resource-manager/mysql/2021-05-01/configurations/client.go @@ -1,18 +1,26 @@ package configurations -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 ConfigurationsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewConfigurationsClientWithBaseURI(endpoint string) ConfigurationsClient { - return ConfigurationsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewConfigurationsClientWithBaseURI(api environments.Api) (*ConfigurationsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "configurations", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ConfigurationsClient: %+v", err) } + + return &ConfigurationsClient{ + Client: client, + }, nil } diff --git a/resource-manager/mysql/2021-05-01/configurations/constants.go b/resource-manager/mysql/2021-05-01/configurations/constants.go index f1b6795d8b6..f1dd2076e3c 100644 --- a/resource-manager/mysql/2021-05-01/configurations/constants.go +++ b/resource-manager/mysql/2021-05-01/configurations/constants.go @@ -1,6 +1,10 @@ package configurations -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. @@ -19,6 +23,19 @@ func PossibleValuesForConfigurationSource() []string { } } +func (s *ConfigurationSource) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConfigurationSource(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseConfigurationSource(input string) (*ConfigurationSource, error) { vals := map[string]ConfigurationSource{ "system-default": ConfigurationSourceSystemNegativedefault, @@ -47,6 +64,19 @@ func PossibleValuesForIsConfigPendingRestart() []string { } } +func (s *IsConfigPendingRestart) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIsConfigPendingRestart(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseIsConfigPendingRestart(input string) (*IsConfigPendingRestart, error) { vals := map[string]IsConfigPendingRestart{ "false": IsConfigPendingRestartFalse, @@ -75,6 +105,19 @@ func PossibleValuesForIsDynamicConfig() []string { } } +func (s *IsDynamicConfig) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIsDynamicConfig(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseIsDynamicConfig(input string) (*IsDynamicConfig, error) { vals := map[string]IsDynamicConfig{ "false": IsDynamicConfigFalse, @@ -103,6 +146,19 @@ func PossibleValuesForIsReadOnly() []string { } } +func (s *IsReadOnly) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIsReadOnly(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseIsReadOnly(input string) (*IsReadOnly, error) { vals := map[string]IsReadOnly{ "false": IsReadOnlyFalse, diff --git a/resource-manager/mysql/2021-05-01/configurations/method_batchupdate.go b/resource-manager/mysql/2021-05-01/configurations/method_batchupdate.go new file mode 100644 index 00000000000..d0c2d8f4766 --- /dev/null +++ b/resource-manager/mysql/2021-05-01/configurations/method_batchupdate.go @@ -0,0 +1,74 @@ +package configurations + +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 BatchUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// BatchUpdate ... +func (c ConfigurationsClient) BatchUpdate(ctx context.Context, id FlexibleServerId, input ConfigurationListForBatchUpdate) (result BatchUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/updateConfigurations", 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 +} + +// BatchUpdateThenPoll performs BatchUpdate then polls until it's completed +func (c ConfigurationsClient) BatchUpdateThenPoll(ctx context.Context, id FlexibleServerId, input ConfigurationListForBatchUpdate) error { + result, err := c.BatchUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing BatchUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after BatchUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/mysql/2021-05-01/configurations/method_batchupdate_autorest.go b/resource-manager/mysql/2021-05-01/configurations/method_batchupdate_autorest.go deleted file mode 100644 index db8e7f9f189..00000000000 --- a/resource-manager/mysql/2021-05-01/configurations/method_batchupdate_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package configurations - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type BatchUpdateOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// BatchUpdate ... -func (c ConfigurationsClient) BatchUpdate(ctx context.Context, id FlexibleServerId, input ConfigurationListForBatchUpdate) (result BatchUpdateOperationResponse, err error) { - req, err := c.preparerForBatchUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "configurations.ConfigurationsClient", "BatchUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForBatchUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "configurations.ConfigurationsClient", "BatchUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// BatchUpdateThenPoll performs BatchUpdate then polls until it's completed -func (c ConfigurationsClient) BatchUpdateThenPoll(ctx context.Context, id FlexibleServerId, input ConfigurationListForBatchUpdate) error { - result, err := c.BatchUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing BatchUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after BatchUpdate: %+v", err) - } - - return nil -} - -// preparerForBatchUpdate prepares the BatchUpdate request. -func (c ConfigurationsClient) preparerForBatchUpdate(ctx context.Context, id FlexibleServerId, input ConfigurationListForBatchUpdate) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/updateConfigurations", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForBatchUpdate sends the BatchUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c ConfigurationsClient) senderForBatchUpdate(ctx context.Context, req *http.Request) (future BatchUpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/mysql/2021-05-01/configurations/method_get.go b/resource-manager/mysql/2021-05-01/configurations/method_get.go new file mode 100644 index 00000000000..d9bbfb3ea3d --- /dev/null +++ b/resource-manager/mysql/2021-05-01/configurations/method_get.go @@ -0,0 +1,51 @@ +package configurations + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Configuration +} + +// Get ... +func (c ConfigurationsClient) Get(ctx context.Context, id ConfigurationId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/mysql/2021-05-01/configurations/method_get_autorest.go b/resource-manager/mysql/2021-05-01/configurations/method_get_autorest.go deleted file mode 100644 index 2aeb488f91c..00000000000 --- a/resource-manager/mysql/2021-05-01/configurations/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package configurations - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *Configuration -} - -// Get ... -func (c ConfigurationsClient) Get(ctx context.Context, id ConfigurationId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "configurations.ConfigurationsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "configurations.ConfigurationsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "configurations.ConfigurationsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ConfigurationsClient) preparerForGet(ctx context.Context, id ConfigurationId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c ConfigurationsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/mysql/2021-05-01/configurations/method_listbyserver.go b/resource-manager/mysql/2021-05-01/configurations/method_listbyserver.go new file mode 100644 index 00000000000..3369a4ba43d --- /dev/null +++ b/resource-manager/mysql/2021-05-01/configurations/method_listbyserver.go @@ -0,0 +1,89 @@ +package configurations + +import ( + "context" + "fmt" + "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 ListByServerOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Configuration +} + +type ListByServerCompleteResult struct { + Items []Configuration +} + +// ListByServer ... +func (c ConfigurationsClient) ListByServer(ctx context.Context, id FlexibleServerId) (result ListByServerOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/configurations", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Configuration `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServerComplete retrieves all the results into a single object +func (c ConfigurationsClient) ListByServerComplete(ctx context.Context, id FlexibleServerId) (ListByServerCompleteResult, error) { + return c.ListByServerCompleteMatchingPredicate(ctx, id, ConfigurationOperationPredicate{}) +} + +// ListByServerCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ConfigurationsClient) ListByServerCompleteMatchingPredicate(ctx context.Context, id FlexibleServerId, predicate ConfigurationOperationPredicate) (result ListByServerCompleteResult, err error) { + items := make([]Configuration, 0) + + resp, err := c.ListByServer(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServerCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/mysql/2021-05-01/configurations/method_listbyserver_autorest.go b/resource-manager/mysql/2021-05-01/configurations/method_listbyserver_autorest.go deleted file mode 100644 index 93f2ecccdee..00000000000 --- a/resource-manager/mysql/2021-05-01/configurations/method_listbyserver_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package configurations - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByServerOperationResponse struct { - HttpResponse *http.Response - Model *[]Configuration - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServerOperationResponse, error) -} - -type ListByServerCompleteResult struct { - Items []Configuration -} - -func (r ListByServerOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServerOperationResponse) LoadMore(ctx context.Context) (resp ListByServerOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByServer ... -func (c ConfigurationsClient) ListByServer(ctx context.Context, id FlexibleServerId) (resp ListByServerOperationResponse, err error) { - req, err := c.preparerForListByServer(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "configurations.ConfigurationsClient", "ListByServer", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "configurations.ConfigurationsClient", "ListByServer", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByServer(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "configurations.ConfigurationsClient", "ListByServer", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByServer prepares the ListByServer request. -func (c ConfigurationsClient) preparerForListByServer(ctx context.Context, id FlexibleServerId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/configurations", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServerWithNextLink prepares the ListByServer request with the given nextLink token. -func (c ConfigurationsClient) preparerForListByServerWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByServer handles the response to the ListByServer request. The method always -// closes the http.Response Body. -func (c ConfigurationsClient) responderForListByServer(resp *http.Response) (result ListByServerOperationResponse, err error) { - type page struct { - Values []Configuration `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByServerOperationResponse, err error) { - req, err := c.preparerForListByServerWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "configurations.ConfigurationsClient", "ListByServer", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "configurations.ConfigurationsClient", "ListByServer", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByServer(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "configurations.ConfigurationsClient", "ListByServer", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServerComplete retrieves all of the results into a single object -func (c ConfigurationsClient) ListByServerComplete(ctx context.Context, id FlexibleServerId) (ListByServerCompleteResult, error) { - return c.ListByServerCompleteMatchingPredicate(ctx, id, ConfigurationOperationPredicate{}) -} - -// ListByServerCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ConfigurationsClient) ListByServerCompleteMatchingPredicate(ctx context.Context, id FlexibleServerId, predicate ConfigurationOperationPredicate) (resp ListByServerCompleteResult, err error) { - items := make([]Configuration, 0) - - page, err := c.ListByServer(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServerCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/mysql/2021-05-01/configurations/method_update.go b/resource-manager/mysql/2021-05-01/configurations/method_update.go new file mode 100644 index 00000000000..e9b210b8cbd --- /dev/null +++ b/resource-manager/mysql/2021-05-01/configurations/method_update.go @@ -0,0 +1,74 @@ +package configurations + +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 UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Update ... +func (c ConfigurationsClient) Update(ctx context.Context, id ConfigurationId, input Configuration) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + 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 +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c ConfigurationsClient) UpdateThenPoll(ctx context.Context, id ConfigurationId, input Configuration) error { + result, err := c.Update(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/resource-manager/mysql/2021-05-01/configurations/method_update_autorest.go b/resource-manager/mysql/2021-05-01/configurations/method_update_autorest.go deleted file mode 100644 index 7d79f3dd369..00000000000 --- a/resource-manager/mysql/2021-05-01/configurations/method_update_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package configurations - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Update ... -func (c ConfigurationsClient) Update(ctx context.Context, id ConfigurationId, input Configuration) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "configurations.ConfigurationsClient", "Update", nil, "Failure preparing request") - return - } - - result, err = c.senderForUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "configurations.ConfigurationsClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// UpdateThenPoll performs Update then polls until it's completed -func (c ConfigurationsClient) UpdateThenPoll(ctx context.Context, id ConfigurationId, input Configuration) error { - result, err := c.Update(ctx, id, input) - if err != nil { - return fmt.Errorf("performing Update: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Update: %+v", err) - } - - return nil -} - -// preparerForUpdate prepares the Update request. -func (c ConfigurationsClient) preparerForUpdate(ctx context.Context, id ConfigurationId, input Configuration) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForUpdate sends the Update request. The method will close the -// http.Response Body if it receives an error. -func (c ConfigurationsClient) senderForUpdate(ctx context.Context, req *http.Request) (future UpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/mysql/2021-05-01/databases/client.go b/resource-manager/mysql/2021-05-01/databases/client.go index 5305d65eb6c..bb94a331f78 100644 --- a/resource-manager/mysql/2021-05-01/databases/client.go +++ b/resource-manager/mysql/2021-05-01/databases/client.go @@ -1,18 +1,26 @@ package databases -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 DatabasesClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewDatabasesClientWithBaseURI(endpoint string) DatabasesClient { - return DatabasesClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewDatabasesClientWithBaseURI(api environments.Api) (*DatabasesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "databases", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DatabasesClient: %+v", err) } + + return &DatabasesClient{ + Client: client, + }, nil } diff --git a/resource-manager/mysql/2021-05-01/databases/method_createorupdate.go b/resource-manager/mysql/2021-05-01/databases/method_createorupdate.go new file mode 100644 index 00000000000..6dc4e3e0560 --- /dev/null +++ b/resource-manager/mysql/2021-05-01/databases/method_createorupdate.go @@ -0,0 +1,75 @@ +package databases + +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 +} + +// CreateOrUpdate ... +func (c DatabasesClient) CreateOrUpdate(ctx context.Context, id DatabaseId, input Database) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 DatabasesClient) CreateOrUpdateThenPoll(ctx context.Context, id DatabaseId, input Database) 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 +} diff --git a/resource-manager/mysql/2021-05-01/databases/method_createorupdate_autorest.go b/resource-manager/mysql/2021-05-01/databases/method_createorupdate_autorest.go deleted file mode 100644 index 8046543297d..00000000000 --- a/resource-manager/mysql/2021-05-01/databases/method_createorupdate_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package databases - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateOrUpdate ... -func (c DatabasesClient) CreateOrUpdate(ctx context.Context, id DatabaseId, input Database) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c DatabasesClient) CreateOrUpdateThenPoll(ctx context.Context, id DatabaseId, input Database) error { - result, err := c.CreateOrUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateOrUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateOrUpdate: %+v", err) - } - - return nil -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c DatabasesClient) preparerForCreateOrUpdate(ctx context.Context, id DatabaseId, input Database) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateOrUpdate sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c DatabasesClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/mysql/2021-05-01/databases/method_delete.go b/resource-manager/mysql/2021-05-01/databases/method_delete.go new file mode 100644 index 00000000000..8d10b76fa30 --- /dev/null +++ b/resource-manager/mysql/2021-05-01/databases/method_delete.go @@ -0,0 +1,71 @@ +package databases + +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 DatabasesClient) Delete(ctx context.Context, id DatabaseId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 DatabasesClient) DeleteThenPoll(ctx context.Context, id DatabaseId) 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 +} diff --git a/resource-manager/mysql/2021-05-01/databases/method_delete_autorest.go b/resource-manager/mysql/2021-05-01/databases/method_delete_autorest.go deleted file mode 100644 index 13221da85a6..00000000000 --- a/resource-manager/mysql/2021-05-01/databases/method_delete_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package databases - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// Delete ... -func (c DatabasesClient) Delete(ctx context.Context, id DatabaseId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c DatabasesClient) DeleteThenPoll(ctx context.Context, id DatabaseId) error { - result, err := c.Delete(ctx, id) - if err != nil { - return fmt.Errorf("performing Delete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Delete: %+v", err) - } - - return nil -} - -// preparerForDelete prepares the Delete request. -func (c DatabasesClient) preparerForDelete(ctx context.Context, id DatabaseId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDelete sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (c DatabasesClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/mysql/2021-05-01/databases/method_get.go b/resource-manager/mysql/2021-05-01/databases/method_get.go new file mode 100644 index 00000000000..6f2c4fe3341 --- /dev/null +++ b/resource-manager/mysql/2021-05-01/databases/method_get.go @@ -0,0 +1,51 @@ +package databases + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Database +} + +// Get ... +func (c DatabasesClient) Get(ctx context.Context, id DatabaseId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/mysql/2021-05-01/databases/method_get_autorest.go b/resource-manager/mysql/2021-05-01/databases/method_get_autorest.go deleted file mode 100644 index f35d313d226..00000000000 --- a/resource-manager/mysql/2021-05-01/databases/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package databases - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *Database -} - -// Get ... -func (c DatabasesClient) Get(ctx context.Context, id DatabaseId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c DatabasesClient) preparerForGet(ctx context.Context, id DatabaseId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c DatabasesClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/mysql/2021-05-01/databases/method_listbyserver.go b/resource-manager/mysql/2021-05-01/databases/method_listbyserver.go new file mode 100644 index 00000000000..dca5cb1f346 --- /dev/null +++ b/resource-manager/mysql/2021-05-01/databases/method_listbyserver.go @@ -0,0 +1,89 @@ +package databases + +import ( + "context" + "fmt" + "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 ListByServerOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Database +} + +type ListByServerCompleteResult struct { + Items []Database +} + +// ListByServer ... +func (c DatabasesClient) ListByServer(ctx context.Context, id FlexibleServerId) (result ListByServerOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/databases", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Database `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServerComplete retrieves all the results into a single object +func (c DatabasesClient) ListByServerComplete(ctx context.Context, id FlexibleServerId) (ListByServerCompleteResult, error) { + return c.ListByServerCompleteMatchingPredicate(ctx, id, DatabaseOperationPredicate{}) +} + +// ListByServerCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DatabasesClient) ListByServerCompleteMatchingPredicate(ctx context.Context, id FlexibleServerId, predicate DatabaseOperationPredicate) (result ListByServerCompleteResult, err error) { + items := make([]Database, 0) + + resp, err := c.ListByServer(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServerCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/mysql/2021-05-01/databases/method_listbyserver_autorest.go b/resource-manager/mysql/2021-05-01/databases/method_listbyserver_autorest.go deleted file mode 100644 index 5937f9e8958..00000000000 --- a/resource-manager/mysql/2021-05-01/databases/method_listbyserver_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package databases - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByServerOperationResponse struct { - HttpResponse *http.Response - Model *[]Database - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServerOperationResponse, error) -} - -type ListByServerCompleteResult struct { - Items []Database -} - -func (r ListByServerOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServerOperationResponse) LoadMore(ctx context.Context) (resp ListByServerOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByServer ... -func (c DatabasesClient) ListByServer(ctx context.Context, id FlexibleServerId) (resp ListByServerOperationResponse, err error) { - req, err := c.preparerForListByServer(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "ListByServer", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "ListByServer", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByServer(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "ListByServer", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByServer prepares the ListByServer request. -func (c DatabasesClient) preparerForListByServer(ctx context.Context, id FlexibleServerId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/databases", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServerWithNextLink prepares the ListByServer request with the given nextLink token. -func (c DatabasesClient) preparerForListByServerWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByServer handles the response to the ListByServer request. The method always -// closes the http.Response Body. -func (c DatabasesClient) responderForListByServer(resp *http.Response) (result ListByServerOperationResponse, err error) { - type page struct { - Values []Database `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByServerOperationResponse, err error) { - req, err := c.preparerForListByServerWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "ListByServer", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "ListByServer", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByServer(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "ListByServer", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServerComplete retrieves all of the results into a single object -func (c DatabasesClient) ListByServerComplete(ctx context.Context, id FlexibleServerId) (ListByServerCompleteResult, error) { - return c.ListByServerCompleteMatchingPredicate(ctx, id, DatabaseOperationPredicate{}) -} - -// ListByServerCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c DatabasesClient) ListByServerCompleteMatchingPredicate(ctx context.Context, id FlexibleServerId, predicate DatabaseOperationPredicate) (resp ListByServerCompleteResult, err error) { - items := make([]Database, 0) - - page, err := c.ListByServer(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServerCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/mysql/2021-05-01/firewallrules/client.go b/resource-manager/mysql/2021-05-01/firewallrules/client.go index ac01b0459a1..6493e429eb1 100644 --- a/resource-manager/mysql/2021-05-01/firewallrules/client.go +++ b/resource-manager/mysql/2021-05-01/firewallrules/client.go @@ -1,18 +1,26 @@ package firewallrules -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 FirewallRulesClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewFirewallRulesClientWithBaseURI(endpoint string) FirewallRulesClient { - return FirewallRulesClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewFirewallRulesClientWithBaseURI(api environments.Api) (*FirewallRulesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "firewallrules", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating FirewallRulesClient: %+v", err) } + + return &FirewallRulesClient{ + Client: client, + }, nil } diff --git a/resource-manager/mysql/2021-05-01/firewallrules/method_createorupdate.go b/resource-manager/mysql/2021-05-01/firewallrules/method_createorupdate.go new file mode 100644 index 00000000000..dc64d3809d0 --- /dev/null +++ b/resource-manager/mysql/2021-05-01/firewallrules/method_createorupdate.go @@ -0,0 +1,75 @@ +package firewallrules + +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 +} + +// CreateOrUpdate ... +func (c FirewallRulesClient) CreateOrUpdate(ctx context.Context, id FirewallRuleId, input FirewallRule) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 FirewallRulesClient) CreateOrUpdateThenPoll(ctx context.Context, id FirewallRuleId, input FirewallRule) 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 +} diff --git a/resource-manager/mysql/2021-05-01/firewallrules/method_createorupdate_autorest.go b/resource-manager/mysql/2021-05-01/firewallrules/method_createorupdate_autorest.go deleted file mode 100644 index 0dfa761f1a0..00000000000 --- a/resource-manager/mysql/2021-05-01/firewallrules/method_createorupdate_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package firewallrules - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateOrUpdate ... -func (c FirewallRulesClient) CreateOrUpdate(ctx context.Context, id FirewallRuleId, input FirewallRule) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "firewallrules.FirewallRulesClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "firewallrules.FirewallRulesClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c FirewallRulesClient) CreateOrUpdateThenPoll(ctx context.Context, id FirewallRuleId, input FirewallRule) error { - result, err := c.CreateOrUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateOrUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateOrUpdate: %+v", err) - } - - return nil -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c FirewallRulesClient) preparerForCreateOrUpdate(ctx context.Context, id FirewallRuleId, input FirewallRule) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateOrUpdate sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c FirewallRulesClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/mysql/2021-05-01/firewallrules/method_delete.go b/resource-manager/mysql/2021-05-01/firewallrules/method_delete.go new file mode 100644 index 00000000000..0b8a33693c0 --- /dev/null +++ b/resource-manager/mysql/2021-05-01/firewallrules/method_delete.go @@ -0,0 +1,71 @@ +package firewallrules + +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 FirewallRulesClient) Delete(ctx context.Context, id FirewallRuleId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 FirewallRulesClient) DeleteThenPoll(ctx context.Context, id FirewallRuleId) 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 +} diff --git a/resource-manager/mysql/2021-05-01/firewallrules/method_delete_autorest.go b/resource-manager/mysql/2021-05-01/firewallrules/method_delete_autorest.go deleted file mode 100644 index ec4b290ecdd..00000000000 --- a/resource-manager/mysql/2021-05-01/firewallrules/method_delete_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package firewallrules - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// Delete ... -func (c FirewallRulesClient) Delete(ctx context.Context, id FirewallRuleId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "firewallrules.FirewallRulesClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "firewallrules.FirewallRulesClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c FirewallRulesClient) DeleteThenPoll(ctx context.Context, id FirewallRuleId) error { - result, err := c.Delete(ctx, id) - if err != nil { - return fmt.Errorf("performing Delete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Delete: %+v", err) - } - - return nil -} - -// preparerForDelete prepares the Delete request. -func (c FirewallRulesClient) preparerForDelete(ctx context.Context, id FirewallRuleId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDelete sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (c FirewallRulesClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/mysql/2021-05-01/firewallrules/method_get.go b/resource-manager/mysql/2021-05-01/firewallrules/method_get.go new file mode 100644 index 00000000000..f14c6b31f8d --- /dev/null +++ b/resource-manager/mysql/2021-05-01/firewallrules/method_get.go @@ -0,0 +1,51 @@ +package firewallrules + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *FirewallRule +} + +// Get ... +func (c FirewallRulesClient) Get(ctx context.Context, id FirewallRuleId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/mysql/2021-05-01/firewallrules/method_get_autorest.go b/resource-manager/mysql/2021-05-01/firewallrules/method_get_autorest.go deleted file mode 100644 index 1391c01ba1a..00000000000 --- a/resource-manager/mysql/2021-05-01/firewallrules/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package firewallrules - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *FirewallRule -} - -// Get ... -func (c FirewallRulesClient) Get(ctx context.Context, id FirewallRuleId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "firewallrules.FirewallRulesClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "firewallrules.FirewallRulesClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "firewallrules.FirewallRulesClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c FirewallRulesClient) preparerForGet(ctx context.Context, id FirewallRuleId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c FirewallRulesClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/mysql/2021-05-01/firewallrules/method_listbyserver.go b/resource-manager/mysql/2021-05-01/firewallrules/method_listbyserver.go new file mode 100644 index 00000000000..e187720f151 --- /dev/null +++ b/resource-manager/mysql/2021-05-01/firewallrules/method_listbyserver.go @@ -0,0 +1,89 @@ +package firewallrules + +import ( + "context" + "fmt" + "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 ListByServerOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]FirewallRule +} + +type ListByServerCompleteResult struct { + Items []FirewallRule +} + +// ListByServer ... +func (c FirewallRulesClient) ListByServer(ctx context.Context, id FlexibleServerId) (result ListByServerOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/firewallRules", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]FirewallRule `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServerComplete retrieves all the results into a single object +func (c FirewallRulesClient) ListByServerComplete(ctx context.Context, id FlexibleServerId) (ListByServerCompleteResult, error) { + return c.ListByServerCompleteMatchingPredicate(ctx, id, FirewallRuleOperationPredicate{}) +} + +// ListByServerCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c FirewallRulesClient) ListByServerCompleteMatchingPredicate(ctx context.Context, id FlexibleServerId, predicate FirewallRuleOperationPredicate) (result ListByServerCompleteResult, err error) { + items := make([]FirewallRule, 0) + + resp, err := c.ListByServer(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServerCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/mysql/2021-05-01/firewallrules/method_listbyserver_autorest.go b/resource-manager/mysql/2021-05-01/firewallrules/method_listbyserver_autorest.go deleted file mode 100644 index 82fe51aed30..00000000000 --- a/resource-manager/mysql/2021-05-01/firewallrules/method_listbyserver_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package firewallrules - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByServerOperationResponse struct { - HttpResponse *http.Response - Model *[]FirewallRule - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServerOperationResponse, error) -} - -type ListByServerCompleteResult struct { - Items []FirewallRule -} - -func (r ListByServerOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServerOperationResponse) LoadMore(ctx context.Context) (resp ListByServerOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByServer ... -func (c FirewallRulesClient) ListByServer(ctx context.Context, id FlexibleServerId) (resp ListByServerOperationResponse, err error) { - req, err := c.preparerForListByServer(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "firewallrules.FirewallRulesClient", "ListByServer", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "firewallrules.FirewallRulesClient", "ListByServer", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByServer(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "firewallrules.FirewallRulesClient", "ListByServer", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByServer prepares the ListByServer request. -func (c FirewallRulesClient) preparerForListByServer(ctx context.Context, id FlexibleServerId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/firewallRules", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServerWithNextLink prepares the ListByServer request with the given nextLink token. -func (c FirewallRulesClient) preparerForListByServerWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByServer handles the response to the ListByServer request. The method always -// closes the http.Response Body. -func (c FirewallRulesClient) responderForListByServer(resp *http.Response) (result ListByServerOperationResponse, err error) { - type page struct { - Values []FirewallRule `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByServerOperationResponse, err error) { - req, err := c.preparerForListByServerWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "firewallrules.FirewallRulesClient", "ListByServer", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "firewallrules.FirewallRulesClient", "ListByServer", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByServer(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "firewallrules.FirewallRulesClient", "ListByServer", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServerComplete retrieves all of the results into a single object -func (c FirewallRulesClient) ListByServerComplete(ctx context.Context, id FlexibleServerId) (ListByServerCompleteResult, error) { - return c.ListByServerCompleteMatchingPredicate(ctx, id, FirewallRuleOperationPredicate{}) -} - -// ListByServerCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c FirewallRulesClient) ListByServerCompleteMatchingPredicate(ctx context.Context, id FlexibleServerId, predicate FirewallRuleOperationPredicate) (resp ListByServerCompleteResult, err error) { - items := make([]FirewallRule, 0) - - page, err := c.ListByServer(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServerCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/mysql/2021-05-01/getprivatednszonesuffix/client.go b/resource-manager/mysql/2021-05-01/getprivatednszonesuffix/client.go index ce9cceb6b9a..39cc68bc144 100644 --- a/resource-manager/mysql/2021-05-01/getprivatednszonesuffix/client.go +++ b/resource-manager/mysql/2021-05-01/getprivatednszonesuffix/client.go @@ -1,18 +1,26 @@ package getprivatednszonesuffix -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 GetPrivateDnsZoneSuffixClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewGetPrivateDnsZoneSuffixClientWithBaseURI(endpoint string) GetPrivateDnsZoneSuffixClient { - return GetPrivateDnsZoneSuffixClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewGetPrivateDnsZoneSuffixClientWithBaseURI(api environments.Api) (*GetPrivateDnsZoneSuffixClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "getprivatednszonesuffix", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating GetPrivateDnsZoneSuffixClient: %+v", err) } + + return &GetPrivateDnsZoneSuffixClient{ + Client: client, + }, nil } diff --git a/resource-manager/mysql/2021-05-01/getprivatednszonesuffix/method_execute.go b/resource-manager/mysql/2021-05-01/getprivatednszonesuffix/method_execute.go new file mode 100644 index 00000000000..f00af054dec --- /dev/null +++ b/resource-manager/mysql/2021-05-01/getprivatednszonesuffix/method_execute.go @@ -0,0 +1,51 @@ +package getprivatednszonesuffix + +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 ExecuteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *GetPrivateDnsZoneSuffixResponse +} + +// Execute ... +func (c GetPrivateDnsZoneSuffixClient) Execute(ctx context.Context) (result ExecuteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: "/providers/Microsoft.DBforMySQL/getPrivateDnsZoneSuffix", + } + + 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 +} diff --git a/resource-manager/mysql/2021-05-01/getprivatednszonesuffix/method_execute_autorest.go b/resource-manager/mysql/2021-05-01/getprivatednszonesuffix/method_execute_autorest.go deleted file mode 100644 index e8091abed30..00000000000 --- a/resource-manager/mysql/2021-05-01/getprivatednszonesuffix/method_execute_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package getprivatednszonesuffix - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ExecuteOperationResponse struct { - HttpResponse *http.Response - Model *GetPrivateDnsZoneSuffixResponse -} - -// Execute ... -func (c GetPrivateDnsZoneSuffixClient) Execute(ctx context.Context) (result ExecuteOperationResponse, err error) { - req, err := c.preparerForExecute(ctx) - if err != nil { - err = autorest.NewErrorWithError(err, "getprivatednszonesuffix.GetPrivateDnsZoneSuffixClient", "Execute", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "getprivatednszonesuffix.GetPrivateDnsZoneSuffixClient", "Execute", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForExecute(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "getprivatednszonesuffix.GetPrivateDnsZoneSuffixClient", "Execute", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForExecute prepares the Execute request. -func (c GetPrivateDnsZoneSuffixClient) preparerForExecute(ctx context.Context) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath("/providers/Microsoft.DBforMySQL/getPrivateDnsZoneSuffix"), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForExecute handles the response to the Execute request. The method always -// closes the http.Response Body. -func (c GetPrivateDnsZoneSuffixClient) responderForExecute(resp *http.Response) (result ExecuteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/mysql/2021-05-01/locationbasedcapabilities/client.go b/resource-manager/mysql/2021-05-01/locationbasedcapabilities/client.go index 7c8f88e30d1..c7ed45f57a6 100644 --- a/resource-manager/mysql/2021-05-01/locationbasedcapabilities/client.go +++ b/resource-manager/mysql/2021-05-01/locationbasedcapabilities/client.go @@ -1,18 +1,26 @@ package locationbasedcapabilities -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 LocationBasedCapabilitiesClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewLocationBasedCapabilitiesClientWithBaseURI(endpoint string) LocationBasedCapabilitiesClient { - return LocationBasedCapabilitiesClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewLocationBasedCapabilitiesClientWithBaseURI(api environments.Api) (*LocationBasedCapabilitiesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "locationbasedcapabilities", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating LocationBasedCapabilitiesClient: %+v", err) } + + return &LocationBasedCapabilitiesClient{ + Client: client, + }, nil } diff --git a/resource-manager/mysql/2021-05-01/locationbasedcapabilities/method_list.go b/resource-manager/mysql/2021-05-01/locationbasedcapabilities/method_list.go new file mode 100644 index 00000000000..34b87056703 --- /dev/null +++ b/resource-manager/mysql/2021-05-01/locationbasedcapabilities/method_list.go @@ -0,0 +1,89 @@ +package locationbasedcapabilities + +import ( + "context" + "fmt" + "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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CapabilityProperties +} + +type ListCompleteResult struct { + Items []CapabilityProperties +} + +// List ... +func (c LocationBasedCapabilitiesClient) List(ctx context.Context, id LocationId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/capabilities", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]CapabilityProperties `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c LocationBasedCapabilitiesClient) ListComplete(ctx context.Context, id LocationId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, CapabilityPropertiesOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c LocationBasedCapabilitiesClient) ListCompleteMatchingPredicate(ctx context.Context, id LocationId, predicate CapabilityPropertiesOperationPredicate) (result ListCompleteResult, err error) { + items := make([]CapabilityProperties, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/mysql/2021-05-01/locationbasedcapabilities/method_list_autorest.go b/resource-manager/mysql/2021-05-01/locationbasedcapabilities/method_list_autorest.go deleted file mode 100644 index 0d25a07068a..00000000000 --- a/resource-manager/mysql/2021-05-01/locationbasedcapabilities/method_list_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package locationbasedcapabilities - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListOperationResponse struct { - HttpResponse *http.Response - Model *[]CapabilityProperties - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []CapabilityProperties -} - -func (r ListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// List ... -func (c LocationBasedCapabilitiesClient) List(ctx context.Context, id LocationId) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "locationbasedcapabilities.LocationBasedCapabilitiesClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "locationbasedcapabilities.LocationBasedCapabilitiesClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "locationbasedcapabilities.LocationBasedCapabilitiesClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c LocationBasedCapabilitiesClient) preparerForList(ctx context.Context, id LocationId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/capabilities", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c LocationBasedCapabilitiesClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForList handles the response to the List request. The method always -// closes the http.Response Body. -func (c LocationBasedCapabilitiesClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []CapabilityProperties `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { - req, err := c.preparerForListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "locationbasedcapabilities.LocationBasedCapabilitiesClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "locationbasedcapabilities.LocationBasedCapabilitiesClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "locationbasedcapabilities.LocationBasedCapabilitiesClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c LocationBasedCapabilitiesClient) ListComplete(ctx context.Context, id LocationId) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, CapabilityPropertiesOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c LocationBasedCapabilitiesClient) ListCompleteMatchingPredicate(ctx context.Context, id LocationId, predicate CapabilityPropertiesOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]CapabilityProperties, 0) - - page, err := c.List(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/mysql/2021-05-01/serverfailover/client.go b/resource-manager/mysql/2021-05-01/serverfailover/client.go index f723c8a149d..d90a9229592 100644 --- a/resource-manager/mysql/2021-05-01/serverfailover/client.go +++ b/resource-manager/mysql/2021-05-01/serverfailover/client.go @@ -1,18 +1,26 @@ package serverfailover -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 ServerFailoverClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewServerFailoverClientWithBaseURI(endpoint string) ServerFailoverClient { - return ServerFailoverClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewServerFailoverClientWithBaseURI(api environments.Api) (*ServerFailoverClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "serverfailover", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ServerFailoverClient: %+v", err) } + + return &ServerFailoverClient{ + Client: client, + }, nil } diff --git a/resource-manager/mysql/2021-05-01/serverfailover/method_serversfailover.go b/resource-manager/mysql/2021-05-01/serverfailover/method_serversfailover.go new file mode 100644 index 00000000000..aa31c631dd0 --- /dev/null +++ b/resource-manager/mysql/2021-05-01/serverfailover/method_serversfailover.go @@ -0,0 +1,70 @@ +package serverfailover + +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 ServersFailoverOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ServersFailover ... +func (c ServerFailoverClient) ServersFailover(ctx context.Context, id FlexibleServerId) (result ServersFailoverOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/failover", 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 +} + +// ServersFailoverThenPoll performs ServersFailover then polls until it's completed +func (c ServerFailoverClient) ServersFailoverThenPoll(ctx context.Context, id FlexibleServerId) error { + result, err := c.ServersFailover(ctx, id) + if err != nil { + return fmt.Errorf("performing ServersFailover: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ServersFailover: %+v", err) + } + + return nil +} diff --git a/resource-manager/mysql/2021-05-01/serverfailover/method_serversfailover_autorest.go b/resource-manager/mysql/2021-05-01/serverfailover/method_serversfailover_autorest.go deleted file mode 100644 index a3d79cc5efa..00000000000 --- a/resource-manager/mysql/2021-05-01/serverfailover/method_serversfailover_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package serverfailover - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ServersFailoverOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// ServersFailover ... -func (c ServerFailoverClient) ServersFailover(ctx context.Context, id FlexibleServerId) (result ServersFailoverOperationResponse, err error) { - req, err := c.preparerForServersFailover(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "serverfailover.ServerFailoverClient", "ServersFailover", nil, "Failure preparing request") - return - } - - result, err = c.senderForServersFailover(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "serverfailover.ServerFailoverClient", "ServersFailover", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// ServersFailoverThenPoll performs ServersFailover then polls until it's completed -func (c ServerFailoverClient) ServersFailoverThenPoll(ctx context.Context, id FlexibleServerId) error { - result, err := c.ServersFailover(ctx, id) - if err != nil { - return fmt.Errorf("performing ServersFailover: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after ServersFailover: %+v", err) - } - - return nil -} - -// preparerForServersFailover prepares the ServersFailover request. -func (c ServerFailoverClient) preparerForServersFailover(ctx context.Context, id FlexibleServerId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/failover", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForServersFailover sends the ServersFailover request. The method will close the -// http.Response Body if it receives an error. -func (c ServerFailoverClient) senderForServersFailover(ctx context.Context, req *http.Request) (future ServersFailoverOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/mysql/2021-05-01/serverrestart/client.go b/resource-manager/mysql/2021-05-01/serverrestart/client.go index 7e3313f4726..dda19ef0b54 100644 --- a/resource-manager/mysql/2021-05-01/serverrestart/client.go +++ b/resource-manager/mysql/2021-05-01/serverrestart/client.go @@ -1,18 +1,26 @@ package serverrestart -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 ServerRestartClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewServerRestartClientWithBaseURI(endpoint string) ServerRestartClient { - return ServerRestartClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewServerRestartClientWithBaseURI(api environments.Api) (*ServerRestartClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "serverrestart", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ServerRestartClient: %+v", err) } + + return &ServerRestartClient{ + Client: client, + }, nil } diff --git a/resource-manager/mysql/2021-05-01/serverrestart/constants.go b/resource-manager/mysql/2021-05-01/serverrestart/constants.go index 136ece086bc..0ce79f8aedc 100644 --- a/resource-manager/mysql/2021-05-01/serverrestart/constants.go +++ b/resource-manager/mysql/2021-05-01/serverrestart/constants.go @@ -1,6 +1,10 @@ package serverrestart -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. @@ -19,6 +23,19 @@ func PossibleValuesForEnableStatusEnum() []string { } } +func (s *EnableStatusEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEnableStatusEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseEnableStatusEnum(input string) (*EnableStatusEnum, error) { vals := map[string]EnableStatusEnum{ "disabled": EnableStatusEnumDisabled, diff --git a/resource-manager/mysql/2021-05-01/serverrestart/method_serversrestart.go b/resource-manager/mysql/2021-05-01/serverrestart/method_serversrestart.go new file mode 100644 index 00000000000..8954c04f305 --- /dev/null +++ b/resource-manager/mysql/2021-05-01/serverrestart/method_serversrestart.go @@ -0,0 +1,74 @@ +package serverrestart + +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 ServersRestartOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ServersRestart ... +func (c ServerRestartClient) ServersRestart(ctx context.Context, id FlexibleServerId, input ServerRestartParameter) (result ServersRestartOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restart", 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 +} + +// ServersRestartThenPoll performs ServersRestart then polls until it's completed +func (c ServerRestartClient) ServersRestartThenPoll(ctx context.Context, id FlexibleServerId, input ServerRestartParameter) error { + result, err := c.ServersRestart(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ServersRestart: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ServersRestart: %+v", err) + } + + return nil +} diff --git a/resource-manager/mysql/2021-05-01/serverrestart/method_serversrestart_autorest.go b/resource-manager/mysql/2021-05-01/serverrestart/method_serversrestart_autorest.go deleted file mode 100644 index c0c843cd1e2..00000000000 --- a/resource-manager/mysql/2021-05-01/serverrestart/method_serversrestart_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package serverrestart - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ServersRestartOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// ServersRestart ... -func (c ServerRestartClient) ServersRestart(ctx context.Context, id FlexibleServerId, input ServerRestartParameter) (result ServersRestartOperationResponse, err error) { - req, err := c.preparerForServersRestart(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "serverrestart.ServerRestartClient", "ServersRestart", nil, "Failure preparing request") - return - } - - result, err = c.senderForServersRestart(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "serverrestart.ServerRestartClient", "ServersRestart", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// ServersRestartThenPoll performs ServersRestart then polls until it's completed -func (c ServerRestartClient) ServersRestartThenPoll(ctx context.Context, id FlexibleServerId, input ServerRestartParameter) error { - result, err := c.ServersRestart(ctx, id, input) - if err != nil { - return fmt.Errorf("performing ServersRestart: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after ServersRestart: %+v", err) - } - - return nil -} - -// preparerForServersRestart prepares the ServersRestart request. -func (c ServerRestartClient) preparerForServersRestart(ctx context.Context, id FlexibleServerId, input ServerRestartParameter) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/restart", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForServersRestart sends the ServersRestart request. The method will close the -// http.Response Body if it receives an error. -func (c ServerRestartClient) senderForServersRestart(ctx context.Context, req *http.Request) (future ServersRestartOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/mysql/2021-05-01/servers/client.go b/resource-manager/mysql/2021-05-01/servers/client.go index fd9e02ba599..a1e11668771 100644 --- a/resource-manager/mysql/2021-05-01/servers/client.go +++ b/resource-manager/mysql/2021-05-01/servers/client.go @@ -1,18 +1,26 @@ package servers -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 ServersClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewServersClientWithBaseURI(endpoint string) ServersClient { - return ServersClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewServersClientWithBaseURI(api environments.Api) (*ServersClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "servers", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ServersClient: %+v", err) } + + return &ServersClient{ + Client: client, + }, nil } diff --git a/resource-manager/mysql/2021-05-01/servers/constants.go b/resource-manager/mysql/2021-05-01/servers/constants.go index 9c01b32c11d..38f0dee4a21 100644 --- a/resource-manager/mysql/2021-05-01/servers/constants.go +++ b/resource-manager/mysql/2021-05-01/servers/constants.go @@ -1,6 +1,10 @@ package servers -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. @@ -23,6 +27,19 @@ func PossibleValuesForCreateMode() []string { } } +func (s *CreateMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCreateMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseCreateMode(input string) (*CreateMode, error) { vals := map[string]CreateMode{ "default": CreateModeDefault, @@ -53,6 +70,19 @@ func PossibleValuesForDataEncryptionType() []string { } } +func (s *DataEncryptionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDataEncryptionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseDataEncryptionType(input string) (*DataEncryptionType, error) { vals := map[string]DataEncryptionType{ "azurekeyvault": DataEncryptionTypeAzureKeyVault, @@ -81,6 +111,19 @@ func PossibleValuesForEnableStatusEnum() []string { } } +func (s *EnableStatusEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEnableStatusEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseEnableStatusEnum(input string) (*EnableStatusEnum, error) { vals := map[string]EnableStatusEnum{ "disabled": EnableStatusEnumDisabled, @@ -111,6 +154,19 @@ func PossibleValuesForHighAvailabilityMode() []string { } } +func (s *HighAvailabilityMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHighAvailabilityMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseHighAvailabilityMode(input string) (*HighAvailabilityMode, error) { vals := map[string]HighAvailabilityMode{ "disabled": HighAvailabilityModeDisabled, @@ -146,6 +202,19 @@ func PossibleValuesForHighAvailabilityState() []string { } } +func (s *HighAvailabilityState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHighAvailabilityState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseHighAvailabilityState(input string) (*HighAvailabilityState, error) { vals := map[string]HighAvailabilityState{ "creatingstandby": HighAvailabilityStateCreatingStandby, @@ -175,6 +244,19 @@ func PossibleValuesForManagedServiceIdentityType() []string { } } +func (s *ManagedServiceIdentityType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedServiceIdentityType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseManagedServiceIdentityType(input string) (*ManagedServiceIdentityType, error) { vals := map[string]ManagedServiceIdentityType{ "userassigned": ManagedServiceIdentityTypeUserAssigned, @@ -204,6 +286,19 @@ func PossibleValuesForReplicationRole() []string { } } +func (s *ReplicationRole) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseReplicationRole(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseReplicationRole(input string) (*ReplicationRole, error) { vals := map[string]ReplicationRole{ "none": ReplicationRoleNone, @@ -243,6 +338,19 @@ func PossibleValuesForServerState() []string { } } +func (s *ServerState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServerState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseServerState(input string) (*ServerState, error) { vals := map[string]ServerState{ "disabled": ServerStateDisabled, @@ -276,6 +384,19 @@ func PossibleValuesForServerVersion() []string { } } +func (s *ServerVersion) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServerVersion(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseServerVersion(input string) (*ServerVersion, error) { vals := map[string]ServerVersion{ "8.0.21": ServerVersionEightPointZeroPointTwoOne, @@ -306,6 +427,19 @@ func PossibleValuesForSkuTier() []string { } } +func (s *SkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseSkuTier(input string) (*SkuTier, error) { vals := map[string]SkuTier{ "burstable": SkuTierBurstable, diff --git a/resource-manager/mysql/2021-05-01/servers/method_create.go b/resource-manager/mysql/2021-05-01/servers/method_create.go new file mode 100644 index 00000000000..7d5c992b539 --- /dev/null +++ b/resource-manager/mysql/2021-05-01/servers/method_create.go @@ -0,0 +1,75 @@ +package servers + +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 CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Create ... +func (c ServersClient) Create(ctx context.Context, id FlexibleServerId, input Server) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c ServersClient) CreateThenPoll(ctx context.Context, id FlexibleServerId, input Server) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/mysql/2021-05-01/servers/method_create_autorest.go b/resource-manager/mysql/2021-05-01/servers/method_create_autorest.go deleted file mode 100644 index f7cd73566e6..00000000000 --- a/resource-manager/mysql/2021-05-01/servers/method_create_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package servers - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Create ... -func (c ServersClient) Create(ctx context.Context, id FlexibleServerId, input Server) (result CreateOperationResponse, err error) { - req, err := c.preparerForCreate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "Create", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "Create", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateThenPoll performs Create then polls until it's completed -func (c ServersClient) CreateThenPoll(ctx context.Context, id FlexibleServerId, input Server) error { - result, err := c.Create(ctx, id, input) - if err != nil { - return fmt.Errorf("performing Create: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Create: %+v", err) - } - - return nil -} - -// preparerForCreate prepares the Create request. -func (c ServersClient) preparerForCreate(ctx context.Context, id FlexibleServerId, input Server) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreate sends the Create request. The method will close the -// http.Response Body if it receives an error. -func (c ServersClient) senderForCreate(ctx context.Context, req *http.Request) (future CreateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/mysql/2021-05-01/servers/method_delete.go b/resource-manager/mysql/2021-05-01/servers/method_delete.go new file mode 100644 index 00000000000..c2dab4be6e1 --- /dev/null +++ b/resource-manager/mysql/2021-05-01/servers/method_delete.go @@ -0,0 +1,71 @@ +package servers + +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 ServersClient) Delete(ctx context.Context, id FlexibleServerId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 ServersClient) DeleteThenPoll(ctx context.Context, id FlexibleServerId) 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 +} diff --git a/resource-manager/mysql/2021-05-01/servers/method_delete_autorest.go b/resource-manager/mysql/2021-05-01/servers/method_delete_autorest.go deleted file mode 100644 index d05fd1a076a..00000000000 --- a/resource-manager/mysql/2021-05-01/servers/method_delete_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package servers - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// Delete ... -func (c ServersClient) Delete(ctx context.Context, id FlexibleServerId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c ServersClient) DeleteThenPoll(ctx context.Context, id FlexibleServerId) error { - result, err := c.Delete(ctx, id) - if err != nil { - return fmt.Errorf("performing Delete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Delete: %+v", err) - } - - return nil -} - -// preparerForDelete prepares the Delete request. -func (c ServersClient) preparerForDelete(ctx context.Context, id FlexibleServerId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDelete sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (c ServersClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/mysql/2021-05-01/servers/method_get.go b/resource-manager/mysql/2021-05-01/servers/method_get.go new file mode 100644 index 00000000000..7ec2c3f3db3 --- /dev/null +++ b/resource-manager/mysql/2021-05-01/servers/method_get.go @@ -0,0 +1,51 @@ +package servers + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Server +} + +// Get ... +func (c ServersClient) Get(ctx context.Context, id FlexibleServerId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/mysql/2021-05-01/servers/method_get_autorest.go b/resource-manager/mysql/2021-05-01/servers/method_get_autorest.go deleted file mode 100644 index bb0074a3085..00000000000 --- a/resource-manager/mysql/2021-05-01/servers/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package servers - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *Server -} - -// Get ... -func (c ServersClient) Get(ctx context.Context, id FlexibleServerId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ServersClient) preparerForGet(ctx context.Context, id FlexibleServerId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c ServersClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/mysql/2021-05-01/servers/method_list.go b/resource-manager/mysql/2021-05-01/servers/method_list.go new file mode 100644 index 00000000000..50c7b1709d1 --- /dev/null +++ b/resource-manager/mysql/2021-05-01/servers/method_list.go @@ -0,0 +1,90 @@ +package servers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Server +} + +type ListCompleteResult struct { + Items []Server +} + +// List ... +func (c ServersClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.DBforMySQL/flexibleServers", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Server `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ServersClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, ServerOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ServersClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ServerOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Server, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/mysql/2021-05-01/servers/method_list_autorest.go b/resource-manager/mysql/2021-05-01/servers/method_list_autorest.go deleted file mode 100644 index fb15e88ae69..00000000000 --- a/resource-manager/mysql/2021-05-01/servers/method_list_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package servers - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListOperationResponse struct { - HttpResponse *http.Response - Model *[]Server - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []Server -} - -func (r ListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// List ... -func (c ServersClient) List(ctx context.Context, id commonids.SubscriptionId) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c ServersClient) preparerForList(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.DBforMySQL/flexibleServers", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c ServersClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForList handles the response to the List request. The method always -// closes the http.Response Body. -func (c ServersClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []Server `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { - req, err := c.preparerForListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c ServersClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, ServerOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ServersClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ServerOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]Server, 0) - - page, err := c.List(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/mysql/2021-05-01/servers/method_listbyresourcegroup.go b/resource-manager/mysql/2021-05-01/servers/method_listbyresourcegroup.go new file mode 100644 index 00000000000..d7037bf20b2 --- /dev/null +++ b/resource-manager/mysql/2021-05-01/servers/method_listbyresourcegroup.go @@ -0,0 +1,90 @@ +package servers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Server +} + +type ListByResourceGroupCompleteResult struct { + Items []Server +} + +// ListByResourceGroup ... +func (c ServersClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.DBforMySQL/flexibleServers", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Server `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c ServersClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, ServerOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ServersClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ServerOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]Server, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/mysql/2021-05-01/servers/method_listbyresourcegroup_autorest.go b/resource-manager/mysql/2021-05-01/servers/method_listbyresourcegroup_autorest.go deleted file mode 100644 index 6d0822e633f..00000000000 --- a/resource-manager/mysql/2021-05-01/servers/method_listbyresourcegroup_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package servers - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByResourceGroupOperationResponse struct { - HttpResponse *http.Response - Model *[]Server - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByResourceGroupOperationResponse, error) -} - -type ListByResourceGroupCompleteResult struct { - Items []Server -} - -func (r ListByResourceGroupOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByResourceGroupOperationResponse) LoadMore(ctx context.Context) (resp ListByResourceGroupOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByResourceGroup ... -func (c ServersClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (resp ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroup(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "ListByResourceGroup", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByResourceGroup(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "ListByResourceGroup", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByResourceGroup prepares the ListByResourceGroup request. -func (c ServersClient) preparerForListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.DBforMySQL/flexibleServers", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByResourceGroupWithNextLink prepares the ListByResourceGroup request with the given nextLink token. -func (c ServersClient) preparerForListByResourceGroupWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByResourceGroup handles the response to the ListByResourceGroup request. The method always -// closes the http.Response Body. -func (c ServersClient) responderForListByResourceGroup(resp *http.Response) (result ListByResourceGroupOperationResponse, err error) { - type page struct { - Values []Server `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroupWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "ListByResourceGroup", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByResourceGroup(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "ListByResourceGroup", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByResourceGroupComplete retrieves all of the results into a single object -func (c ServersClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { - return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, ServerOperationPredicate{}) -} - -// ListByResourceGroupCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ServersClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ServerOperationPredicate) (resp ListByResourceGroupCompleteResult, err error) { - items := make([]Server, 0) - - page, err := c.ListByResourceGroup(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByResourceGroupCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/mysql/2021-05-01/servers/method_replicaslistbyserver.go b/resource-manager/mysql/2021-05-01/servers/method_replicaslistbyserver.go new file mode 100644 index 00000000000..91d61596f4f --- /dev/null +++ b/resource-manager/mysql/2021-05-01/servers/method_replicaslistbyserver.go @@ -0,0 +1,89 @@ +package servers + +import ( + "context" + "fmt" + "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 ReplicasListByServerOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Server +} + +type ReplicasListByServerCompleteResult struct { + Items []Server +} + +// ReplicasListByServer ... +func (c ServersClient) ReplicasListByServer(ctx context.Context, id FlexibleServerId) (result ReplicasListByServerOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/replicas", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Server `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ReplicasListByServerComplete retrieves all the results into a single object +func (c ServersClient) ReplicasListByServerComplete(ctx context.Context, id FlexibleServerId) (ReplicasListByServerCompleteResult, error) { + return c.ReplicasListByServerCompleteMatchingPredicate(ctx, id, ServerOperationPredicate{}) +} + +// ReplicasListByServerCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ServersClient) ReplicasListByServerCompleteMatchingPredicate(ctx context.Context, id FlexibleServerId, predicate ServerOperationPredicate) (result ReplicasListByServerCompleteResult, err error) { + items := make([]Server, 0) + + resp, err := c.ReplicasListByServer(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ReplicasListByServerCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/mysql/2021-05-01/servers/method_replicaslistbyserver_autorest.go b/resource-manager/mysql/2021-05-01/servers/method_replicaslistbyserver_autorest.go deleted file mode 100644 index c0bf40cf8b3..00000000000 --- a/resource-manager/mysql/2021-05-01/servers/method_replicaslistbyserver_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package servers - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ReplicasListByServerOperationResponse struct { - HttpResponse *http.Response - Model *[]Server - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ReplicasListByServerOperationResponse, error) -} - -type ReplicasListByServerCompleteResult struct { - Items []Server -} - -func (r ReplicasListByServerOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ReplicasListByServerOperationResponse) LoadMore(ctx context.Context) (resp ReplicasListByServerOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ReplicasListByServer ... -func (c ServersClient) ReplicasListByServer(ctx context.Context, id FlexibleServerId) (resp ReplicasListByServerOperationResponse, err error) { - req, err := c.preparerForReplicasListByServer(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "ReplicasListByServer", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "ReplicasListByServer", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForReplicasListByServer(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "ReplicasListByServer", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForReplicasListByServer prepares the ReplicasListByServer request. -func (c ServersClient) preparerForReplicasListByServer(ctx context.Context, id FlexibleServerId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/replicas", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForReplicasListByServerWithNextLink prepares the ReplicasListByServer request with the given nextLink token. -func (c ServersClient) preparerForReplicasListByServerWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForReplicasListByServer handles the response to the ReplicasListByServer request. The method always -// closes the http.Response Body. -func (c ServersClient) responderForReplicasListByServer(resp *http.Response) (result ReplicasListByServerOperationResponse, err error) { - type page struct { - Values []Server `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ReplicasListByServerOperationResponse, err error) { - req, err := c.preparerForReplicasListByServerWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "ReplicasListByServer", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "ReplicasListByServer", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForReplicasListByServer(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "ReplicasListByServer", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ReplicasListByServerComplete retrieves all of the results into a single object -func (c ServersClient) ReplicasListByServerComplete(ctx context.Context, id FlexibleServerId) (ReplicasListByServerCompleteResult, error) { - return c.ReplicasListByServerCompleteMatchingPredicate(ctx, id, ServerOperationPredicate{}) -} - -// ReplicasListByServerCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ServersClient) ReplicasListByServerCompleteMatchingPredicate(ctx context.Context, id FlexibleServerId, predicate ServerOperationPredicate) (resp ReplicasListByServerCompleteResult, err error) { - items := make([]Server, 0) - - page, err := c.ReplicasListByServer(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ReplicasListByServerCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/mysql/2021-05-01/servers/method_update.go b/resource-manager/mysql/2021-05-01/servers/method_update.go new file mode 100644 index 00000000000..c25f4634b6d --- /dev/null +++ b/resource-manager/mysql/2021-05-01/servers/method_update.go @@ -0,0 +1,74 @@ +package servers + +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 UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Update ... +func (c ServersClient) Update(ctx context.Context, id FlexibleServerId, input ServerForUpdate) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + 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 +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c ServersClient) UpdateThenPoll(ctx context.Context, id FlexibleServerId, input ServerForUpdate) error { + result, err := c.Update(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/resource-manager/mysql/2021-05-01/servers/method_update_autorest.go b/resource-manager/mysql/2021-05-01/servers/method_update_autorest.go deleted file mode 100644 index 588b1305994..00000000000 --- a/resource-manager/mysql/2021-05-01/servers/method_update_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package servers - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Update ... -func (c ServersClient) Update(ctx context.Context, id FlexibleServerId, input ServerForUpdate) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "Update", nil, "Failure preparing request") - return - } - - result, err = c.senderForUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// UpdateThenPoll performs Update then polls until it's completed -func (c ServersClient) UpdateThenPoll(ctx context.Context, id FlexibleServerId, input ServerForUpdate) error { - result, err := c.Update(ctx, id, input) - if err != nil { - return fmt.Errorf("performing Update: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Update: %+v", err) - } - - return nil -} - -// preparerForUpdate prepares the Update request. -func (c ServersClient) preparerForUpdate(ctx context.Context, id FlexibleServerId, input ServerForUpdate) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForUpdate sends the Update request. The method will close the -// http.Response Body if it receives an error. -func (c ServersClient) senderForUpdate(ctx context.Context, req *http.Request) (future UpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/mysql/2021-05-01/serverstart/client.go b/resource-manager/mysql/2021-05-01/serverstart/client.go index 035bd9107ce..f24d38e00f9 100644 --- a/resource-manager/mysql/2021-05-01/serverstart/client.go +++ b/resource-manager/mysql/2021-05-01/serverstart/client.go @@ -1,18 +1,26 @@ package serverstart -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 ServerStartClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewServerStartClientWithBaseURI(endpoint string) ServerStartClient { - return ServerStartClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewServerStartClientWithBaseURI(api environments.Api) (*ServerStartClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "serverstart", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ServerStartClient: %+v", err) } + + return &ServerStartClient{ + Client: client, + }, nil } diff --git a/resource-manager/mysql/2021-05-01/serverstart/method_serversstart.go b/resource-manager/mysql/2021-05-01/serverstart/method_serversstart.go new file mode 100644 index 00000000000..195d7ff6855 --- /dev/null +++ b/resource-manager/mysql/2021-05-01/serverstart/method_serversstart.go @@ -0,0 +1,70 @@ +package serverstart + +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 ServersStartOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ServersStart ... +func (c ServerStartClient) ServersStart(ctx context.Context, id FlexibleServerId) (result ServersStartOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/start", 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 +} + +// ServersStartThenPoll performs ServersStart then polls until it's completed +func (c ServerStartClient) ServersStartThenPoll(ctx context.Context, id FlexibleServerId) error { + result, err := c.ServersStart(ctx, id) + if err != nil { + return fmt.Errorf("performing ServersStart: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ServersStart: %+v", err) + } + + return nil +} diff --git a/resource-manager/mysql/2021-05-01/serverstart/method_serversstart_autorest.go b/resource-manager/mysql/2021-05-01/serverstart/method_serversstart_autorest.go deleted file mode 100644 index d9ba15437e8..00000000000 --- a/resource-manager/mysql/2021-05-01/serverstart/method_serversstart_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package serverstart - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ServersStartOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// ServersStart ... -func (c ServerStartClient) ServersStart(ctx context.Context, id FlexibleServerId) (result ServersStartOperationResponse, err error) { - req, err := c.preparerForServersStart(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "serverstart.ServerStartClient", "ServersStart", nil, "Failure preparing request") - return - } - - result, err = c.senderForServersStart(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "serverstart.ServerStartClient", "ServersStart", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// ServersStartThenPoll performs ServersStart then polls until it's completed -func (c ServerStartClient) ServersStartThenPoll(ctx context.Context, id FlexibleServerId) error { - result, err := c.ServersStart(ctx, id) - if err != nil { - return fmt.Errorf("performing ServersStart: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after ServersStart: %+v", err) - } - - return nil -} - -// preparerForServersStart prepares the ServersStart request. -func (c ServerStartClient) preparerForServersStart(ctx context.Context, id FlexibleServerId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/start", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForServersStart sends the ServersStart request. The method will close the -// http.Response Body if it receives an error. -func (c ServerStartClient) senderForServersStart(ctx context.Context, req *http.Request) (future ServersStartOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/mysql/2021-05-01/serverstop/client.go b/resource-manager/mysql/2021-05-01/serverstop/client.go index 488dece59ac..c47cb0e7335 100644 --- a/resource-manager/mysql/2021-05-01/serverstop/client.go +++ b/resource-manager/mysql/2021-05-01/serverstop/client.go @@ -1,18 +1,26 @@ package serverstop -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 ServerStopClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewServerStopClientWithBaseURI(endpoint string) ServerStopClient { - return ServerStopClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewServerStopClientWithBaseURI(api environments.Api) (*ServerStopClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "serverstop", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ServerStopClient: %+v", err) } + + return &ServerStopClient{ + Client: client, + }, nil } diff --git a/resource-manager/mysql/2021-05-01/serverstop/method_serversstop.go b/resource-manager/mysql/2021-05-01/serverstop/method_serversstop.go new file mode 100644 index 00000000000..f63fd390edb --- /dev/null +++ b/resource-manager/mysql/2021-05-01/serverstop/method_serversstop.go @@ -0,0 +1,70 @@ +package serverstop + +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 ServersStopOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ServersStop ... +func (c ServerStopClient) ServersStop(ctx context.Context, id FlexibleServerId) (result ServersStopOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/stop", 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 +} + +// ServersStopThenPoll performs ServersStop then polls until it's completed +func (c ServerStopClient) ServersStopThenPoll(ctx context.Context, id FlexibleServerId) error { + result, err := c.ServersStop(ctx, id) + if err != nil { + return fmt.Errorf("performing ServersStop: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ServersStop: %+v", err) + } + + return nil +} diff --git a/resource-manager/mysql/2021-05-01/serverstop/method_serversstop_autorest.go b/resource-manager/mysql/2021-05-01/serverstop/method_serversstop_autorest.go deleted file mode 100644 index cc1b5c74e6a..00000000000 --- a/resource-manager/mysql/2021-05-01/serverstop/method_serversstop_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package serverstop - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ServersStopOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// ServersStop ... -func (c ServerStopClient) ServersStop(ctx context.Context, id FlexibleServerId) (result ServersStopOperationResponse, err error) { - req, err := c.preparerForServersStop(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "serverstop.ServerStopClient", "ServersStop", nil, "Failure preparing request") - return - } - - result, err = c.senderForServersStop(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "serverstop.ServerStopClient", "ServersStop", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// ServersStopThenPoll performs ServersStop then polls until it's completed -func (c ServerStopClient) ServersStopThenPoll(ctx context.Context, id FlexibleServerId) error { - result, err := c.ServersStop(ctx, id) - if err != nil { - return fmt.Errorf("performing ServersStop: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after ServersStop: %+v", err) - } - - return nil -} - -// preparerForServersStop prepares the ServersStop request. -func (c ServerStopClient) preparerForServersStop(ctx context.Context, id FlexibleServerId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/stop", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForServersStop sends the ServersStop request. The method will close the -// http.Response Body if it receives an error. -func (c ServerStopClient) senderForServersStop(ctx context.Context, req *http.Request) (future ServersStopOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/mysql/2021-12-01-preview/azureadadministrators/client.go b/resource-manager/mysql/2021-12-01-preview/azureadadministrators/client.go index 4e49ebc04ec..eb020534988 100644 --- a/resource-manager/mysql/2021-12-01-preview/azureadadministrators/client.go +++ b/resource-manager/mysql/2021-12-01-preview/azureadadministrators/client.go @@ -1,18 +1,26 @@ package azureadadministrators -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 AzureADAdministratorsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewAzureADAdministratorsClientWithBaseURI(endpoint string) AzureADAdministratorsClient { - return AzureADAdministratorsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewAzureADAdministratorsClientWithBaseURI(api environments.Api) (*AzureADAdministratorsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "azureadadministrators", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AzureADAdministratorsClient: %+v", err) } + + return &AzureADAdministratorsClient{ + Client: client, + }, nil } diff --git a/resource-manager/mysql/2021-12-01-preview/azureadadministrators/constants.go b/resource-manager/mysql/2021-12-01-preview/azureadadministrators/constants.go index 1c7faa91a93..54afc0f8110 100644 --- a/resource-manager/mysql/2021-12-01-preview/azureadadministrators/constants.go +++ b/resource-manager/mysql/2021-12-01-preview/azureadadministrators/constants.go @@ -1,6 +1,10 @@ package azureadadministrators -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. @@ -17,6 +21,19 @@ func PossibleValuesForAdministratorType() []string { } } +func (s *AdministratorType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAdministratorType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAdministratorType(input string) (*AdministratorType, error) { vals := map[string]AdministratorType{ "activedirectory": AdministratorTypeActiveDirectory, diff --git a/resource-manager/mysql/2021-12-01-preview/azureadadministrators/method_createorupdate.go b/resource-manager/mysql/2021-12-01-preview/azureadadministrators/method_createorupdate.go new file mode 100644 index 00000000000..1f6b6ee3f75 --- /dev/null +++ b/resource-manager/mysql/2021-12-01-preview/azureadadministrators/method_createorupdate.go @@ -0,0 +1,75 @@ +package azureadadministrators + +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 +} + +// CreateOrUpdate ... +func (c AzureADAdministratorsClient) CreateOrUpdate(ctx context.Context, id FlexibleServerId, input AzureADAdministrator) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/administrators/ActiveDirectory", 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 AzureADAdministratorsClient) CreateOrUpdateThenPoll(ctx context.Context, id FlexibleServerId, input AzureADAdministrator) 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 +} diff --git a/resource-manager/mysql/2021-12-01-preview/azureadadministrators/method_createorupdate_autorest.go b/resource-manager/mysql/2021-12-01-preview/azureadadministrators/method_createorupdate_autorest.go deleted file mode 100644 index fe63044abfb..00000000000 --- a/resource-manager/mysql/2021-12-01-preview/azureadadministrators/method_createorupdate_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package azureadadministrators - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateOrUpdate ... -func (c AzureADAdministratorsClient) CreateOrUpdate(ctx context.Context, id FlexibleServerId, input AzureADAdministrator) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "azureadadministrators.AzureADAdministratorsClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "azureadadministrators.AzureADAdministratorsClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c AzureADAdministratorsClient) CreateOrUpdateThenPoll(ctx context.Context, id FlexibleServerId, input AzureADAdministrator) error { - result, err := c.CreateOrUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateOrUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateOrUpdate: %+v", err) - } - - return nil -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c AzureADAdministratorsClient) preparerForCreateOrUpdate(ctx context.Context, id FlexibleServerId, input AzureADAdministrator) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/administrators/ActiveDirectory", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateOrUpdate sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c AzureADAdministratorsClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/mysql/2021-12-01-preview/azureadadministrators/method_delete.go b/resource-manager/mysql/2021-12-01-preview/azureadadministrators/method_delete.go new file mode 100644 index 00000000000..02daa781db4 --- /dev/null +++ b/resource-manager/mysql/2021-12-01-preview/azureadadministrators/method_delete.go @@ -0,0 +1,71 @@ +package azureadadministrators + +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 AzureADAdministratorsClient) Delete(ctx context.Context, id FlexibleServerId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: fmt.Sprintf("%s/administrators/ActiveDirectory", 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 AzureADAdministratorsClient) DeleteThenPoll(ctx context.Context, id FlexibleServerId) 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 +} diff --git a/resource-manager/mysql/2021-12-01-preview/azureadadministrators/method_delete_autorest.go b/resource-manager/mysql/2021-12-01-preview/azureadadministrators/method_delete_autorest.go deleted file mode 100644 index 64c9e88c04f..00000000000 --- a/resource-manager/mysql/2021-12-01-preview/azureadadministrators/method_delete_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package azureadadministrators - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// Delete ... -func (c AzureADAdministratorsClient) Delete(ctx context.Context, id FlexibleServerId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "azureadadministrators.AzureADAdministratorsClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "azureadadministrators.AzureADAdministratorsClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c AzureADAdministratorsClient) DeleteThenPoll(ctx context.Context, id FlexibleServerId) error { - result, err := c.Delete(ctx, id) - if err != nil { - return fmt.Errorf("performing Delete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Delete: %+v", err) - } - - return nil -} - -// preparerForDelete prepares the Delete request. -func (c AzureADAdministratorsClient) preparerForDelete(ctx context.Context, id FlexibleServerId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/administrators/ActiveDirectory", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDelete sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (c AzureADAdministratorsClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/mysql/2021-12-01-preview/azureadadministrators/method_get.go b/resource-manager/mysql/2021-12-01-preview/azureadadministrators/method_get.go new file mode 100644 index 00000000000..f9a8c7e7a20 --- /dev/null +++ b/resource-manager/mysql/2021-12-01-preview/azureadadministrators/method_get.go @@ -0,0 +1,52 @@ +package azureadadministrators + +import ( + "context" + "fmt" + "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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AzureADAdministrator +} + +// Get ... +func (c AzureADAdministratorsClient) Get(ctx context.Context, id FlexibleServerId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/administrators/ActiveDirectory", 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 +} diff --git a/resource-manager/mysql/2021-12-01-preview/azureadadministrators/method_get_autorest.go b/resource-manager/mysql/2021-12-01-preview/azureadadministrators/method_get_autorest.go deleted file mode 100644 index 4768f45f1ea..00000000000 --- a/resource-manager/mysql/2021-12-01-preview/azureadadministrators/method_get_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package azureadadministrators - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *AzureADAdministrator -} - -// Get ... -func (c AzureADAdministratorsClient) Get(ctx context.Context, id FlexibleServerId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "azureadadministrators.AzureADAdministratorsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "azureadadministrators.AzureADAdministratorsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "azureadadministrators.AzureADAdministratorsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c AzureADAdministratorsClient) preparerForGet(ctx context.Context, id FlexibleServerId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/administrators/ActiveDirectory", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c AzureADAdministratorsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/mysql/2021-12-01-preview/azureadadministrators/method_listbyserver.go b/resource-manager/mysql/2021-12-01-preview/azureadadministrators/method_listbyserver.go new file mode 100644 index 00000000000..10421bcca6f --- /dev/null +++ b/resource-manager/mysql/2021-12-01-preview/azureadadministrators/method_listbyserver.go @@ -0,0 +1,89 @@ +package azureadadministrators + +import ( + "context" + "fmt" + "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 ListByServerOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AzureADAdministrator +} + +type ListByServerCompleteResult struct { + Items []AzureADAdministrator +} + +// ListByServer ... +func (c AzureADAdministratorsClient) ListByServer(ctx context.Context, id FlexibleServerId) (result ListByServerOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/administrators", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AzureADAdministrator `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServerComplete retrieves all the results into a single object +func (c AzureADAdministratorsClient) ListByServerComplete(ctx context.Context, id FlexibleServerId) (ListByServerCompleteResult, error) { + return c.ListByServerCompleteMatchingPredicate(ctx, id, AzureADAdministratorOperationPredicate{}) +} + +// ListByServerCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AzureADAdministratorsClient) ListByServerCompleteMatchingPredicate(ctx context.Context, id FlexibleServerId, predicate AzureADAdministratorOperationPredicate) (result ListByServerCompleteResult, err error) { + items := make([]AzureADAdministrator, 0) + + resp, err := c.ListByServer(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServerCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/mysql/2021-12-01-preview/azureadadministrators/method_listbyserver_autorest.go b/resource-manager/mysql/2021-12-01-preview/azureadadministrators/method_listbyserver_autorest.go deleted file mode 100644 index 9121e4b6ec9..00000000000 --- a/resource-manager/mysql/2021-12-01-preview/azureadadministrators/method_listbyserver_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package azureadadministrators - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByServerOperationResponse struct { - HttpResponse *http.Response - Model *[]AzureADAdministrator - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServerOperationResponse, error) -} - -type ListByServerCompleteResult struct { - Items []AzureADAdministrator -} - -func (r ListByServerOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServerOperationResponse) LoadMore(ctx context.Context) (resp ListByServerOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByServer ... -func (c AzureADAdministratorsClient) ListByServer(ctx context.Context, id FlexibleServerId) (resp ListByServerOperationResponse, err error) { - req, err := c.preparerForListByServer(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "azureadadministrators.AzureADAdministratorsClient", "ListByServer", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "azureadadministrators.AzureADAdministratorsClient", "ListByServer", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByServer(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "azureadadministrators.AzureADAdministratorsClient", "ListByServer", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByServer prepares the ListByServer request. -func (c AzureADAdministratorsClient) preparerForListByServer(ctx context.Context, id FlexibleServerId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/administrators", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServerWithNextLink prepares the ListByServer request with the given nextLink token. -func (c AzureADAdministratorsClient) preparerForListByServerWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByServer handles the response to the ListByServer request. The method always -// closes the http.Response Body. -func (c AzureADAdministratorsClient) responderForListByServer(resp *http.Response) (result ListByServerOperationResponse, err error) { - type page struct { - Values []AzureADAdministrator `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByServerOperationResponse, err error) { - req, err := c.preparerForListByServerWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "azureadadministrators.AzureADAdministratorsClient", "ListByServer", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "azureadadministrators.AzureADAdministratorsClient", "ListByServer", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByServer(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "azureadadministrators.AzureADAdministratorsClient", "ListByServer", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServerComplete retrieves all of the results into a single object -func (c AzureADAdministratorsClient) ListByServerComplete(ctx context.Context, id FlexibleServerId) (ListByServerCompleteResult, error) { - return c.ListByServerCompleteMatchingPredicate(ctx, id, AzureADAdministratorOperationPredicate{}) -} - -// ListByServerCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c AzureADAdministratorsClient) ListByServerCompleteMatchingPredicate(ctx context.Context, id FlexibleServerId, predicate AzureADAdministratorOperationPredicate) (resp ListByServerCompleteResult, err error) { - items := make([]AzureADAdministrator, 0) - - page, err := c.ListByServer(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServerCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/mysql/2021-12-01-preview/backups/client.go b/resource-manager/mysql/2021-12-01-preview/backups/client.go index 8669bac74ee..ae4432efd22 100644 --- a/resource-manager/mysql/2021-12-01-preview/backups/client.go +++ b/resource-manager/mysql/2021-12-01-preview/backups/client.go @@ -1,18 +1,26 @@ package backups -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 BackupsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewBackupsClientWithBaseURI(endpoint string) BackupsClient { - return BackupsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewBackupsClientWithBaseURI(api environments.Api) (*BackupsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "backups", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating BackupsClient: %+v", err) } + + return &BackupsClient{ + Client: client, + }, nil } diff --git a/resource-manager/mysql/2021-12-01-preview/backups/method_get.go b/resource-manager/mysql/2021-12-01-preview/backups/method_get.go new file mode 100644 index 00000000000..161afc45282 --- /dev/null +++ b/resource-manager/mysql/2021-12-01-preview/backups/method_get.go @@ -0,0 +1,51 @@ +package backups + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ServerBackup +} + +// Get ... +func (c BackupsClient) Get(ctx context.Context, id BackupId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/mysql/2021-12-01-preview/backups/method_get_autorest.go b/resource-manager/mysql/2021-12-01-preview/backups/method_get_autorest.go deleted file mode 100644 index 932c6ce0d6c..00000000000 --- a/resource-manager/mysql/2021-12-01-preview/backups/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package backups - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *ServerBackup -} - -// Get ... -func (c BackupsClient) Get(ctx context.Context, id BackupId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "backups.BackupsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "backups.BackupsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "backups.BackupsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c BackupsClient) preparerForGet(ctx context.Context, id BackupId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c BackupsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/mysql/2021-12-01-preview/backups/method_listbyserver.go b/resource-manager/mysql/2021-12-01-preview/backups/method_listbyserver.go new file mode 100644 index 00000000000..baab7e30266 --- /dev/null +++ b/resource-manager/mysql/2021-12-01-preview/backups/method_listbyserver.go @@ -0,0 +1,89 @@ +package backups + +import ( + "context" + "fmt" + "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 ListByServerOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ServerBackup +} + +type ListByServerCompleteResult struct { + Items []ServerBackup +} + +// ListByServer ... +func (c BackupsClient) ListByServer(ctx context.Context, id FlexibleServerId) (result ListByServerOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/backups", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ServerBackup `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServerComplete retrieves all the results into a single object +func (c BackupsClient) ListByServerComplete(ctx context.Context, id FlexibleServerId) (ListByServerCompleteResult, error) { + return c.ListByServerCompleteMatchingPredicate(ctx, id, ServerBackupOperationPredicate{}) +} + +// ListByServerCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c BackupsClient) ListByServerCompleteMatchingPredicate(ctx context.Context, id FlexibleServerId, predicate ServerBackupOperationPredicate) (result ListByServerCompleteResult, err error) { + items := make([]ServerBackup, 0) + + resp, err := c.ListByServer(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServerCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/mysql/2021-12-01-preview/backups/method_listbyserver_autorest.go b/resource-manager/mysql/2021-12-01-preview/backups/method_listbyserver_autorest.go deleted file mode 100644 index 998090174cf..00000000000 --- a/resource-manager/mysql/2021-12-01-preview/backups/method_listbyserver_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package backups - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByServerOperationResponse struct { - HttpResponse *http.Response - Model *[]ServerBackup - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServerOperationResponse, error) -} - -type ListByServerCompleteResult struct { - Items []ServerBackup -} - -func (r ListByServerOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServerOperationResponse) LoadMore(ctx context.Context) (resp ListByServerOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByServer ... -func (c BackupsClient) ListByServer(ctx context.Context, id FlexibleServerId) (resp ListByServerOperationResponse, err error) { - req, err := c.preparerForListByServer(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "backups.BackupsClient", "ListByServer", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "backups.BackupsClient", "ListByServer", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByServer(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "backups.BackupsClient", "ListByServer", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByServer prepares the ListByServer request. -func (c BackupsClient) preparerForListByServer(ctx context.Context, id FlexibleServerId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/backups", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServerWithNextLink prepares the ListByServer request with the given nextLink token. -func (c BackupsClient) preparerForListByServerWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByServer handles the response to the ListByServer request. The method always -// closes the http.Response Body. -func (c BackupsClient) responderForListByServer(resp *http.Response) (result ListByServerOperationResponse, err error) { - type page struct { - Values []ServerBackup `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByServerOperationResponse, err error) { - req, err := c.preparerForListByServerWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "backups.BackupsClient", "ListByServer", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "backups.BackupsClient", "ListByServer", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByServer(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "backups.BackupsClient", "ListByServer", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServerComplete retrieves all of the results into a single object -func (c BackupsClient) ListByServerComplete(ctx context.Context, id FlexibleServerId) (ListByServerCompleteResult, error) { - return c.ListByServerCompleteMatchingPredicate(ctx, id, ServerBackupOperationPredicate{}) -} - -// ListByServerCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c BackupsClient) ListByServerCompleteMatchingPredicate(ctx context.Context, id FlexibleServerId, predicate ServerBackupOperationPredicate) (resp ListByServerCompleteResult, err error) { - items := make([]ServerBackup, 0) - - page, err := c.ListByServer(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServerCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/mysql/2021-12-01-preview/backups/method_put.go b/resource-manager/mysql/2021-12-01-preview/backups/method_put.go new file mode 100644 index 00000000000..74359bfcefd --- /dev/null +++ b/resource-manager/mysql/2021-12-01-preview/backups/method_put.go @@ -0,0 +1,51 @@ +package backups + +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 PutOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ServerBackup +} + +// Put ... +func (c BackupsClient) Put(ctx context.Context, id BackupId) (result PutOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + 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 +} diff --git a/resource-manager/mysql/2021-12-01-preview/backups/method_put_autorest.go b/resource-manager/mysql/2021-12-01-preview/backups/method_put_autorest.go deleted file mode 100644 index c98190ee043..00000000000 --- a/resource-manager/mysql/2021-12-01-preview/backups/method_put_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package backups - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PutOperationResponse struct { - HttpResponse *http.Response - Model *ServerBackup -} - -// Put ... -func (c BackupsClient) Put(ctx context.Context, id BackupId) (result PutOperationResponse, err error) { - req, err := c.preparerForPut(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "backups.BackupsClient", "Put", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "backups.BackupsClient", "Put", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForPut(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "backups.BackupsClient", "Put", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForPut prepares the Put request. -func (c BackupsClient) preparerForPut(ctx context.Context, id BackupId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForPut handles the response to the Put request. The method always -// closes the http.Response Body. -func (c BackupsClient) responderForPut(resp *http.Response) (result PutOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/mysql/2021-12-01-preview/checknameavailability/client.go b/resource-manager/mysql/2021-12-01-preview/checknameavailability/client.go index a8ea1dabf11..81c73505778 100644 --- a/resource-manager/mysql/2021-12-01-preview/checknameavailability/client.go +++ b/resource-manager/mysql/2021-12-01-preview/checknameavailability/client.go @@ -1,18 +1,26 @@ package checknameavailability -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 CheckNameAvailabilityClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewCheckNameAvailabilityClientWithBaseURI(endpoint string) CheckNameAvailabilityClient { - return CheckNameAvailabilityClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewCheckNameAvailabilityClientWithBaseURI(api environments.Api) (*CheckNameAvailabilityClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "checknameavailability", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CheckNameAvailabilityClient: %+v", err) } + + return &CheckNameAvailabilityClient{ + Client: client, + }, nil } diff --git a/resource-manager/mysql/2021-12-01-preview/checknameavailability/method_execute.go b/resource-manager/mysql/2021-12-01-preview/checknameavailability/method_execute.go new file mode 100644 index 00000000000..319ad5d298b --- /dev/null +++ b/resource-manager/mysql/2021-12-01-preview/checknameavailability/method_execute.go @@ -0,0 +1,56 @@ +package checknameavailability + +import ( + "context" + "fmt" + "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 ExecuteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NameAvailability +} + +// Execute ... +func (c CheckNameAvailabilityClient) Execute(ctx context.Context, id LocationId, input NameAvailabilityRequest) (result ExecuteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/checkNameAvailability", 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 +} diff --git a/resource-manager/mysql/2021-12-01-preview/checknameavailability/method_execute_autorest.go b/resource-manager/mysql/2021-12-01-preview/checknameavailability/method_execute_autorest.go deleted file mode 100644 index abe034c4edd..00000000000 --- a/resource-manager/mysql/2021-12-01-preview/checknameavailability/method_execute_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package checknameavailability - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ExecuteOperationResponse struct { - HttpResponse *http.Response - Model *NameAvailability -} - -// Execute ... -func (c CheckNameAvailabilityClient) Execute(ctx context.Context, id LocationId, input NameAvailabilityRequest) (result ExecuteOperationResponse, err error) { - req, err := c.preparerForExecute(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "checknameavailability.CheckNameAvailabilityClient", "Execute", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "checknameavailability.CheckNameAvailabilityClient", "Execute", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForExecute(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "checknameavailability.CheckNameAvailabilityClient", "Execute", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForExecute prepares the Execute request. -func (c CheckNameAvailabilityClient) preparerForExecute(ctx context.Context, id LocationId, input NameAvailabilityRequest) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/checkNameAvailability", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForExecute handles the response to the Execute request. The method always -// closes the http.Response Body. -func (c CheckNameAvailabilityClient) responderForExecute(resp *http.Response) (result ExecuteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/mysql/2021-12-01-preview/checknameavailability/method_withoutlocationexecute.go b/resource-manager/mysql/2021-12-01-preview/checknameavailability/method_withoutlocationexecute.go new file mode 100644 index 00000000000..875573b0386 --- /dev/null +++ b/resource-manager/mysql/2021-12-01-preview/checknameavailability/method_withoutlocationexecute.go @@ -0,0 +1,57 @@ +package checknameavailability + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 WithoutLocationExecuteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NameAvailability +} + +// WithoutLocationExecute ... +func (c CheckNameAvailabilityClient) WithoutLocationExecute(ctx context.Context, id commonids.SubscriptionId, input NameAvailabilityRequest) (result WithoutLocationExecuteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.DBforMySQL/checkNameAvailability", 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 +} diff --git a/resource-manager/mysql/2021-12-01-preview/checknameavailability/method_withoutlocationexecute_autorest.go b/resource-manager/mysql/2021-12-01-preview/checknameavailability/method_withoutlocationexecute_autorest.go deleted file mode 100644 index ec031b0c323..00000000000 --- a/resource-manager/mysql/2021-12-01-preview/checknameavailability/method_withoutlocationexecute_autorest.go +++ /dev/null @@ -1,71 +0,0 @@ -package checknameavailability - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type WithoutLocationExecuteOperationResponse struct { - HttpResponse *http.Response - Model *NameAvailability -} - -// WithoutLocationExecute ... -func (c CheckNameAvailabilityClient) WithoutLocationExecute(ctx context.Context, id commonids.SubscriptionId, input NameAvailabilityRequest) (result WithoutLocationExecuteOperationResponse, err error) { - req, err := c.preparerForWithoutLocationExecute(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "checknameavailability.CheckNameAvailabilityClient", "WithoutLocationExecute", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "checknameavailability.CheckNameAvailabilityClient", "WithoutLocationExecute", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForWithoutLocationExecute(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "checknameavailability.CheckNameAvailabilityClient", "WithoutLocationExecute", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForWithoutLocationExecute prepares the WithoutLocationExecute request. -func (c CheckNameAvailabilityClient) preparerForWithoutLocationExecute(ctx context.Context, id commonids.SubscriptionId, input NameAvailabilityRequest) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.DBforMySQL/checkNameAvailability", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForWithoutLocationExecute handles the response to the WithoutLocationExecute request. The method always -// closes the http.Response Body. -func (c CheckNameAvailabilityClient) responderForWithoutLocationExecute(resp *http.Response) (result WithoutLocationExecuteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/mysql/2021-12-01-preview/client.go b/resource-manager/mysql/2021-12-01-preview/client.go index 1725dedc00a..3ac7f438d8f 100644 --- a/resource-manager/mysql/2021-12-01-preview/client.go +++ b/resource-manager/mysql/2021-12-01-preview/client.go @@ -4,7 +4,8 @@ package v2021_12_01_preview // 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/mysql/2021-12-01-preview/azureadadministrators" "github.com/hashicorp/go-azure-sdk/resource-manager/mysql/2021-12-01-preview/backups" "github.com/hashicorp/go-azure-sdk/resource-manager/mysql/2021-12-01-preview/checknameavailability" @@ -19,6 +20,8 @@ import ( "github.com/hashicorp/go-azure-sdk/resource-manager/mysql/2021-12-01-preview/servers" "github.com/hashicorp/go-azure-sdk/resource-manager/mysql/2021-12-01-preview/serverstart" "github.com/hashicorp/go-azure-sdk/resource-manager/mysql/2021-12-01-preview/serverstop" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/environments" ) type Client struct { @@ -38,64 +41,105 @@ type Client struct { Servers *servers.ServersClient } -func NewClientWithBaseURI(endpoint string, configureAuthFunc func(c *autorest.Client)) Client { - - azureADAdministratorsClient := azureadadministrators.NewAzureADAdministratorsClientWithBaseURI(endpoint) - configureAuthFunc(&azureADAdministratorsClient.Client) - - backupsClient := backups.NewBackupsClientWithBaseURI(endpoint) - configureAuthFunc(&backupsClient.Client) +func NewClientWithBaseURI(api environments.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + azureADAdministratorsClient, err := azureadadministrators.NewAzureADAdministratorsClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building AzureADAdministrators client: %+v", err) + } + configureFunc(azureADAdministratorsClient.Client) - checkNameAvailabilityClient := checknameavailability.NewCheckNameAvailabilityClientWithBaseURI(endpoint) - configureAuthFunc(&checkNameAvailabilityClient.Client) + backupsClient, err := backups.NewBackupsClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Backups client: %+v", err) + } + configureFunc(backupsClient.Client) - configurationsClient := configurations.NewConfigurationsClientWithBaseURI(endpoint) - configureAuthFunc(&configurationsClient.Client) + checkNameAvailabilityClient, err := checknameavailability.NewCheckNameAvailabilityClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building CheckNameAvailability client: %+v", err) + } + configureFunc(checkNameAvailabilityClient.Client) - databasesClient := databases.NewDatabasesClientWithBaseURI(endpoint) - configureAuthFunc(&databasesClient.Client) + configurationsClient, err := configurations.NewConfigurationsClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Configurations client: %+v", err) + } + configureFunc(configurationsClient.Client) - firewallRulesClient := firewallrules.NewFirewallRulesClientWithBaseURI(endpoint) - configureAuthFunc(&firewallRulesClient.Client) + databasesClient, err := databases.NewDatabasesClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Databases client: %+v", err) + } + configureFunc(databasesClient.Client) - getPrivateDnsZoneSuffixClient := getprivatednszonesuffix.NewGetPrivateDnsZoneSuffixClientWithBaseURI(endpoint) - configureAuthFunc(&getPrivateDnsZoneSuffixClient.Client) + firewallRulesClient, err := firewallrules.NewFirewallRulesClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building FirewallRules client: %+v", err) + } + configureFunc(firewallRulesClient.Client) - locationBasedCapabilitiesClient := locationbasedcapabilities.NewLocationBasedCapabilitiesClientWithBaseURI(endpoint) - configureAuthFunc(&locationBasedCapabilitiesClient.Client) + getPrivateDnsZoneSuffixClient, err := getprivatednszonesuffix.NewGetPrivateDnsZoneSuffixClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building GetPrivateDnsZoneSuffix client: %+v", err) + } + configureFunc(getPrivateDnsZoneSuffixClient.Client) - logFilesClient := logfiles.NewLogFilesClientWithBaseURI(endpoint) - configureAuthFunc(&logFilesClient.Client) + locationBasedCapabilitiesClient, err := locationbasedcapabilities.NewLocationBasedCapabilitiesClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building LocationBasedCapabilities client: %+v", err) + } + configureFunc(locationBasedCapabilitiesClient.Client) - serverFailoverClient := serverfailover.NewServerFailoverClientWithBaseURI(endpoint) - configureAuthFunc(&serverFailoverClient.Client) + logFilesClient, err := logfiles.NewLogFilesClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building LogFiles client: %+v", err) + } + configureFunc(logFilesClient.Client) - serverRestartClient := serverrestart.NewServerRestartClientWithBaseURI(endpoint) - configureAuthFunc(&serverRestartClient.Client) + serverFailoverClient, err := serverfailover.NewServerFailoverClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ServerFailover client: %+v", err) + } + configureFunc(serverFailoverClient.Client) - serverStartClient := serverstart.NewServerStartClientWithBaseURI(endpoint) - configureAuthFunc(&serverStartClient.Client) + serverRestartClient, err := serverrestart.NewServerRestartClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ServerRestart client: %+v", err) + } + configureFunc(serverRestartClient.Client) - serverStopClient := serverstop.NewServerStopClientWithBaseURI(endpoint) - configureAuthFunc(&serverStopClient.Client) + serverStartClient, err := serverstart.NewServerStartClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ServerStart client: %+v", err) + } + configureFunc(serverStartClient.Client) - serversClient := servers.NewServersClientWithBaseURI(endpoint) - configureAuthFunc(&serversClient.Client) + serverStopClient, err := serverstop.NewServerStopClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ServerStop client: %+v", err) + } + configureFunc(serverStopClient.Client) - return Client{ - AzureADAdministrators: &azureADAdministratorsClient, - Backups: &backupsClient, - CheckNameAvailability: &checkNameAvailabilityClient, - Configurations: &configurationsClient, - Databases: &databasesClient, - FirewallRules: &firewallRulesClient, - GetPrivateDnsZoneSuffix: &getPrivateDnsZoneSuffixClient, - LocationBasedCapabilities: &locationBasedCapabilitiesClient, - LogFiles: &logFilesClient, - ServerFailover: &serverFailoverClient, - ServerRestart: &serverRestartClient, - ServerStart: &serverStartClient, - ServerStop: &serverStopClient, - Servers: &serversClient, + serversClient, err := servers.NewServersClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Servers client: %+v", err) } + configureFunc(serversClient.Client) + + return &Client{ + AzureADAdministrators: azureADAdministratorsClient, + Backups: backupsClient, + CheckNameAvailability: checkNameAvailabilityClient, + Configurations: configurationsClient, + Databases: databasesClient, + FirewallRules: firewallRulesClient, + GetPrivateDnsZoneSuffix: getPrivateDnsZoneSuffixClient, + LocationBasedCapabilities: locationBasedCapabilitiesClient, + LogFiles: logFilesClient, + ServerFailover: serverFailoverClient, + ServerRestart: serverRestartClient, + ServerStart: serverStartClient, + ServerStop: serverStopClient, + Servers: serversClient, + }, nil } diff --git a/resource-manager/mysql/2021-12-01-preview/configurations/client.go b/resource-manager/mysql/2021-12-01-preview/configurations/client.go index bbe813edd98..c2b3df6d8b8 100644 --- a/resource-manager/mysql/2021-12-01-preview/configurations/client.go +++ b/resource-manager/mysql/2021-12-01-preview/configurations/client.go @@ -1,18 +1,26 @@ package configurations -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 ConfigurationsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewConfigurationsClientWithBaseURI(endpoint string) ConfigurationsClient { - return ConfigurationsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewConfigurationsClientWithBaseURI(api environments.Api) (*ConfigurationsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "configurations", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ConfigurationsClient: %+v", err) } + + return &ConfigurationsClient{ + Client: client, + }, nil } diff --git a/resource-manager/mysql/2021-12-01-preview/configurations/constants.go b/resource-manager/mysql/2021-12-01-preview/configurations/constants.go index 315bd568db4..5508483dcba 100644 --- a/resource-manager/mysql/2021-12-01-preview/configurations/constants.go +++ b/resource-manager/mysql/2021-12-01-preview/configurations/constants.go @@ -1,6 +1,10 @@ package configurations -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. @@ -19,6 +23,19 @@ func PossibleValuesForConfigurationSource() []string { } } +func (s *ConfigurationSource) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConfigurationSource(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseConfigurationSource(input string) (*ConfigurationSource, error) { vals := map[string]ConfigurationSource{ "system-default": ConfigurationSourceSystemNegativedefault, @@ -47,6 +64,19 @@ func PossibleValuesForIsConfigPendingRestart() []string { } } +func (s *IsConfigPendingRestart) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIsConfigPendingRestart(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseIsConfigPendingRestart(input string) (*IsConfigPendingRestart, error) { vals := map[string]IsConfigPendingRestart{ "false": IsConfigPendingRestartFalse, @@ -75,6 +105,19 @@ func PossibleValuesForIsDynamicConfig() []string { } } +func (s *IsDynamicConfig) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIsDynamicConfig(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseIsDynamicConfig(input string) (*IsDynamicConfig, error) { vals := map[string]IsDynamicConfig{ "false": IsDynamicConfigFalse, @@ -103,6 +146,19 @@ func PossibleValuesForIsReadOnly() []string { } } +func (s *IsReadOnly) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIsReadOnly(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseIsReadOnly(input string) (*IsReadOnly, error) { vals := map[string]IsReadOnly{ "false": IsReadOnlyFalse, @@ -131,6 +187,19 @@ func PossibleValuesForResetAllToDefault() []string { } } +func (s *ResetAllToDefault) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResetAllToDefault(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseResetAllToDefault(input string) (*ResetAllToDefault, error) { vals := map[string]ResetAllToDefault{ "false": ResetAllToDefaultFalse, diff --git a/resource-manager/mysql/2021-12-01-preview/configurations/method_batchupdate.go b/resource-manager/mysql/2021-12-01-preview/configurations/method_batchupdate.go new file mode 100644 index 00000000000..d0c2d8f4766 --- /dev/null +++ b/resource-manager/mysql/2021-12-01-preview/configurations/method_batchupdate.go @@ -0,0 +1,74 @@ +package configurations + +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 BatchUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// BatchUpdate ... +func (c ConfigurationsClient) BatchUpdate(ctx context.Context, id FlexibleServerId, input ConfigurationListForBatchUpdate) (result BatchUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/updateConfigurations", 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 +} + +// BatchUpdateThenPoll performs BatchUpdate then polls until it's completed +func (c ConfigurationsClient) BatchUpdateThenPoll(ctx context.Context, id FlexibleServerId, input ConfigurationListForBatchUpdate) error { + result, err := c.BatchUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing BatchUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after BatchUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/mysql/2021-12-01-preview/configurations/method_batchupdate_autorest.go b/resource-manager/mysql/2021-12-01-preview/configurations/method_batchupdate_autorest.go deleted file mode 100644 index db8e7f9f189..00000000000 --- a/resource-manager/mysql/2021-12-01-preview/configurations/method_batchupdate_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package configurations - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type BatchUpdateOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// BatchUpdate ... -func (c ConfigurationsClient) BatchUpdate(ctx context.Context, id FlexibleServerId, input ConfigurationListForBatchUpdate) (result BatchUpdateOperationResponse, err error) { - req, err := c.preparerForBatchUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "configurations.ConfigurationsClient", "BatchUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForBatchUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "configurations.ConfigurationsClient", "BatchUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// BatchUpdateThenPoll performs BatchUpdate then polls until it's completed -func (c ConfigurationsClient) BatchUpdateThenPoll(ctx context.Context, id FlexibleServerId, input ConfigurationListForBatchUpdate) error { - result, err := c.BatchUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing BatchUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after BatchUpdate: %+v", err) - } - - return nil -} - -// preparerForBatchUpdate prepares the BatchUpdate request. -func (c ConfigurationsClient) preparerForBatchUpdate(ctx context.Context, id FlexibleServerId, input ConfigurationListForBatchUpdate) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/updateConfigurations", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForBatchUpdate sends the BatchUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c ConfigurationsClient) senderForBatchUpdate(ctx context.Context, req *http.Request) (future BatchUpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/mysql/2021-12-01-preview/configurations/method_createorupdate.go b/resource-manager/mysql/2021-12-01-preview/configurations/method_createorupdate.go new file mode 100644 index 00000000000..3b1b65a9581 --- /dev/null +++ b/resource-manager/mysql/2021-12-01-preview/configurations/method_createorupdate.go @@ -0,0 +1,74 @@ +package configurations + +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 +} + +// CreateOrUpdate ... +func (c ConfigurationsClient) CreateOrUpdate(ctx context.Context, id ConfigurationId, input Configuration) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 ConfigurationsClient) CreateOrUpdateThenPoll(ctx context.Context, id ConfigurationId, input Configuration) 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 +} diff --git a/resource-manager/mysql/2021-12-01-preview/configurations/method_createorupdate_autorest.go b/resource-manager/mysql/2021-12-01-preview/configurations/method_createorupdate_autorest.go deleted file mode 100644 index c1e771a52d1..00000000000 --- a/resource-manager/mysql/2021-12-01-preview/configurations/method_createorupdate_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package configurations - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateOrUpdate ... -func (c ConfigurationsClient) CreateOrUpdate(ctx context.Context, id ConfigurationId, input Configuration) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "configurations.ConfigurationsClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "configurations.ConfigurationsClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c ConfigurationsClient) CreateOrUpdateThenPoll(ctx context.Context, id ConfigurationId, input Configuration) error { - result, err := c.CreateOrUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateOrUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateOrUpdate: %+v", err) - } - - return nil -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c ConfigurationsClient) preparerForCreateOrUpdate(ctx context.Context, id ConfigurationId, input Configuration) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateOrUpdate sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c ConfigurationsClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/mysql/2021-12-01-preview/configurations/method_get.go b/resource-manager/mysql/2021-12-01-preview/configurations/method_get.go new file mode 100644 index 00000000000..d9bbfb3ea3d --- /dev/null +++ b/resource-manager/mysql/2021-12-01-preview/configurations/method_get.go @@ -0,0 +1,51 @@ +package configurations + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Configuration +} + +// Get ... +func (c ConfigurationsClient) Get(ctx context.Context, id ConfigurationId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/mysql/2021-12-01-preview/configurations/method_get_autorest.go b/resource-manager/mysql/2021-12-01-preview/configurations/method_get_autorest.go deleted file mode 100644 index 2aeb488f91c..00000000000 --- a/resource-manager/mysql/2021-12-01-preview/configurations/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package configurations - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *Configuration -} - -// Get ... -func (c ConfigurationsClient) Get(ctx context.Context, id ConfigurationId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "configurations.ConfigurationsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "configurations.ConfigurationsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "configurations.ConfigurationsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ConfigurationsClient) preparerForGet(ctx context.Context, id ConfigurationId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c ConfigurationsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/mysql/2021-12-01-preview/configurations/method_listbyserver.go b/resource-manager/mysql/2021-12-01-preview/configurations/method_listbyserver.go new file mode 100644 index 00000000000..00b35ec5f85 --- /dev/null +++ b/resource-manager/mysql/2021-12-01-preview/configurations/method_listbyserver.go @@ -0,0 +1,129 @@ +package configurations + +import ( + "context" + "fmt" + "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 ListByServerOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Configuration +} + +type ListByServerCompleteResult struct { + Items []Configuration +} + +type ListByServerOperationOptions struct { + Keyword *string + Page *int64 + PageSize *int64 + Tags *string +} + +func DefaultListByServerOperationOptions() ListByServerOperationOptions { + return ListByServerOperationOptions{} +} + +func (o ListByServerOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServerOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServerOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Keyword != nil { + out.Append("keyword", fmt.Sprintf("%v", *o.Keyword)) + } + if o.Page != nil { + out.Append("page", fmt.Sprintf("%v", *o.Page)) + } + if o.PageSize != nil { + out.Append("pageSize", fmt.Sprintf("%v", *o.PageSize)) + } + if o.Tags != nil { + out.Append("tags", fmt.Sprintf("%v", *o.Tags)) + } + return &out +} + +// ListByServer ... +func (c ConfigurationsClient) ListByServer(ctx context.Context, id FlexibleServerId, options ListByServerOperationOptions) (result ListByServerOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/configurations", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Configuration `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServerComplete retrieves all the results into a single object +func (c ConfigurationsClient) ListByServerComplete(ctx context.Context, id FlexibleServerId, options ListByServerOperationOptions) (ListByServerCompleteResult, error) { + return c.ListByServerCompleteMatchingPredicate(ctx, id, options, ConfigurationOperationPredicate{}) +} + +// ListByServerCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ConfigurationsClient) ListByServerCompleteMatchingPredicate(ctx context.Context, id FlexibleServerId, options ListByServerOperationOptions, predicate ConfigurationOperationPredicate) (result ListByServerCompleteResult, err error) { + items := make([]Configuration, 0) + + resp, err := c.ListByServer(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServerCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/mysql/2021-12-01-preview/configurations/method_listbyserver_autorest.go b/resource-manager/mysql/2021-12-01-preview/configurations/method_listbyserver_autorest.go deleted file mode 100644 index b3602ba12ff..00000000000 --- a/resource-manager/mysql/2021-12-01-preview/configurations/method_listbyserver_autorest.go +++ /dev/null @@ -1,230 +0,0 @@ -package configurations - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByServerOperationResponse struct { - HttpResponse *http.Response - Model *[]Configuration - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServerOperationResponse, error) -} - -type ListByServerCompleteResult struct { - Items []Configuration -} - -func (r ListByServerOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServerOperationResponse) LoadMore(ctx context.Context) (resp ListByServerOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServerOperationOptions struct { - Keyword *string - Page *int64 - PageSize *int64 - Tags *string -} - -func DefaultListByServerOperationOptions() ListByServerOperationOptions { - return ListByServerOperationOptions{} -} - -func (o ListByServerOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServerOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Keyword != nil { - out["keyword"] = *o.Keyword - } - - if o.Page != nil { - out["page"] = *o.Page - } - - if o.PageSize != nil { - out["pageSize"] = *o.PageSize - } - - if o.Tags != nil { - out["tags"] = *o.Tags - } - - return out -} - -// ListByServer ... -func (c ConfigurationsClient) ListByServer(ctx context.Context, id FlexibleServerId, options ListByServerOperationOptions) (resp ListByServerOperationResponse, err error) { - req, err := c.preparerForListByServer(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "configurations.ConfigurationsClient", "ListByServer", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "configurations.ConfigurationsClient", "ListByServer", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByServer(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "configurations.ConfigurationsClient", "ListByServer", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByServer prepares the ListByServer request. -func (c ConfigurationsClient) preparerForListByServer(ctx context.Context, id FlexibleServerId, options ListByServerOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/configurations", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServerWithNextLink prepares the ListByServer request with the given nextLink token. -func (c ConfigurationsClient) preparerForListByServerWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByServer handles the response to the ListByServer request. The method always -// closes the http.Response Body. -func (c ConfigurationsClient) responderForListByServer(resp *http.Response) (result ListByServerOperationResponse, err error) { - type page struct { - Values []Configuration `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByServerOperationResponse, err error) { - req, err := c.preparerForListByServerWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "configurations.ConfigurationsClient", "ListByServer", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "configurations.ConfigurationsClient", "ListByServer", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByServer(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "configurations.ConfigurationsClient", "ListByServer", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServerComplete retrieves all of the results into a single object -func (c ConfigurationsClient) ListByServerComplete(ctx context.Context, id FlexibleServerId, options ListByServerOperationOptions) (ListByServerCompleteResult, error) { - return c.ListByServerCompleteMatchingPredicate(ctx, id, options, ConfigurationOperationPredicate{}) -} - -// ListByServerCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ConfigurationsClient) ListByServerCompleteMatchingPredicate(ctx context.Context, id FlexibleServerId, options ListByServerOperationOptions, predicate ConfigurationOperationPredicate) (resp ListByServerCompleteResult, err error) { - items := make([]Configuration, 0) - - page, err := c.ListByServer(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServerCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/mysql/2021-12-01-preview/configurations/method_update.go b/resource-manager/mysql/2021-12-01-preview/configurations/method_update.go new file mode 100644 index 00000000000..e9b210b8cbd --- /dev/null +++ b/resource-manager/mysql/2021-12-01-preview/configurations/method_update.go @@ -0,0 +1,74 @@ +package configurations + +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 UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Update ... +func (c ConfigurationsClient) Update(ctx context.Context, id ConfigurationId, input Configuration) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + 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 +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c ConfigurationsClient) UpdateThenPoll(ctx context.Context, id ConfigurationId, input Configuration) error { + result, err := c.Update(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/resource-manager/mysql/2021-12-01-preview/configurations/method_update_autorest.go b/resource-manager/mysql/2021-12-01-preview/configurations/method_update_autorest.go deleted file mode 100644 index 7d79f3dd369..00000000000 --- a/resource-manager/mysql/2021-12-01-preview/configurations/method_update_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package configurations - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Update ... -func (c ConfigurationsClient) Update(ctx context.Context, id ConfigurationId, input Configuration) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "configurations.ConfigurationsClient", "Update", nil, "Failure preparing request") - return - } - - result, err = c.senderForUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "configurations.ConfigurationsClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// UpdateThenPoll performs Update then polls until it's completed -func (c ConfigurationsClient) UpdateThenPoll(ctx context.Context, id ConfigurationId, input Configuration) error { - result, err := c.Update(ctx, id, input) - if err != nil { - return fmt.Errorf("performing Update: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Update: %+v", err) - } - - return nil -} - -// preparerForUpdate prepares the Update request. -func (c ConfigurationsClient) preparerForUpdate(ctx context.Context, id ConfigurationId, input Configuration) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForUpdate sends the Update request. The method will close the -// http.Response Body if it receives an error. -func (c ConfigurationsClient) senderForUpdate(ctx context.Context, req *http.Request) (future UpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/mysql/2021-12-01-preview/databases/client.go b/resource-manager/mysql/2021-12-01-preview/databases/client.go index 5305d65eb6c..bb94a331f78 100644 --- a/resource-manager/mysql/2021-12-01-preview/databases/client.go +++ b/resource-manager/mysql/2021-12-01-preview/databases/client.go @@ -1,18 +1,26 @@ package databases -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 DatabasesClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewDatabasesClientWithBaseURI(endpoint string) DatabasesClient { - return DatabasesClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewDatabasesClientWithBaseURI(api environments.Api) (*DatabasesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "databases", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DatabasesClient: %+v", err) } + + return &DatabasesClient{ + Client: client, + }, nil } diff --git a/resource-manager/mysql/2021-12-01-preview/databases/method_createorupdate.go b/resource-manager/mysql/2021-12-01-preview/databases/method_createorupdate.go new file mode 100644 index 00000000000..6dc4e3e0560 --- /dev/null +++ b/resource-manager/mysql/2021-12-01-preview/databases/method_createorupdate.go @@ -0,0 +1,75 @@ +package databases + +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 +} + +// CreateOrUpdate ... +func (c DatabasesClient) CreateOrUpdate(ctx context.Context, id DatabaseId, input Database) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 DatabasesClient) CreateOrUpdateThenPoll(ctx context.Context, id DatabaseId, input Database) 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 +} diff --git a/resource-manager/mysql/2021-12-01-preview/databases/method_createorupdate_autorest.go b/resource-manager/mysql/2021-12-01-preview/databases/method_createorupdate_autorest.go deleted file mode 100644 index 8046543297d..00000000000 --- a/resource-manager/mysql/2021-12-01-preview/databases/method_createorupdate_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package databases - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateOrUpdate ... -func (c DatabasesClient) CreateOrUpdate(ctx context.Context, id DatabaseId, input Database) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c DatabasesClient) CreateOrUpdateThenPoll(ctx context.Context, id DatabaseId, input Database) error { - result, err := c.CreateOrUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateOrUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateOrUpdate: %+v", err) - } - - return nil -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c DatabasesClient) preparerForCreateOrUpdate(ctx context.Context, id DatabaseId, input Database) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateOrUpdate sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c DatabasesClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/mysql/2021-12-01-preview/databases/method_delete.go b/resource-manager/mysql/2021-12-01-preview/databases/method_delete.go new file mode 100644 index 00000000000..8d10b76fa30 --- /dev/null +++ b/resource-manager/mysql/2021-12-01-preview/databases/method_delete.go @@ -0,0 +1,71 @@ +package databases + +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 DatabasesClient) Delete(ctx context.Context, id DatabaseId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 DatabasesClient) DeleteThenPoll(ctx context.Context, id DatabaseId) 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 +} diff --git a/resource-manager/mysql/2021-12-01-preview/databases/method_delete_autorest.go b/resource-manager/mysql/2021-12-01-preview/databases/method_delete_autorest.go deleted file mode 100644 index 13221da85a6..00000000000 --- a/resource-manager/mysql/2021-12-01-preview/databases/method_delete_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package databases - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// Delete ... -func (c DatabasesClient) Delete(ctx context.Context, id DatabaseId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c DatabasesClient) DeleteThenPoll(ctx context.Context, id DatabaseId) error { - result, err := c.Delete(ctx, id) - if err != nil { - return fmt.Errorf("performing Delete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Delete: %+v", err) - } - - return nil -} - -// preparerForDelete prepares the Delete request. -func (c DatabasesClient) preparerForDelete(ctx context.Context, id DatabaseId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDelete sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (c DatabasesClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/mysql/2021-12-01-preview/databases/method_get.go b/resource-manager/mysql/2021-12-01-preview/databases/method_get.go new file mode 100644 index 00000000000..6f2c4fe3341 --- /dev/null +++ b/resource-manager/mysql/2021-12-01-preview/databases/method_get.go @@ -0,0 +1,51 @@ +package databases + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Database +} + +// Get ... +func (c DatabasesClient) Get(ctx context.Context, id DatabaseId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/mysql/2021-12-01-preview/databases/method_get_autorest.go b/resource-manager/mysql/2021-12-01-preview/databases/method_get_autorest.go deleted file mode 100644 index f35d313d226..00000000000 --- a/resource-manager/mysql/2021-12-01-preview/databases/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package databases - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *Database -} - -// Get ... -func (c DatabasesClient) Get(ctx context.Context, id DatabaseId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c DatabasesClient) preparerForGet(ctx context.Context, id DatabaseId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c DatabasesClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/mysql/2021-12-01-preview/databases/method_listbyserver.go b/resource-manager/mysql/2021-12-01-preview/databases/method_listbyserver.go new file mode 100644 index 00000000000..dca5cb1f346 --- /dev/null +++ b/resource-manager/mysql/2021-12-01-preview/databases/method_listbyserver.go @@ -0,0 +1,89 @@ +package databases + +import ( + "context" + "fmt" + "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 ListByServerOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Database +} + +type ListByServerCompleteResult struct { + Items []Database +} + +// ListByServer ... +func (c DatabasesClient) ListByServer(ctx context.Context, id FlexibleServerId) (result ListByServerOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/databases", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Database `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServerComplete retrieves all the results into a single object +func (c DatabasesClient) ListByServerComplete(ctx context.Context, id FlexibleServerId) (ListByServerCompleteResult, error) { + return c.ListByServerCompleteMatchingPredicate(ctx, id, DatabaseOperationPredicate{}) +} + +// ListByServerCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DatabasesClient) ListByServerCompleteMatchingPredicate(ctx context.Context, id FlexibleServerId, predicate DatabaseOperationPredicate) (result ListByServerCompleteResult, err error) { + items := make([]Database, 0) + + resp, err := c.ListByServer(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServerCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/mysql/2021-12-01-preview/databases/method_listbyserver_autorest.go b/resource-manager/mysql/2021-12-01-preview/databases/method_listbyserver_autorest.go deleted file mode 100644 index 5937f9e8958..00000000000 --- a/resource-manager/mysql/2021-12-01-preview/databases/method_listbyserver_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package databases - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByServerOperationResponse struct { - HttpResponse *http.Response - Model *[]Database - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServerOperationResponse, error) -} - -type ListByServerCompleteResult struct { - Items []Database -} - -func (r ListByServerOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServerOperationResponse) LoadMore(ctx context.Context) (resp ListByServerOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByServer ... -func (c DatabasesClient) ListByServer(ctx context.Context, id FlexibleServerId) (resp ListByServerOperationResponse, err error) { - req, err := c.preparerForListByServer(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "ListByServer", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "ListByServer", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByServer(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "ListByServer", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByServer prepares the ListByServer request. -func (c DatabasesClient) preparerForListByServer(ctx context.Context, id FlexibleServerId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/databases", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServerWithNextLink prepares the ListByServer request with the given nextLink token. -func (c DatabasesClient) preparerForListByServerWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByServer handles the response to the ListByServer request. The method always -// closes the http.Response Body. -func (c DatabasesClient) responderForListByServer(resp *http.Response) (result ListByServerOperationResponse, err error) { - type page struct { - Values []Database `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByServerOperationResponse, err error) { - req, err := c.preparerForListByServerWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "ListByServer", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "ListByServer", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByServer(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "ListByServer", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServerComplete retrieves all of the results into a single object -func (c DatabasesClient) ListByServerComplete(ctx context.Context, id FlexibleServerId) (ListByServerCompleteResult, error) { - return c.ListByServerCompleteMatchingPredicate(ctx, id, DatabaseOperationPredicate{}) -} - -// ListByServerCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c DatabasesClient) ListByServerCompleteMatchingPredicate(ctx context.Context, id FlexibleServerId, predicate DatabaseOperationPredicate) (resp ListByServerCompleteResult, err error) { - items := make([]Database, 0) - - page, err := c.ListByServer(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServerCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/mysql/2021-12-01-preview/firewallrules/client.go b/resource-manager/mysql/2021-12-01-preview/firewallrules/client.go index ac01b0459a1..6493e429eb1 100644 --- a/resource-manager/mysql/2021-12-01-preview/firewallrules/client.go +++ b/resource-manager/mysql/2021-12-01-preview/firewallrules/client.go @@ -1,18 +1,26 @@ package firewallrules -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 FirewallRulesClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewFirewallRulesClientWithBaseURI(endpoint string) FirewallRulesClient { - return FirewallRulesClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewFirewallRulesClientWithBaseURI(api environments.Api) (*FirewallRulesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "firewallrules", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating FirewallRulesClient: %+v", err) } + + return &FirewallRulesClient{ + Client: client, + }, nil } diff --git a/resource-manager/mysql/2021-12-01-preview/firewallrules/method_createorupdate.go b/resource-manager/mysql/2021-12-01-preview/firewallrules/method_createorupdate.go new file mode 100644 index 00000000000..dc64d3809d0 --- /dev/null +++ b/resource-manager/mysql/2021-12-01-preview/firewallrules/method_createorupdate.go @@ -0,0 +1,75 @@ +package firewallrules + +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 +} + +// CreateOrUpdate ... +func (c FirewallRulesClient) CreateOrUpdate(ctx context.Context, id FirewallRuleId, input FirewallRule) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 FirewallRulesClient) CreateOrUpdateThenPoll(ctx context.Context, id FirewallRuleId, input FirewallRule) 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 +} diff --git a/resource-manager/mysql/2021-12-01-preview/firewallrules/method_createorupdate_autorest.go b/resource-manager/mysql/2021-12-01-preview/firewallrules/method_createorupdate_autorest.go deleted file mode 100644 index 0dfa761f1a0..00000000000 --- a/resource-manager/mysql/2021-12-01-preview/firewallrules/method_createorupdate_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package firewallrules - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateOrUpdate ... -func (c FirewallRulesClient) CreateOrUpdate(ctx context.Context, id FirewallRuleId, input FirewallRule) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "firewallrules.FirewallRulesClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "firewallrules.FirewallRulesClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c FirewallRulesClient) CreateOrUpdateThenPoll(ctx context.Context, id FirewallRuleId, input FirewallRule) error { - result, err := c.CreateOrUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateOrUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateOrUpdate: %+v", err) - } - - return nil -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c FirewallRulesClient) preparerForCreateOrUpdate(ctx context.Context, id FirewallRuleId, input FirewallRule) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateOrUpdate sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c FirewallRulesClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/mysql/2021-12-01-preview/firewallrules/method_delete.go b/resource-manager/mysql/2021-12-01-preview/firewallrules/method_delete.go new file mode 100644 index 00000000000..0b8a33693c0 --- /dev/null +++ b/resource-manager/mysql/2021-12-01-preview/firewallrules/method_delete.go @@ -0,0 +1,71 @@ +package firewallrules + +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 FirewallRulesClient) Delete(ctx context.Context, id FirewallRuleId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 FirewallRulesClient) DeleteThenPoll(ctx context.Context, id FirewallRuleId) 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 +} diff --git a/resource-manager/mysql/2021-12-01-preview/firewallrules/method_delete_autorest.go b/resource-manager/mysql/2021-12-01-preview/firewallrules/method_delete_autorest.go deleted file mode 100644 index ec4b290ecdd..00000000000 --- a/resource-manager/mysql/2021-12-01-preview/firewallrules/method_delete_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package firewallrules - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// Delete ... -func (c FirewallRulesClient) Delete(ctx context.Context, id FirewallRuleId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "firewallrules.FirewallRulesClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "firewallrules.FirewallRulesClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c FirewallRulesClient) DeleteThenPoll(ctx context.Context, id FirewallRuleId) error { - result, err := c.Delete(ctx, id) - if err != nil { - return fmt.Errorf("performing Delete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Delete: %+v", err) - } - - return nil -} - -// preparerForDelete prepares the Delete request. -func (c FirewallRulesClient) preparerForDelete(ctx context.Context, id FirewallRuleId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDelete sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (c FirewallRulesClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/mysql/2021-12-01-preview/firewallrules/method_get.go b/resource-manager/mysql/2021-12-01-preview/firewallrules/method_get.go new file mode 100644 index 00000000000..f14c6b31f8d --- /dev/null +++ b/resource-manager/mysql/2021-12-01-preview/firewallrules/method_get.go @@ -0,0 +1,51 @@ +package firewallrules + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *FirewallRule +} + +// Get ... +func (c FirewallRulesClient) Get(ctx context.Context, id FirewallRuleId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/mysql/2021-12-01-preview/firewallrules/method_get_autorest.go b/resource-manager/mysql/2021-12-01-preview/firewallrules/method_get_autorest.go deleted file mode 100644 index 1391c01ba1a..00000000000 --- a/resource-manager/mysql/2021-12-01-preview/firewallrules/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package firewallrules - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *FirewallRule -} - -// Get ... -func (c FirewallRulesClient) Get(ctx context.Context, id FirewallRuleId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "firewallrules.FirewallRulesClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "firewallrules.FirewallRulesClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "firewallrules.FirewallRulesClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c FirewallRulesClient) preparerForGet(ctx context.Context, id FirewallRuleId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c FirewallRulesClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/mysql/2021-12-01-preview/firewallrules/method_listbyserver.go b/resource-manager/mysql/2021-12-01-preview/firewallrules/method_listbyserver.go new file mode 100644 index 00000000000..e187720f151 --- /dev/null +++ b/resource-manager/mysql/2021-12-01-preview/firewallrules/method_listbyserver.go @@ -0,0 +1,89 @@ +package firewallrules + +import ( + "context" + "fmt" + "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 ListByServerOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]FirewallRule +} + +type ListByServerCompleteResult struct { + Items []FirewallRule +} + +// ListByServer ... +func (c FirewallRulesClient) ListByServer(ctx context.Context, id FlexibleServerId) (result ListByServerOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/firewallRules", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]FirewallRule `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServerComplete retrieves all the results into a single object +func (c FirewallRulesClient) ListByServerComplete(ctx context.Context, id FlexibleServerId) (ListByServerCompleteResult, error) { + return c.ListByServerCompleteMatchingPredicate(ctx, id, FirewallRuleOperationPredicate{}) +} + +// ListByServerCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c FirewallRulesClient) ListByServerCompleteMatchingPredicate(ctx context.Context, id FlexibleServerId, predicate FirewallRuleOperationPredicate) (result ListByServerCompleteResult, err error) { + items := make([]FirewallRule, 0) + + resp, err := c.ListByServer(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServerCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/mysql/2021-12-01-preview/firewallrules/method_listbyserver_autorest.go b/resource-manager/mysql/2021-12-01-preview/firewallrules/method_listbyserver_autorest.go deleted file mode 100644 index 82fe51aed30..00000000000 --- a/resource-manager/mysql/2021-12-01-preview/firewallrules/method_listbyserver_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package firewallrules - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByServerOperationResponse struct { - HttpResponse *http.Response - Model *[]FirewallRule - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServerOperationResponse, error) -} - -type ListByServerCompleteResult struct { - Items []FirewallRule -} - -func (r ListByServerOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServerOperationResponse) LoadMore(ctx context.Context) (resp ListByServerOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByServer ... -func (c FirewallRulesClient) ListByServer(ctx context.Context, id FlexibleServerId) (resp ListByServerOperationResponse, err error) { - req, err := c.preparerForListByServer(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "firewallrules.FirewallRulesClient", "ListByServer", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "firewallrules.FirewallRulesClient", "ListByServer", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByServer(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "firewallrules.FirewallRulesClient", "ListByServer", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByServer prepares the ListByServer request. -func (c FirewallRulesClient) preparerForListByServer(ctx context.Context, id FlexibleServerId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/firewallRules", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServerWithNextLink prepares the ListByServer request with the given nextLink token. -func (c FirewallRulesClient) preparerForListByServerWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByServer handles the response to the ListByServer request. The method always -// closes the http.Response Body. -func (c FirewallRulesClient) responderForListByServer(resp *http.Response) (result ListByServerOperationResponse, err error) { - type page struct { - Values []FirewallRule `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByServerOperationResponse, err error) { - req, err := c.preparerForListByServerWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "firewallrules.FirewallRulesClient", "ListByServer", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "firewallrules.FirewallRulesClient", "ListByServer", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByServer(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "firewallrules.FirewallRulesClient", "ListByServer", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServerComplete retrieves all of the results into a single object -func (c FirewallRulesClient) ListByServerComplete(ctx context.Context, id FlexibleServerId) (ListByServerCompleteResult, error) { - return c.ListByServerCompleteMatchingPredicate(ctx, id, FirewallRuleOperationPredicate{}) -} - -// ListByServerCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c FirewallRulesClient) ListByServerCompleteMatchingPredicate(ctx context.Context, id FlexibleServerId, predicate FirewallRuleOperationPredicate) (resp ListByServerCompleteResult, err error) { - items := make([]FirewallRule, 0) - - page, err := c.ListByServer(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServerCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/mysql/2021-12-01-preview/getprivatednszonesuffix/client.go b/resource-manager/mysql/2021-12-01-preview/getprivatednszonesuffix/client.go index ce9cceb6b9a..39cc68bc144 100644 --- a/resource-manager/mysql/2021-12-01-preview/getprivatednszonesuffix/client.go +++ b/resource-manager/mysql/2021-12-01-preview/getprivatednszonesuffix/client.go @@ -1,18 +1,26 @@ package getprivatednszonesuffix -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 GetPrivateDnsZoneSuffixClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewGetPrivateDnsZoneSuffixClientWithBaseURI(endpoint string) GetPrivateDnsZoneSuffixClient { - return GetPrivateDnsZoneSuffixClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewGetPrivateDnsZoneSuffixClientWithBaseURI(api environments.Api) (*GetPrivateDnsZoneSuffixClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "getprivatednszonesuffix", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating GetPrivateDnsZoneSuffixClient: %+v", err) } + + return &GetPrivateDnsZoneSuffixClient{ + Client: client, + }, nil } diff --git a/resource-manager/mysql/2021-12-01-preview/getprivatednszonesuffix/method_execute.go b/resource-manager/mysql/2021-12-01-preview/getprivatednszonesuffix/method_execute.go new file mode 100644 index 00000000000..f00af054dec --- /dev/null +++ b/resource-manager/mysql/2021-12-01-preview/getprivatednszonesuffix/method_execute.go @@ -0,0 +1,51 @@ +package getprivatednszonesuffix + +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 ExecuteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *GetPrivateDnsZoneSuffixResponse +} + +// Execute ... +func (c GetPrivateDnsZoneSuffixClient) Execute(ctx context.Context) (result ExecuteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: "/providers/Microsoft.DBforMySQL/getPrivateDnsZoneSuffix", + } + + 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 +} diff --git a/resource-manager/mysql/2021-12-01-preview/getprivatednszonesuffix/method_execute_autorest.go b/resource-manager/mysql/2021-12-01-preview/getprivatednszonesuffix/method_execute_autorest.go deleted file mode 100644 index e8091abed30..00000000000 --- a/resource-manager/mysql/2021-12-01-preview/getprivatednszonesuffix/method_execute_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package getprivatednszonesuffix - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ExecuteOperationResponse struct { - HttpResponse *http.Response - Model *GetPrivateDnsZoneSuffixResponse -} - -// Execute ... -func (c GetPrivateDnsZoneSuffixClient) Execute(ctx context.Context) (result ExecuteOperationResponse, err error) { - req, err := c.preparerForExecute(ctx) - if err != nil { - err = autorest.NewErrorWithError(err, "getprivatednszonesuffix.GetPrivateDnsZoneSuffixClient", "Execute", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "getprivatednszonesuffix.GetPrivateDnsZoneSuffixClient", "Execute", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForExecute(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "getprivatednszonesuffix.GetPrivateDnsZoneSuffixClient", "Execute", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForExecute prepares the Execute request. -func (c GetPrivateDnsZoneSuffixClient) preparerForExecute(ctx context.Context) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath("/providers/Microsoft.DBforMySQL/getPrivateDnsZoneSuffix"), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForExecute handles the response to the Execute request. The method always -// closes the http.Response Body. -func (c GetPrivateDnsZoneSuffixClient) responderForExecute(resp *http.Response) (result ExecuteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/mysql/2021-12-01-preview/locationbasedcapabilities/client.go b/resource-manager/mysql/2021-12-01-preview/locationbasedcapabilities/client.go index 7c8f88e30d1..c7ed45f57a6 100644 --- a/resource-manager/mysql/2021-12-01-preview/locationbasedcapabilities/client.go +++ b/resource-manager/mysql/2021-12-01-preview/locationbasedcapabilities/client.go @@ -1,18 +1,26 @@ package locationbasedcapabilities -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 LocationBasedCapabilitiesClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewLocationBasedCapabilitiesClientWithBaseURI(endpoint string) LocationBasedCapabilitiesClient { - return LocationBasedCapabilitiesClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewLocationBasedCapabilitiesClientWithBaseURI(api environments.Api) (*LocationBasedCapabilitiesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "locationbasedcapabilities", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating LocationBasedCapabilitiesClient: %+v", err) } + + return &LocationBasedCapabilitiesClient{ + Client: client, + }, nil } diff --git a/resource-manager/mysql/2021-12-01-preview/locationbasedcapabilities/method_list.go b/resource-manager/mysql/2021-12-01-preview/locationbasedcapabilities/method_list.go new file mode 100644 index 00000000000..34b87056703 --- /dev/null +++ b/resource-manager/mysql/2021-12-01-preview/locationbasedcapabilities/method_list.go @@ -0,0 +1,89 @@ +package locationbasedcapabilities + +import ( + "context" + "fmt" + "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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CapabilityProperties +} + +type ListCompleteResult struct { + Items []CapabilityProperties +} + +// List ... +func (c LocationBasedCapabilitiesClient) List(ctx context.Context, id LocationId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/capabilities", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]CapabilityProperties `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c LocationBasedCapabilitiesClient) ListComplete(ctx context.Context, id LocationId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, CapabilityPropertiesOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c LocationBasedCapabilitiesClient) ListCompleteMatchingPredicate(ctx context.Context, id LocationId, predicate CapabilityPropertiesOperationPredicate) (result ListCompleteResult, err error) { + items := make([]CapabilityProperties, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/mysql/2021-12-01-preview/locationbasedcapabilities/method_list_autorest.go b/resource-manager/mysql/2021-12-01-preview/locationbasedcapabilities/method_list_autorest.go deleted file mode 100644 index 0d25a07068a..00000000000 --- a/resource-manager/mysql/2021-12-01-preview/locationbasedcapabilities/method_list_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package locationbasedcapabilities - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListOperationResponse struct { - HttpResponse *http.Response - Model *[]CapabilityProperties - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []CapabilityProperties -} - -func (r ListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// List ... -func (c LocationBasedCapabilitiesClient) List(ctx context.Context, id LocationId) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "locationbasedcapabilities.LocationBasedCapabilitiesClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "locationbasedcapabilities.LocationBasedCapabilitiesClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "locationbasedcapabilities.LocationBasedCapabilitiesClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c LocationBasedCapabilitiesClient) preparerForList(ctx context.Context, id LocationId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/capabilities", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c LocationBasedCapabilitiesClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForList handles the response to the List request. The method always -// closes the http.Response Body. -func (c LocationBasedCapabilitiesClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []CapabilityProperties `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { - req, err := c.preparerForListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "locationbasedcapabilities.LocationBasedCapabilitiesClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "locationbasedcapabilities.LocationBasedCapabilitiesClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "locationbasedcapabilities.LocationBasedCapabilitiesClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c LocationBasedCapabilitiesClient) ListComplete(ctx context.Context, id LocationId) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, CapabilityPropertiesOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c LocationBasedCapabilitiesClient) ListCompleteMatchingPredicate(ctx context.Context, id LocationId, predicate CapabilityPropertiesOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]CapabilityProperties, 0) - - page, err := c.List(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/mysql/2021-12-01-preview/logfiles/client.go b/resource-manager/mysql/2021-12-01-preview/logfiles/client.go index 5b776366d70..99d5dad075a 100644 --- a/resource-manager/mysql/2021-12-01-preview/logfiles/client.go +++ b/resource-manager/mysql/2021-12-01-preview/logfiles/client.go @@ -1,18 +1,26 @@ package logfiles -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 LogFilesClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewLogFilesClientWithBaseURI(endpoint string) LogFilesClient { - return LogFilesClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewLogFilesClientWithBaseURI(api environments.Api) (*LogFilesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "logfiles", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating LogFilesClient: %+v", err) } + + return &LogFilesClient{ + Client: client, + }, nil } diff --git a/resource-manager/mysql/2021-12-01-preview/logfiles/method_listbyserver.go b/resource-manager/mysql/2021-12-01-preview/logfiles/method_listbyserver.go new file mode 100644 index 00000000000..515deb3cc8c --- /dev/null +++ b/resource-manager/mysql/2021-12-01-preview/logfiles/method_listbyserver.go @@ -0,0 +1,89 @@ +package logfiles + +import ( + "context" + "fmt" + "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 ListByServerOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]LogFile +} + +type ListByServerCompleteResult struct { + Items []LogFile +} + +// ListByServer ... +func (c LogFilesClient) ListByServer(ctx context.Context, id FlexibleServerId) (result ListByServerOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/logFiles", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]LogFile `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServerComplete retrieves all the results into a single object +func (c LogFilesClient) ListByServerComplete(ctx context.Context, id FlexibleServerId) (ListByServerCompleteResult, error) { + return c.ListByServerCompleteMatchingPredicate(ctx, id, LogFileOperationPredicate{}) +} + +// ListByServerCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c LogFilesClient) ListByServerCompleteMatchingPredicate(ctx context.Context, id FlexibleServerId, predicate LogFileOperationPredicate) (result ListByServerCompleteResult, err error) { + items := make([]LogFile, 0) + + resp, err := c.ListByServer(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServerCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/mysql/2021-12-01-preview/logfiles/method_listbyserver_autorest.go b/resource-manager/mysql/2021-12-01-preview/logfiles/method_listbyserver_autorest.go deleted file mode 100644 index 1ec55821c53..00000000000 --- a/resource-manager/mysql/2021-12-01-preview/logfiles/method_listbyserver_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package logfiles - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByServerOperationResponse struct { - HttpResponse *http.Response - Model *[]LogFile - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServerOperationResponse, error) -} - -type ListByServerCompleteResult struct { - Items []LogFile -} - -func (r ListByServerOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServerOperationResponse) LoadMore(ctx context.Context) (resp ListByServerOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByServer ... -func (c LogFilesClient) ListByServer(ctx context.Context, id FlexibleServerId) (resp ListByServerOperationResponse, err error) { - req, err := c.preparerForListByServer(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "logfiles.LogFilesClient", "ListByServer", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "logfiles.LogFilesClient", "ListByServer", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByServer(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "logfiles.LogFilesClient", "ListByServer", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByServer prepares the ListByServer request. -func (c LogFilesClient) preparerForListByServer(ctx context.Context, id FlexibleServerId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/logFiles", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServerWithNextLink prepares the ListByServer request with the given nextLink token. -func (c LogFilesClient) preparerForListByServerWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByServer handles the response to the ListByServer request. The method always -// closes the http.Response Body. -func (c LogFilesClient) responderForListByServer(resp *http.Response) (result ListByServerOperationResponse, err error) { - type page struct { - Values []LogFile `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByServerOperationResponse, err error) { - req, err := c.preparerForListByServerWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "logfiles.LogFilesClient", "ListByServer", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "logfiles.LogFilesClient", "ListByServer", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByServer(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "logfiles.LogFilesClient", "ListByServer", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServerComplete retrieves all of the results into a single object -func (c LogFilesClient) ListByServerComplete(ctx context.Context, id FlexibleServerId) (ListByServerCompleteResult, error) { - return c.ListByServerCompleteMatchingPredicate(ctx, id, LogFileOperationPredicate{}) -} - -// ListByServerCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c LogFilesClient) ListByServerCompleteMatchingPredicate(ctx context.Context, id FlexibleServerId, predicate LogFileOperationPredicate) (resp ListByServerCompleteResult, err error) { - items := make([]LogFile, 0) - - page, err := c.ListByServer(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServerCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/mysql/2021-12-01-preview/serverfailover/client.go b/resource-manager/mysql/2021-12-01-preview/serverfailover/client.go index f723c8a149d..d90a9229592 100644 --- a/resource-manager/mysql/2021-12-01-preview/serverfailover/client.go +++ b/resource-manager/mysql/2021-12-01-preview/serverfailover/client.go @@ -1,18 +1,26 @@ package serverfailover -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 ServerFailoverClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewServerFailoverClientWithBaseURI(endpoint string) ServerFailoverClient { - return ServerFailoverClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewServerFailoverClientWithBaseURI(api environments.Api) (*ServerFailoverClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "serverfailover", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ServerFailoverClient: %+v", err) } + + return &ServerFailoverClient{ + Client: client, + }, nil } diff --git a/resource-manager/mysql/2021-12-01-preview/serverfailover/method_serversfailover.go b/resource-manager/mysql/2021-12-01-preview/serverfailover/method_serversfailover.go new file mode 100644 index 00000000000..aa31c631dd0 --- /dev/null +++ b/resource-manager/mysql/2021-12-01-preview/serverfailover/method_serversfailover.go @@ -0,0 +1,70 @@ +package serverfailover + +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 ServersFailoverOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ServersFailover ... +func (c ServerFailoverClient) ServersFailover(ctx context.Context, id FlexibleServerId) (result ServersFailoverOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/failover", 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 +} + +// ServersFailoverThenPoll performs ServersFailover then polls until it's completed +func (c ServerFailoverClient) ServersFailoverThenPoll(ctx context.Context, id FlexibleServerId) error { + result, err := c.ServersFailover(ctx, id) + if err != nil { + return fmt.Errorf("performing ServersFailover: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ServersFailover: %+v", err) + } + + return nil +} diff --git a/resource-manager/mysql/2021-12-01-preview/serverfailover/method_serversfailover_autorest.go b/resource-manager/mysql/2021-12-01-preview/serverfailover/method_serversfailover_autorest.go deleted file mode 100644 index a3d79cc5efa..00000000000 --- a/resource-manager/mysql/2021-12-01-preview/serverfailover/method_serversfailover_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package serverfailover - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ServersFailoverOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// ServersFailover ... -func (c ServerFailoverClient) ServersFailover(ctx context.Context, id FlexibleServerId) (result ServersFailoverOperationResponse, err error) { - req, err := c.preparerForServersFailover(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "serverfailover.ServerFailoverClient", "ServersFailover", nil, "Failure preparing request") - return - } - - result, err = c.senderForServersFailover(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "serverfailover.ServerFailoverClient", "ServersFailover", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// ServersFailoverThenPoll performs ServersFailover then polls until it's completed -func (c ServerFailoverClient) ServersFailoverThenPoll(ctx context.Context, id FlexibleServerId) error { - result, err := c.ServersFailover(ctx, id) - if err != nil { - return fmt.Errorf("performing ServersFailover: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after ServersFailover: %+v", err) - } - - return nil -} - -// preparerForServersFailover prepares the ServersFailover request. -func (c ServerFailoverClient) preparerForServersFailover(ctx context.Context, id FlexibleServerId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/failover", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForServersFailover sends the ServersFailover request. The method will close the -// http.Response Body if it receives an error. -func (c ServerFailoverClient) senderForServersFailover(ctx context.Context, req *http.Request) (future ServersFailoverOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/mysql/2021-12-01-preview/serverrestart/client.go b/resource-manager/mysql/2021-12-01-preview/serverrestart/client.go index 7e3313f4726..dda19ef0b54 100644 --- a/resource-manager/mysql/2021-12-01-preview/serverrestart/client.go +++ b/resource-manager/mysql/2021-12-01-preview/serverrestart/client.go @@ -1,18 +1,26 @@ package serverrestart -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 ServerRestartClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewServerRestartClientWithBaseURI(endpoint string) ServerRestartClient { - return ServerRestartClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewServerRestartClientWithBaseURI(api environments.Api) (*ServerRestartClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "serverrestart", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ServerRestartClient: %+v", err) } + + return &ServerRestartClient{ + Client: client, + }, nil } diff --git a/resource-manager/mysql/2021-12-01-preview/serverrestart/constants.go b/resource-manager/mysql/2021-12-01-preview/serverrestart/constants.go index 136ece086bc..0ce79f8aedc 100644 --- a/resource-manager/mysql/2021-12-01-preview/serverrestart/constants.go +++ b/resource-manager/mysql/2021-12-01-preview/serverrestart/constants.go @@ -1,6 +1,10 @@ package serverrestart -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. @@ -19,6 +23,19 @@ func PossibleValuesForEnableStatusEnum() []string { } } +func (s *EnableStatusEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEnableStatusEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseEnableStatusEnum(input string) (*EnableStatusEnum, error) { vals := map[string]EnableStatusEnum{ "disabled": EnableStatusEnumDisabled, diff --git a/resource-manager/mysql/2021-12-01-preview/serverrestart/method_serversrestart.go b/resource-manager/mysql/2021-12-01-preview/serverrestart/method_serversrestart.go new file mode 100644 index 00000000000..8954c04f305 --- /dev/null +++ b/resource-manager/mysql/2021-12-01-preview/serverrestart/method_serversrestart.go @@ -0,0 +1,74 @@ +package serverrestart + +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 ServersRestartOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ServersRestart ... +func (c ServerRestartClient) ServersRestart(ctx context.Context, id FlexibleServerId, input ServerRestartParameter) (result ServersRestartOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restart", 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 +} + +// ServersRestartThenPoll performs ServersRestart then polls until it's completed +func (c ServerRestartClient) ServersRestartThenPoll(ctx context.Context, id FlexibleServerId, input ServerRestartParameter) error { + result, err := c.ServersRestart(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ServersRestart: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ServersRestart: %+v", err) + } + + return nil +} diff --git a/resource-manager/mysql/2021-12-01-preview/serverrestart/method_serversrestart_autorest.go b/resource-manager/mysql/2021-12-01-preview/serverrestart/method_serversrestart_autorest.go deleted file mode 100644 index c0c843cd1e2..00000000000 --- a/resource-manager/mysql/2021-12-01-preview/serverrestart/method_serversrestart_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package serverrestart - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ServersRestartOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// ServersRestart ... -func (c ServerRestartClient) ServersRestart(ctx context.Context, id FlexibleServerId, input ServerRestartParameter) (result ServersRestartOperationResponse, err error) { - req, err := c.preparerForServersRestart(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "serverrestart.ServerRestartClient", "ServersRestart", nil, "Failure preparing request") - return - } - - result, err = c.senderForServersRestart(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "serverrestart.ServerRestartClient", "ServersRestart", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// ServersRestartThenPoll performs ServersRestart then polls until it's completed -func (c ServerRestartClient) ServersRestartThenPoll(ctx context.Context, id FlexibleServerId, input ServerRestartParameter) error { - result, err := c.ServersRestart(ctx, id, input) - if err != nil { - return fmt.Errorf("performing ServersRestart: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after ServersRestart: %+v", err) - } - - return nil -} - -// preparerForServersRestart prepares the ServersRestart request. -func (c ServerRestartClient) preparerForServersRestart(ctx context.Context, id FlexibleServerId, input ServerRestartParameter) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/restart", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForServersRestart sends the ServersRestart request. The method will close the -// http.Response Body if it receives an error. -func (c ServerRestartClient) senderForServersRestart(ctx context.Context, req *http.Request) (future ServersRestartOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/mysql/2021-12-01-preview/servers/client.go b/resource-manager/mysql/2021-12-01-preview/servers/client.go index fd9e02ba599..a1e11668771 100644 --- a/resource-manager/mysql/2021-12-01-preview/servers/client.go +++ b/resource-manager/mysql/2021-12-01-preview/servers/client.go @@ -1,18 +1,26 @@ package servers -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 ServersClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewServersClientWithBaseURI(endpoint string) ServersClient { - return ServersClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewServersClientWithBaseURI(api environments.Api) (*ServersClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "servers", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ServersClient: %+v", err) } + + return &ServersClient{ + Client: client, + }, nil } diff --git a/resource-manager/mysql/2021-12-01-preview/servers/constants.go b/resource-manager/mysql/2021-12-01-preview/servers/constants.go index 9c01b32c11d..38f0dee4a21 100644 --- a/resource-manager/mysql/2021-12-01-preview/servers/constants.go +++ b/resource-manager/mysql/2021-12-01-preview/servers/constants.go @@ -1,6 +1,10 @@ package servers -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. @@ -23,6 +27,19 @@ func PossibleValuesForCreateMode() []string { } } +func (s *CreateMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCreateMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseCreateMode(input string) (*CreateMode, error) { vals := map[string]CreateMode{ "default": CreateModeDefault, @@ -53,6 +70,19 @@ func PossibleValuesForDataEncryptionType() []string { } } +func (s *DataEncryptionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDataEncryptionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseDataEncryptionType(input string) (*DataEncryptionType, error) { vals := map[string]DataEncryptionType{ "azurekeyvault": DataEncryptionTypeAzureKeyVault, @@ -81,6 +111,19 @@ func PossibleValuesForEnableStatusEnum() []string { } } +func (s *EnableStatusEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEnableStatusEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseEnableStatusEnum(input string) (*EnableStatusEnum, error) { vals := map[string]EnableStatusEnum{ "disabled": EnableStatusEnumDisabled, @@ -111,6 +154,19 @@ func PossibleValuesForHighAvailabilityMode() []string { } } +func (s *HighAvailabilityMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHighAvailabilityMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseHighAvailabilityMode(input string) (*HighAvailabilityMode, error) { vals := map[string]HighAvailabilityMode{ "disabled": HighAvailabilityModeDisabled, @@ -146,6 +202,19 @@ func PossibleValuesForHighAvailabilityState() []string { } } +func (s *HighAvailabilityState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHighAvailabilityState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseHighAvailabilityState(input string) (*HighAvailabilityState, error) { vals := map[string]HighAvailabilityState{ "creatingstandby": HighAvailabilityStateCreatingStandby, @@ -175,6 +244,19 @@ func PossibleValuesForManagedServiceIdentityType() []string { } } +func (s *ManagedServiceIdentityType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedServiceIdentityType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseManagedServiceIdentityType(input string) (*ManagedServiceIdentityType, error) { vals := map[string]ManagedServiceIdentityType{ "userassigned": ManagedServiceIdentityTypeUserAssigned, @@ -204,6 +286,19 @@ func PossibleValuesForReplicationRole() []string { } } +func (s *ReplicationRole) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseReplicationRole(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseReplicationRole(input string) (*ReplicationRole, error) { vals := map[string]ReplicationRole{ "none": ReplicationRoleNone, @@ -243,6 +338,19 @@ func PossibleValuesForServerState() []string { } } +func (s *ServerState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServerState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseServerState(input string) (*ServerState, error) { vals := map[string]ServerState{ "disabled": ServerStateDisabled, @@ -276,6 +384,19 @@ func PossibleValuesForServerVersion() []string { } } +func (s *ServerVersion) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServerVersion(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseServerVersion(input string) (*ServerVersion, error) { vals := map[string]ServerVersion{ "8.0.21": ServerVersionEightPointZeroPointTwoOne, @@ -306,6 +427,19 @@ func PossibleValuesForSkuTier() []string { } } +func (s *SkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseSkuTier(input string) (*SkuTier, error) { vals := map[string]SkuTier{ "burstable": SkuTierBurstable, diff --git a/resource-manager/mysql/2021-12-01-preview/servers/method_create.go b/resource-manager/mysql/2021-12-01-preview/servers/method_create.go new file mode 100644 index 00000000000..7d5c992b539 --- /dev/null +++ b/resource-manager/mysql/2021-12-01-preview/servers/method_create.go @@ -0,0 +1,75 @@ +package servers + +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 CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Create ... +func (c ServersClient) Create(ctx context.Context, id FlexibleServerId, input Server) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c ServersClient) CreateThenPoll(ctx context.Context, id FlexibleServerId, input Server) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/mysql/2021-12-01-preview/servers/method_create_autorest.go b/resource-manager/mysql/2021-12-01-preview/servers/method_create_autorest.go deleted file mode 100644 index f7cd73566e6..00000000000 --- a/resource-manager/mysql/2021-12-01-preview/servers/method_create_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package servers - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Create ... -func (c ServersClient) Create(ctx context.Context, id FlexibleServerId, input Server) (result CreateOperationResponse, err error) { - req, err := c.preparerForCreate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "Create", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "Create", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateThenPoll performs Create then polls until it's completed -func (c ServersClient) CreateThenPoll(ctx context.Context, id FlexibleServerId, input Server) error { - result, err := c.Create(ctx, id, input) - if err != nil { - return fmt.Errorf("performing Create: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Create: %+v", err) - } - - return nil -} - -// preparerForCreate prepares the Create request. -func (c ServersClient) preparerForCreate(ctx context.Context, id FlexibleServerId, input Server) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreate sends the Create request. The method will close the -// http.Response Body if it receives an error. -func (c ServersClient) senderForCreate(ctx context.Context, req *http.Request) (future CreateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/mysql/2021-12-01-preview/servers/method_delete.go b/resource-manager/mysql/2021-12-01-preview/servers/method_delete.go new file mode 100644 index 00000000000..c2dab4be6e1 --- /dev/null +++ b/resource-manager/mysql/2021-12-01-preview/servers/method_delete.go @@ -0,0 +1,71 @@ +package servers + +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 ServersClient) Delete(ctx context.Context, id FlexibleServerId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 ServersClient) DeleteThenPoll(ctx context.Context, id FlexibleServerId) 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 +} diff --git a/resource-manager/mysql/2021-12-01-preview/servers/method_delete_autorest.go b/resource-manager/mysql/2021-12-01-preview/servers/method_delete_autorest.go deleted file mode 100644 index d05fd1a076a..00000000000 --- a/resource-manager/mysql/2021-12-01-preview/servers/method_delete_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package servers - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// Delete ... -func (c ServersClient) Delete(ctx context.Context, id FlexibleServerId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c ServersClient) DeleteThenPoll(ctx context.Context, id FlexibleServerId) error { - result, err := c.Delete(ctx, id) - if err != nil { - return fmt.Errorf("performing Delete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Delete: %+v", err) - } - - return nil -} - -// preparerForDelete prepares the Delete request. -func (c ServersClient) preparerForDelete(ctx context.Context, id FlexibleServerId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDelete sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (c ServersClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/mysql/2021-12-01-preview/servers/method_get.go b/resource-manager/mysql/2021-12-01-preview/servers/method_get.go new file mode 100644 index 00000000000..7ec2c3f3db3 --- /dev/null +++ b/resource-manager/mysql/2021-12-01-preview/servers/method_get.go @@ -0,0 +1,51 @@ +package servers + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Server +} + +// Get ... +func (c ServersClient) Get(ctx context.Context, id FlexibleServerId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/mysql/2021-12-01-preview/servers/method_get_autorest.go b/resource-manager/mysql/2021-12-01-preview/servers/method_get_autorest.go deleted file mode 100644 index bb0074a3085..00000000000 --- a/resource-manager/mysql/2021-12-01-preview/servers/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package servers - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *Server -} - -// Get ... -func (c ServersClient) Get(ctx context.Context, id FlexibleServerId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ServersClient) preparerForGet(ctx context.Context, id FlexibleServerId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c ServersClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/mysql/2021-12-01-preview/servers/method_list.go b/resource-manager/mysql/2021-12-01-preview/servers/method_list.go new file mode 100644 index 00000000000..50c7b1709d1 --- /dev/null +++ b/resource-manager/mysql/2021-12-01-preview/servers/method_list.go @@ -0,0 +1,90 @@ +package servers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Server +} + +type ListCompleteResult struct { + Items []Server +} + +// List ... +func (c ServersClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.DBforMySQL/flexibleServers", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Server `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ServersClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, ServerOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ServersClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ServerOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Server, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/mysql/2021-12-01-preview/servers/method_list_autorest.go b/resource-manager/mysql/2021-12-01-preview/servers/method_list_autorest.go deleted file mode 100644 index fb15e88ae69..00000000000 --- a/resource-manager/mysql/2021-12-01-preview/servers/method_list_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package servers - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListOperationResponse struct { - HttpResponse *http.Response - Model *[]Server - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []Server -} - -func (r ListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// List ... -func (c ServersClient) List(ctx context.Context, id commonids.SubscriptionId) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c ServersClient) preparerForList(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.DBforMySQL/flexibleServers", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c ServersClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForList handles the response to the List request. The method always -// closes the http.Response Body. -func (c ServersClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []Server `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { - req, err := c.preparerForListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c ServersClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, ServerOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ServersClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ServerOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]Server, 0) - - page, err := c.List(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/mysql/2021-12-01-preview/servers/method_listbyresourcegroup.go b/resource-manager/mysql/2021-12-01-preview/servers/method_listbyresourcegroup.go new file mode 100644 index 00000000000..d7037bf20b2 --- /dev/null +++ b/resource-manager/mysql/2021-12-01-preview/servers/method_listbyresourcegroup.go @@ -0,0 +1,90 @@ +package servers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Server +} + +type ListByResourceGroupCompleteResult struct { + Items []Server +} + +// ListByResourceGroup ... +func (c ServersClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.DBforMySQL/flexibleServers", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Server `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c ServersClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, ServerOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ServersClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ServerOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]Server, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/mysql/2021-12-01-preview/servers/method_listbyresourcegroup_autorest.go b/resource-manager/mysql/2021-12-01-preview/servers/method_listbyresourcegroup_autorest.go deleted file mode 100644 index 6d0822e633f..00000000000 --- a/resource-manager/mysql/2021-12-01-preview/servers/method_listbyresourcegroup_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package servers - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByResourceGroupOperationResponse struct { - HttpResponse *http.Response - Model *[]Server - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByResourceGroupOperationResponse, error) -} - -type ListByResourceGroupCompleteResult struct { - Items []Server -} - -func (r ListByResourceGroupOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByResourceGroupOperationResponse) LoadMore(ctx context.Context) (resp ListByResourceGroupOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByResourceGroup ... -func (c ServersClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (resp ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroup(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "ListByResourceGroup", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByResourceGroup(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "ListByResourceGroup", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByResourceGroup prepares the ListByResourceGroup request. -func (c ServersClient) preparerForListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.DBforMySQL/flexibleServers", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByResourceGroupWithNextLink prepares the ListByResourceGroup request with the given nextLink token. -func (c ServersClient) preparerForListByResourceGroupWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByResourceGroup handles the response to the ListByResourceGroup request. The method always -// closes the http.Response Body. -func (c ServersClient) responderForListByResourceGroup(resp *http.Response) (result ListByResourceGroupOperationResponse, err error) { - type page struct { - Values []Server `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroupWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "ListByResourceGroup", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByResourceGroup(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "ListByResourceGroup", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByResourceGroupComplete retrieves all of the results into a single object -func (c ServersClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { - return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, ServerOperationPredicate{}) -} - -// ListByResourceGroupCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ServersClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ServerOperationPredicate) (resp ListByResourceGroupCompleteResult, err error) { - items := make([]Server, 0) - - page, err := c.ListByResourceGroup(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByResourceGroupCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/mysql/2021-12-01-preview/servers/method_replicaslistbyserver.go b/resource-manager/mysql/2021-12-01-preview/servers/method_replicaslistbyserver.go new file mode 100644 index 00000000000..91d61596f4f --- /dev/null +++ b/resource-manager/mysql/2021-12-01-preview/servers/method_replicaslistbyserver.go @@ -0,0 +1,89 @@ +package servers + +import ( + "context" + "fmt" + "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 ReplicasListByServerOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Server +} + +type ReplicasListByServerCompleteResult struct { + Items []Server +} + +// ReplicasListByServer ... +func (c ServersClient) ReplicasListByServer(ctx context.Context, id FlexibleServerId) (result ReplicasListByServerOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/replicas", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Server `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ReplicasListByServerComplete retrieves all the results into a single object +func (c ServersClient) ReplicasListByServerComplete(ctx context.Context, id FlexibleServerId) (ReplicasListByServerCompleteResult, error) { + return c.ReplicasListByServerCompleteMatchingPredicate(ctx, id, ServerOperationPredicate{}) +} + +// ReplicasListByServerCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ServersClient) ReplicasListByServerCompleteMatchingPredicate(ctx context.Context, id FlexibleServerId, predicate ServerOperationPredicate) (result ReplicasListByServerCompleteResult, err error) { + items := make([]Server, 0) + + resp, err := c.ReplicasListByServer(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ReplicasListByServerCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/mysql/2021-12-01-preview/servers/method_replicaslistbyserver_autorest.go b/resource-manager/mysql/2021-12-01-preview/servers/method_replicaslistbyserver_autorest.go deleted file mode 100644 index c0bf40cf8b3..00000000000 --- a/resource-manager/mysql/2021-12-01-preview/servers/method_replicaslistbyserver_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package servers - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ReplicasListByServerOperationResponse struct { - HttpResponse *http.Response - Model *[]Server - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ReplicasListByServerOperationResponse, error) -} - -type ReplicasListByServerCompleteResult struct { - Items []Server -} - -func (r ReplicasListByServerOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ReplicasListByServerOperationResponse) LoadMore(ctx context.Context) (resp ReplicasListByServerOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ReplicasListByServer ... -func (c ServersClient) ReplicasListByServer(ctx context.Context, id FlexibleServerId) (resp ReplicasListByServerOperationResponse, err error) { - req, err := c.preparerForReplicasListByServer(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "ReplicasListByServer", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "ReplicasListByServer", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForReplicasListByServer(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "ReplicasListByServer", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForReplicasListByServer prepares the ReplicasListByServer request. -func (c ServersClient) preparerForReplicasListByServer(ctx context.Context, id FlexibleServerId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/replicas", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForReplicasListByServerWithNextLink prepares the ReplicasListByServer request with the given nextLink token. -func (c ServersClient) preparerForReplicasListByServerWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForReplicasListByServer handles the response to the ReplicasListByServer request. The method always -// closes the http.Response Body. -func (c ServersClient) responderForReplicasListByServer(resp *http.Response) (result ReplicasListByServerOperationResponse, err error) { - type page struct { - Values []Server `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ReplicasListByServerOperationResponse, err error) { - req, err := c.preparerForReplicasListByServerWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "ReplicasListByServer", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "ReplicasListByServer", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForReplicasListByServer(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "ReplicasListByServer", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ReplicasListByServerComplete retrieves all of the results into a single object -func (c ServersClient) ReplicasListByServerComplete(ctx context.Context, id FlexibleServerId) (ReplicasListByServerCompleteResult, error) { - return c.ReplicasListByServerCompleteMatchingPredicate(ctx, id, ServerOperationPredicate{}) -} - -// ReplicasListByServerCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ServersClient) ReplicasListByServerCompleteMatchingPredicate(ctx context.Context, id FlexibleServerId, predicate ServerOperationPredicate) (resp ReplicasListByServerCompleteResult, err error) { - items := make([]Server, 0) - - page, err := c.ReplicasListByServer(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ReplicasListByServerCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/mysql/2021-12-01-preview/servers/method_update.go b/resource-manager/mysql/2021-12-01-preview/servers/method_update.go new file mode 100644 index 00000000000..c25f4634b6d --- /dev/null +++ b/resource-manager/mysql/2021-12-01-preview/servers/method_update.go @@ -0,0 +1,74 @@ +package servers + +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 UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Update ... +func (c ServersClient) Update(ctx context.Context, id FlexibleServerId, input ServerForUpdate) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + 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 +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c ServersClient) UpdateThenPoll(ctx context.Context, id FlexibleServerId, input ServerForUpdate) error { + result, err := c.Update(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/resource-manager/mysql/2021-12-01-preview/servers/method_update_autorest.go b/resource-manager/mysql/2021-12-01-preview/servers/method_update_autorest.go deleted file mode 100644 index 588b1305994..00000000000 --- a/resource-manager/mysql/2021-12-01-preview/servers/method_update_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package servers - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Update ... -func (c ServersClient) Update(ctx context.Context, id FlexibleServerId, input ServerForUpdate) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "Update", nil, "Failure preparing request") - return - } - - result, err = c.senderForUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// UpdateThenPoll performs Update then polls until it's completed -func (c ServersClient) UpdateThenPoll(ctx context.Context, id FlexibleServerId, input ServerForUpdate) error { - result, err := c.Update(ctx, id, input) - if err != nil { - return fmt.Errorf("performing Update: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Update: %+v", err) - } - - return nil -} - -// preparerForUpdate prepares the Update request. -func (c ServersClient) preparerForUpdate(ctx context.Context, id FlexibleServerId, input ServerForUpdate) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForUpdate sends the Update request. The method will close the -// http.Response Body if it receives an error. -func (c ServersClient) senderForUpdate(ctx context.Context, req *http.Request) (future UpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/mysql/2021-12-01-preview/serverstart/client.go b/resource-manager/mysql/2021-12-01-preview/serverstart/client.go index 035bd9107ce..f24d38e00f9 100644 --- a/resource-manager/mysql/2021-12-01-preview/serverstart/client.go +++ b/resource-manager/mysql/2021-12-01-preview/serverstart/client.go @@ -1,18 +1,26 @@ package serverstart -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 ServerStartClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewServerStartClientWithBaseURI(endpoint string) ServerStartClient { - return ServerStartClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewServerStartClientWithBaseURI(api environments.Api) (*ServerStartClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "serverstart", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ServerStartClient: %+v", err) } + + return &ServerStartClient{ + Client: client, + }, nil } diff --git a/resource-manager/mysql/2021-12-01-preview/serverstart/method_serversstart.go b/resource-manager/mysql/2021-12-01-preview/serverstart/method_serversstart.go new file mode 100644 index 00000000000..195d7ff6855 --- /dev/null +++ b/resource-manager/mysql/2021-12-01-preview/serverstart/method_serversstart.go @@ -0,0 +1,70 @@ +package serverstart + +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 ServersStartOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ServersStart ... +func (c ServerStartClient) ServersStart(ctx context.Context, id FlexibleServerId) (result ServersStartOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/start", 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 +} + +// ServersStartThenPoll performs ServersStart then polls until it's completed +func (c ServerStartClient) ServersStartThenPoll(ctx context.Context, id FlexibleServerId) error { + result, err := c.ServersStart(ctx, id) + if err != nil { + return fmt.Errorf("performing ServersStart: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ServersStart: %+v", err) + } + + return nil +} diff --git a/resource-manager/mysql/2021-12-01-preview/serverstart/method_serversstart_autorest.go b/resource-manager/mysql/2021-12-01-preview/serverstart/method_serversstart_autorest.go deleted file mode 100644 index d9ba15437e8..00000000000 --- a/resource-manager/mysql/2021-12-01-preview/serverstart/method_serversstart_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package serverstart - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ServersStartOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// ServersStart ... -func (c ServerStartClient) ServersStart(ctx context.Context, id FlexibleServerId) (result ServersStartOperationResponse, err error) { - req, err := c.preparerForServersStart(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "serverstart.ServerStartClient", "ServersStart", nil, "Failure preparing request") - return - } - - result, err = c.senderForServersStart(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "serverstart.ServerStartClient", "ServersStart", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// ServersStartThenPoll performs ServersStart then polls until it's completed -func (c ServerStartClient) ServersStartThenPoll(ctx context.Context, id FlexibleServerId) error { - result, err := c.ServersStart(ctx, id) - if err != nil { - return fmt.Errorf("performing ServersStart: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after ServersStart: %+v", err) - } - - return nil -} - -// preparerForServersStart prepares the ServersStart request. -func (c ServerStartClient) preparerForServersStart(ctx context.Context, id FlexibleServerId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/start", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForServersStart sends the ServersStart request. The method will close the -// http.Response Body if it receives an error. -func (c ServerStartClient) senderForServersStart(ctx context.Context, req *http.Request) (future ServersStartOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/mysql/2021-12-01-preview/serverstop/client.go b/resource-manager/mysql/2021-12-01-preview/serverstop/client.go index 488dece59ac..c47cb0e7335 100644 --- a/resource-manager/mysql/2021-12-01-preview/serverstop/client.go +++ b/resource-manager/mysql/2021-12-01-preview/serverstop/client.go @@ -1,18 +1,26 @@ package serverstop -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 ServerStopClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewServerStopClientWithBaseURI(endpoint string) ServerStopClient { - return ServerStopClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewServerStopClientWithBaseURI(api environments.Api) (*ServerStopClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "serverstop", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ServerStopClient: %+v", err) } + + return &ServerStopClient{ + Client: client, + }, nil } diff --git a/resource-manager/mysql/2021-12-01-preview/serverstop/method_serversstop.go b/resource-manager/mysql/2021-12-01-preview/serverstop/method_serversstop.go new file mode 100644 index 00000000000..f63fd390edb --- /dev/null +++ b/resource-manager/mysql/2021-12-01-preview/serverstop/method_serversstop.go @@ -0,0 +1,70 @@ +package serverstop + +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 ServersStopOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ServersStop ... +func (c ServerStopClient) ServersStop(ctx context.Context, id FlexibleServerId) (result ServersStopOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/stop", 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 +} + +// ServersStopThenPoll performs ServersStop then polls until it's completed +func (c ServerStopClient) ServersStopThenPoll(ctx context.Context, id FlexibleServerId) error { + result, err := c.ServersStop(ctx, id) + if err != nil { + return fmt.Errorf("performing ServersStop: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ServersStop: %+v", err) + } + + return nil +} diff --git a/resource-manager/mysql/2021-12-01-preview/serverstop/method_serversstop_autorest.go b/resource-manager/mysql/2021-12-01-preview/serverstop/method_serversstop_autorest.go deleted file mode 100644 index cc1b5c74e6a..00000000000 --- a/resource-manager/mysql/2021-12-01-preview/serverstop/method_serversstop_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package serverstop - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ServersStopOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// ServersStop ... -func (c ServerStopClient) ServersStop(ctx context.Context, id FlexibleServerId) (result ServersStopOperationResponse, err error) { - req, err := c.preparerForServersStop(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "serverstop.ServerStopClient", "ServersStop", nil, "Failure preparing request") - return - } - - result, err = c.senderForServersStop(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "serverstop.ServerStopClient", "ServersStop", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// ServersStopThenPoll performs ServersStop then polls until it's completed -func (c ServerStopClient) ServersStopThenPoll(ctx context.Context, id FlexibleServerId) error { - result, err := c.ServersStop(ctx, id) - if err != nil { - return fmt.Errorf("performing ServersStop: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after ServersStop: %+v", err) - } - - return nil -} - -// preparerForServersStop prepares the ServersStop request. -func (c ServerStopClient) preparerForServersStop(ctx context.Context, id FlexibleServerId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/stop", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForServersStop sends the ServersStop request. The method will close the -// http.Response Body if it receives an error. -func (c ServerStopClient) senderForServersStop(ctx context.Context, req *http.Request) (future ServersStopOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/mysql/2022-01-01/azureadadministrators/client.go b/resource-manager/mysql/2022-01-01/azureadadministrators/client.go index 4e49ebc04ec..eb020534988 100644 --- a/resource-manager/mysql/2022-01-01/azureadadministrators/client.go +++ b/resource-manager/mysql/2022-01-01/azureadadministrators/client.go @@ -1,18 +1,26 @@ package azureadadministrators -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 AzureADAdministratorsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewAzureADAdministratorsClientWithBaseURI(endpoint string) AzureADAdministratorsClient { - return AzureADAdministratorsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewAzureADAdministratorsClientWithBaseURI(api environments.Api) (*AzureADAdministratorsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "azureadadministrators", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AzureADAdministratorsClient: %+v", err) } + + return &AzureADAdministratorsClient{ + Client: client, + }, nil } diff --git a/resource-manager/mysql/2022-01-01/azureadadministrators/constants.go b/resource-manager/mysql/2022-01-01/azureadadministrators/constants.go index 1c7faa91a93..54afc0f8110 100644 --- a/resource-manager/mysql/2022-01-01/azureadadministrators/constants.go +++ b/resource-manager/mysql/2022-01-01/azureadadministrators/constants.go @@ -1,6 +1,10 @@ package azureadadministrators -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. @@ -17,6 +21,19 @@ func PossibleValuesForAdministratorType() []string { } } +func (s *AdministratorType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAdministratorType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAdministratorType(input string) (*AdministratorType, error) { vals := map[string]AdministratorType{ "activedirectory": AdministratorTypeActiveDirectory, diff --git a/resource-manager/mysql/2022-01-01/azureadadministrators/method_createorupdate.go b/resource-manager/mysql/2022-01-01/azureadadministrators/method_createorupdate.go new file mode 100644 index 00000000000..1f6b6ee3f75 --- /dev/null +++ b/resource-manager/mysql/2022-01-01/azureadadministrators/method_createorupdate.go @@ -0,0 +1,75 @@ +package azureadadministrators + +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 +} + +// CreateOrUpdate ... +func (c AzureADAdministratorsClient) CreateOrUpdate(ctx context.Context, id FlexibleServerId, input AzureADAdministrator) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/administrators/ActiveDirectory", 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 AzureADAdministratorsClient) CreateOrUpdateThenPoll(ctx context.Context, id FlexibleServerId, input AzureADAdministrator) 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 +} diff --git a/resource-manager/mysql/2022-01-01/azureadadministrators/method_createorupdate_autorest.go b/resource-manager/mysql/2022-01-01/azureadadministrators/method_createorupdate_autorest.go deleted file mode 100644 index fe63044abfb..00000000000 --- a/resource-manager/mysql/2022-01-01/azureadadministrators/method_createorupdate_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package azureadadministrators - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateOrUpdate ... -func (c AzureADAdministratorsClient) CreateOrUpdate(ctx context.Context, id FlexibleServerId, input AzureADAdministrator) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "azureadadministrators.AzureADAdministratorsClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "azureadadministrators.AzureADAdministratorsClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c AzureADAdministratorsClient) CreateOrUpdateThenPoll(ctx context.Context, id FlexibleServerId, input AzureADAdministrator) error { - result, err := c.CreateOrUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateOrUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateOrUpdate: %+v", err) - } - - return nil -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c AzureADAdministratorsClient) preparerForCreateOrUpdate(ctx context.Context, id FlexibleServerId, input AzureADAdministrator) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/administrators/ActiveDirectory", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateOrUpdate sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c AzureADAdministratorsClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/mysql/2022-01-01/azureadadministrators/method_delete.go b/resource-manager/mysql/2022-01-01/azureadadministrators/method_delete.go new file mode 100644 index 00000000000..02daa781db4 --- /dev/null +++ b/resource-manager/mysql/2022-01-01/azureadadministrators/method_delete.go @@ -0,0 +1,71 @@ +package azureadadministrators + +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 AzureADAdministratorsClient) Delete(ctx context.Context, id FlexibleServerId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: fmt.Sprintf("%s/administrators/ActiveDirectory", 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 AzureADAdministratorsClient) DeleteThenPoll(ctx context.Context, id FlexibleServerId) 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 +} diff --git a/resource-manager/mysql/2022-01-01/azureadadministrators/method_delete_autorest.go b/resource-manager/mysql/2022-01-01/azureadadministrators/method_delete_autorest.go deleted file mode 100644 index 64c9e88c04f..00000000000 --- a/resource-manager/mysql/2022-01-01/azureadadministrators/method_delete_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package azureadadministrators - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// Delete ... -func (c AzureADAdministratorsClient) Delete(ctx context.Context, id FlexibleServerId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "azureadadministrators.AzureADAdministratorsClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "azureadadministrators.AzureADAdministratorsClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c AzureADAdministratorsClient) DeleteThenPoll(ctx context.Context, id FlexibleServerId) error { - result, err := c.Delete(ctx, id) - if err != nil { - return fmt.Errorf("performing Delete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Delete: %+v", err) - } - - return nil -} - -// preparerForDelete prepares the Delete request. -func (c AzureADAdministratorsClient) preparerForDelete(ctx context.Context, id FlexibleServerId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/administrators/ActiveDirectory", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDelete sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (c AzureADAdministratorsClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/mysql/2022-01-01/azureadadministrators/method_get.go b/resource-manager/mysql/2022-01-01/azureadadministrators/method_get.go new file mode 100644 index 00000000000..f9a8c7e7a20 --- /dev/null +++ b/resource-manager/mysql/2022-01-01/azureadadministrators/method_get.go @@ -0,0 +1,52 @@ +package azureadadministrators + +import ( + "context" + "fmt" + "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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AzureADAdministrator +} + +// Get ... +func (c AzureADAdministratorsClient) Get(ctx context.Context, id FlexibleServerId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/administrators/ActiveDirectory", 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 +} diff --git a/resource-manager/mysql/2022-01-01/azureadadministrators/method_get_autorest.go b/resource-manager/mysql/2022-01-01/azureadadministrators/method_get_autorest.go deleted file mode 100644 index 4768f45f1ea..00000000000 --- a/resource-manager/mysql/2022-01-01/azureadadministrators/method_get_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package azureadadministrators - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *AzureADAdministrator -} - -// Get ... -func (c AzureADAdministratorsClient) Get(ctx context.Context, id FlexibleServerId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "azureadadministrators.AzureADAdministratorsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "azureadadministrators.AzureADAdministratorsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "azureadadministrators.AzureADAdministratorsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c AzureADAdministratorsClient) preparerForGet(ctx context.Context, id FlexibleServerId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/administrators/ActiveDirectory", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c AzureADAdministratorsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/mysql/2022-01-01/azureadadministrators/method_listbyserver.go b/resource-manager/mysql/2022-01-01/azureadadministrators/method_listbyserver.go new file mode 100644 index 00000000000..10421bcca6f --- /dev/null +++ b/resource-manager/mysql/2022-01-01/azureadadministrators/method_listbyserver.go @@ -0,0 +1,89 @@ +package azureadadministrators + +import ( + "context" + "fmt" + "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 ListByServerOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AzureADAdministrator +} + +type ListByServerCompleteResult struct { + Items []AzureADAdministrator +} + +// ListByServer ... +func (c AzureADAdministratorsClient) ListByServer(ctx context.Context, id FlexibleServerId) (result ListByServerOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/administrators", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AzureADAdministrator `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServerComplete retrieves all the results into a single object +func (c AzureADAdministratorsClient) ListByServerComplete(ctx context.Context, id FlexibleServerId) (ListByServerCompleteResult, error) { + return c.ListByServerCompleteMatchingPredicate(ctx, id, AzureADAdministratorOperationPredicate{}) +} + +// ListByServerCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AzureADAdministratorsClient) ListByServerCompleteMatchingPredicate(ctx context.Context, id FlexibleServerId, predicate AzureADAdministratorOperationPredicate) (result ListByServerCompleteResult, err error) { + items := make([]AzureADAdministrator, 0) + + resp, err := c.ListByServer(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServerCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/mysql/2022-01-01/azureadadministrators/method_listbyserver_autorest.go b/resource-manager/mysql/2022-01-01/azureadadministrators/method_listbyserver_autorest.go deleted file mode 100644 index 9121e4b6ec9..00000000000 --- a/resource-manager/mysql/2022-01-01/azureadadministrators/method_listbyserver_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package azureadadministrators - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByServerOperationResponse struct { - HttpResponse *http.Response - Model *[]AzureADAdministrator - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServerOperationResponse, error) -} - -type ListByServerCompleteResult struct { - Items []AzureADAdministrator -} - -func (r ListByServerOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServerOperationResponse) LoadMore(ctx context.Context) (resp ListByServerOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByServer ... -func (c AzureADAdministratorsClient) ListByServer(ctx context.Context, id FlexibleServerId) (resp ListByServerOperationResponse, err error) { - req, err := c.preparerForListByServer(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "azureadadministrators.AzureADAdministratorsClient", "ListByServer", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "azureadadministrators.AzureADAdministratorsClient", "ListByServer", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByServer(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "azureadadministrators.AzureADAdministratorsClient", "ListByServer", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByServer prepares the ListByServer request. -func (c AzureADAdministratorsClient) preparerForListByServer(ctx context.Context, id FlexibleServerId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/administrators", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServerWithNextLink prepares the ListByServer request with the given nextLink token. -func (c AzureADAdministratorsClient) preparerForListByServerWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByServer handles the response to the ListByServer request. The method always -// closes the http.Response Body. -func (c AzureADAdministratorsClient) responderForListByServer(resp *http.Response) (result ListByServerOperationResponse, err error) { - type page struct { - Values []AzureADAdministrator `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByServerOperationResponse, err error) { - req, err := c.preparerForListByServerWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "azureadadministrators.AzureADAdministratorsClient", "ListByServer", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "azureadadministrators.AzureADAdministratorsClient", "ListByServer", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByServer(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "azureadadministrators.AzureADAdministratorsClient", "ListByServer", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServerComplete retrieves all of the results into a single object -func (c AzureADAdministratorsClient) ListByServerComplete(ctx context.Context, id FlexibleServerId) (ListByServerCompleteResult, error) { - return c.ListByServerCompleteMatchingPredicate(ctx, id, AzureADAdministratorOperationPredicate{}) -} - -// ListByServerCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c AzureADAdministratorsClient) ListByServerCompleteMatchingPredicate(ctx context.Context, id FlexibleServerId, predicate AzureADAdministratorOperationPredicate) (resp ListByServerCompleteResult, err error) { - items := make([]AzureADAdministrator, 0) - - page, err := c.ListByServer(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServerCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/mysql/2022-01-01/backups/client.go b/resource-manager/mysql/2022-01-01/backups/client.go index 8669bac74ee..ae4432efd22 100644 --- a/resource-manager/mysql/2022-01-01/backups/client.go +++ b/resource-manager/mysql/2022-01-01/backups/client.go @@ -1,18 +1,26 @@ package backups -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 BackupsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewBackupsClientWithBaseURI(endpoint string) BackupsClient { - return BackupsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewBackupsClientWithBaseURI(api environments.Api) (*BackupsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "backups", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating BackupsClient: %+v", err) } + + return &BackupsClient{ + Client: client, + }, nil } diff --git a/resource-manager/mysql/2022-01-01/backups/method_get.go b/resource-manager/mysql/2022-01-01/backups/method_get.go new file mode 100644 index 00000000000..161afc45282 --- /dev/null +++ b/resource-manager/mysql/2022-01-01/backups/method_get.go @@ -0,0 +1,51 @@ +package backups + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ServerBackup +} + +// Get ... +func (c BackupsClient) Get(ctx context.Context, id BackupId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/mysql/2022-01-01/backups/method_get_autorest.go b/resource-manager/mysql/2022-01-01/backups/method_get_autorest.go deleted file mode 100644 index 932c6ce0d6c..00000000000 --- a/resource-manager/mysql/2022-01-01/backups/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package backups - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *ServerBackup -} - -// Get ... -func (c BackupsClient) Get(ctx context.Context, id BackupId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "backups.BackupsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "backups.BackupsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "backups.BackupsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c BackupsClient) preparerForGet(ctx context.Context, id BackupId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c BackupsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/mysql/2022-01-01/backups/method_listbyserver.go b/resource-manager/mysql/2022-01-01/backups/method_listbyserver.go new file mode 100644 index 00000000000..baab7e30266 --- /dev/null +++ b/resource-manager/mysql/2022-01-01/backups/method_listbyserver.go @@ -0,0 +1,89 @@ +package backups + +import ( + "context" + "fmt" + "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 ListByServerOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ServerBackup +} + +type ListByServerCompleteResult struct { + Items []ServerBackup +} + +// ListByServer ... +func (c BackupsClient) ListByServer(ctx context.Context, id FlexibleServerId) (result ListByServerOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/backups", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ServerBackup `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServerComplete retrieves all the results into a single object +func (c BackupsClient) ListByServerComplete(ctx context.Context, id FlexibleServerId) (ListByServerCompleteResult, error) { + return c.ListByServerCompleteMatchingPredicate(ctx, id, ServerBackupOperationPredicate{}) +} + +// ListByServerCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c BackupsClient) ListByServerCompleteMatchingPredicate(ctx context.Context, id FlexibleServerId, predicate ServerBackupOperationPredicate) (result ListByServerCompleteResult, err error) { + items := make([]ServerBackup, 0) + + resp, err := c.ListByServer(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServerCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/mysql/2022-01-01/backups/method_listbyserver_autorest.go b/resource-manager/mysql/2022-01-01/backups/method_listbyserver_autorest.go deleted file mode 100644 index 998090174cf..00000000000 --- a/resource-manager/mysql/2022-01-01/backups/method_listbyserver_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package backups - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByServerOperationResponse struct { - HttpResponse *http.Response - Model *[]ServerBackup - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServerOperationResponse, error) -} - -type ListByServerCompleteResult struct { - Items []ServerBackup -} - -func (r ListByServerOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServerOperationResponse) LoadMore(ctx context.Context) (resp ListByServerOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByServer ... -func (c BackupsClient) ListByServer(ctx context.Context, id FlexibleServerId) (resp ListByServerOperationResponse, err error) { - req, err := c.preparerForListByServer(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "backups.BackupsClient", "ListByServer", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "backups.BackupsClient", "ListByServer", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByServer(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "backups.BackupsClient", "ListByServer", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByServer prepares the ListByServer request. -func (c BackupsClient) preparerForListByServer(ctx context.Context, id FlexibleServerId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/backups", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServerWithNextLink prepares the ListByServer request with the given nextLink token. -func (c BackupsClient) preparerForListByServerWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByServer handles the response to the ListByServer request. The method always -// closes the http.Response Body. -func (c BackupsClient) responderForListByServer(resp *http.Response) (result ListByServerOperationResponse, err error) { - type page struct { - Values []ServerBackup `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByServerOperationResponse, err error) { - req, err := c.preparerForListByServerWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "backups.BackupsClient", "ListByServer", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "backups.BackupsClient", "ListByServer", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByServer(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "backups.BackupsClient", "ListByServer", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServerComplete retrieves all of the results into a single object -func (c BackupsClient) ListByServerComplete(ctx context.Context, id FlexibleServerId) (ListByServerCompleteResult, error) { - return c.ListByServerCompleteMatchingPredicate(ctx, id, ServerBackupOperationPredicate{}) -} - -// ListByServerCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c BackupsClient) ListByServerCompleteMatchingPredicate(ctx context.Context, id FlexibleServerId, predicate ServerBackupOperationPredicate) (resp ListByServerCompleteResult, err error) { - items := make([]ServerBackup, 0) - - page, err := c.ListByServer(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServerCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/mysql/2022-01-01/backups/method_put.go b/resource-manager/mysql/2022-01-01/backups/method_put.go new file mode 100644 index 00000000000..74359bfcefd --- /dev/null +++ b/resource-manager/mysql/2022-01-01/backups/method_put.go @@ -0,0 +1,51 @@ +package backups + +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 PutOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ServerBackup +} + +// Put ... +func (c BackupsClient) Put(ctx context.Context, id BackupId) (result PutOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + 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 +} diff --git a/resource-manager/mysql/2022-01-01/backups/method_put_autorest.go b/resource-manager/mysql/2022-01-01/backups/method_put_autorest.go deleted file mode 100644 index c98190ee043..00000000000 --- a/resource-manager/mysql/2022-01-01/backups/method_put_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package backups - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PutOperationResponse struct { - HttpResponse *http.Response - Model *ServerBackup -} - -// Put ... -func (c BackupsClient) Put(ctx context.Context, id BackupId) (result PutOperationResponse, err error) { - req, err := c.preparerForPut(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "backups.BackupsClient", "Put", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "backups.BackupsClient", "Put", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForPut(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "backups.BackupsClient", "Put", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForPut prepares the Put request. -func (c BackupsClient) preparerForPut(ctx context.Context, id BackupId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForPut handles the response to the Put request. The method always -// closes the http.Response Body. -func (c BackupsClient) responderForPut(resp *http.Response) (result PutOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/mysql/2022-01-01/checknameavailability/client.go b/resource-manager/mysql/2022-01-01/checknameavailability/client.go index a8ea1dabf11..81c73505778 100644 --- a/resource-manager/mysql/2022-01-01/checknameavailability/client.go +++ b/resource-manager/mysql/2022-01-01/checknameavailability/client.go @@ -1,18 +1,26 @@ package checknameavailability -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 CheckNameAvailabilityClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewCheckNameAvailabilityClientWithBaseURI(endpoint string) CheckNameAvailabilityClient { - return CheckNameAvailabilityClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewCheckNameAvailabilityClientWithBaseURI(api environments.Api) (*CheckNameAvailabilityClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "checknameavailability", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CheckNameAvailabilityClient: %+v", err) } + + return &CheckNameAvailabilityClient{ + Client: client, + }, nil } diff --git a/resource-manager/mysql/2022-01-01/checknameavailability/method_execute.go b/resource-manager/mysql/2022-01-01/checknameavailability/method_execute.go new file mode 100644 index 00000000000..319ad5d298b --- /dev/null +++ b/resource-manager/mysql/2022-01-01/checknameavailability/method_execute.go @@ -0,0 +1,56 @@ +package checknameavailability + +import ( + "context" + "fmt" + "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 ExecuteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NameAvailability +} + +// Execute ... +func (c CheckNameAvailabilityClient) Execute(ctx context.Context, id LocationId, input NameAvailabilityRequest) (result ExecuteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/checkNameAvailability", 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 +} diff --git a/resource-manager/mysql/2022-01-01/checknameavailability/method_execute_autorest.go b/resource-manager/mysql/2022-01-01/checknameavailability/method_execute_autorest.go deleted file mode 100644 index abe034c4edd..00000000000 --- a/resource-manager/mysql/2022-01-01/checknameavailability/method_execute_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package checknameavailability - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ExecuteOperationResponse struct { - HttpResponse *http.Response - Model *NameAvailability -} - -// Execute ... -func (c CheckNameAvailabilityClient) Execute(ctx context.Context, id LocationId, input NameAvailabilityRequest) (result ExecuteOperationResponse, err error) { - req, err := c.preparerForExecute(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "checknameavailability.CheckNameAvailabilityClient", "Execute", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "checknameavailability.CheckNameAvailabilityClient", "Execute", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForExecute(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "checknameavailability.CheckNameAvailabilityClient", "Execute", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForExecute prepares the Execute request. -func (c CheckNameAvailabilityClient) preparerForExecute(ctx context.Context, id LocationId, input NameAvailabilityRequest) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/checkNameAvailability", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForExecute handles the response to the Execute request. The method always -// closes the http.Response Body. -func (c CheckNameAvailabilityClient) responderForExecute(resp *http.Response) (result ExecuteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/mysql/2022-01-01/checknameavailability/method_withoutlocationexecute.go b/resource-manager/mysql/2022-01-01/checknameavailability/method_withoutlocationexecute.go new file mode 100644 index 00000000000..875573b0386 --- /dev/null +++ b/resource-manager/mysql/2022-01-01/checknameavailability/method_withoutlocationexecute.go @@ -0,0 +1,57 @@ +package checknameavailability + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 WithoutLocationExecuteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NameAvailability +} + +// WithoutLocationExecute ... +func (c CheckNameAvailabilityClient) WithoutLocationExecute(ctx context.Context, id commonids.SubscriptionId, input NameAvailabilityRequest) (result WithoutLocationExecuteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.DBforMySQL/checkNameAvailability", 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 +} diff --git a/resource-manager/mysql/2022-01-01/checknameavailability/method_withoutlocationexecute_autorest.go b/resource-manager/mysql/2022-01-01/checknameavailability/method_withoutlocationexecute_autorest.go deleted file mode 100644 index ec031b0c323..00000000000 --- a/resource-manager/mysql/2022-01-01/checknameavailability/method_withoutlocationexecute_autorest.go +++ /dev/null @@ -1,71 +0,0 @@ -package checknameavailability - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type WithoutLocationExecuteOperationResponse struct { - HttpResponse *http.Response - Model *NameAvailability -} - -// WithoutLocationExecute ... -func (c CheckNameAvailabilityClient) WithoutLocationExecute(ctx context.Context, id commonids.SubscriptionId, input NameAvailabilityRequest) (result WithoutLocationExecuteOperationResponse, err error) { - req, err := c.preparerForWithoutLocationExecute(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "checknameavailability.CheckNameAvailabilityClient", "WithoutLocationExecute", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "checknameavailability.CheckNameAvailabilityClient", "WithoutLocationExecute", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForWithoutLocationExecute(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "checknameavailability.CheckNameAvailabilityClient", "WithoutLocationExecute", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForWithoutLocationExecute prepares the WithoutLocationExecute request. -func (c CheckNameAvailabilityClient) preparerForWithoutLocationExecute(ctx context.Context, id commonids.SubscriptionId, input NameAvailabilityRequest) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.DBforMySQL/checkNameAvailability", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForWithoutLocationExecute handles the response to the WithoutLocationExecute request. The method always -// closes the http.Response Body. -func (c CheckNameAvailabilityClient) responderForWithoutLocationExecute(resp *http.Response) (result WithoutLocationExecuteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/mysql/2022-01-01/client.go b/resource-manager/mysql/2022-01-01/client.go index 618a4744810..41d61d2f244 100644 --- a/resource-manager/mysql/2022-01-01/client.go +++ b/resource-manager/mysql/2022-01-01/client.go @@ -4,7 +4,8 @@ package v2022_01_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/mysql/2022-01-01/azureadadministrators" "github.com/hashicorp/go-azure-sdk/resource-manager/mysql/2022-01-01/backups" "github.com/hashicorp/go-azure-sdk/resource-manager/mysql/2022-01-01/checknameavailability" @@ -19,6 +20,8 @@ import ( "github.com/hashicorp/go-azure-sdk/resource-manager/mysql/2022-01-01/servers" "github.com/hashicorp/go-azure-sdk/resource-manager/mysql/2022-01-01/serverstart" "github.com/hashicorp/go-azure-sdk/resource-manager/mysql/2022-01-01/serverstop" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/environments" ) type Client struct { @@ -38,64 +41,105 @@ type Client struct { Servers *servers.ServersClient } -func NewClientWithBaseURI(endpoint string, configureAuthFunc func(c *autorest.Client)) Client { - - azureADAdministratorsClient := azureadadministrators.NewAzureADAdministratorsClientWithBaseURI(endpoint) - configureAuthFunc(&azureADAdministratorsClient.Client) - - backupsClient := backups.NewBackupsClientWithBaseURI(endpoint) - configureAuthFunc(&backupsClient.Client) +func NewClientWithBaseURI(api environments.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + azureADAdministratorsClient, err := azureadadministrators.NewAzureADAdministratorsClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building AzureADAdministrators client: %+v", err) + } + configureFunc(azureADAdministratorsClient.Client) - checkNameAvailabilityClient := checknameavailability.NewCheckNameAvailabilityClientWithBaseURI(endpoint) - configureAuthFunc(&checkNameAvailabilityClient.Client) + backupsClient, err := backups.NewBackupsClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Backups client: %+v", err) + } + configureFunc(backupsClient.Client) - configurationsClient := configurations.NewConfigurationsClientWithBaseURI(endpoint) - configureAuthFunc(&configurationsClient.Client) + checkNameAvailabilityClient, err := checknameavailability.NewCheckNameAvailabilityClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building CheckNameAvailability client: %+v", err) + } + configureFunc(checkNameAvailabilityClient.Client) - databasesClient := databases.NewDatabasesClientWithBaseURI(endpoint) - configureAuthFunc(&databasesClient.Client) + configurationsClient, err := configurations.NewConfigurationsClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Configurations client: %+v", err) + } + configureFunc(configurationsClient.Client) - firewallRulesClient := firewallrules.NewFirewallRulesClientWithBaseURI(endpoint) - configureAuthFunc(&firewallRulesClient.Client) + databasesClient, err := databases.NewDatabasesClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Databases client: %+v", err) + } + configureFunc(databasesClient.Client) - getPrivateDnsZoneSuffixClient := getprivatednszonesuffix.NewGetPrivateDnsZoneSuffixClientWithBaseURI(endpoint) - configureAuthFunc(&getPrivateDnsZoneSuffixClient.Client) + firewallRulesClient, err := firewallrules.NewFirewallRulesClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building FirewallRules client: %+v", err) + } + configureFunc(firewallRulesClient.Client) - locationBasedCapabilitiesClient := locationbasedcapabilities.NewLocationBasedCapabilitiesClientWithBaseURI(endpoint) - configureAuthFunc(&locationBasedCapabilitiesClient.Client) + getPrivateDnsZoneSuffixClient, err := getprivatednszonesuffix.NewGetPrivateDnsZoneSuffixClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building GetPrivateDnsZoneSuffix client: %+v", err) + } + configureFunc(getPrivateDnsZoneSuffixClient.Client) - logFilesClient := logfiles.NewLogFilesClientWithBaseURI(endpoint) - configureAuthFunc(&logFilesClient.Client) + locationBasedCapabilitiesClient, err := locationbasedcapabilities.NewLocationBasedCapabilitiesClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building LocationBasedCapabilities client: %+v", err) + } + configureFunc(locationBasedCapabilitiesClient.Client) - serverFailoverClient := serverfailover.NewServerFailoverClientWithBaseURI(endpoint) - configureAuthFunc(&serverFailoverClient.Client) + logFilesClient, err := logfiles.NewLogFilesClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building LogFiles client: %+v", err) + } + configureFunc(logFilesClient.Client) - serverRestartClient := serverrestart.NewServerRestartClientWithBaseURI(endpoint) - configureAuthFunc(&serverRestartClient.Client) + serverFailoverClient, err := serverfailover.NewServerFailoverClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ServerFailover client: %+v", err) + } + configureFunc(serverFailoverClient.Client) - serverStartClient := serverstart.NewServerStartClientWithBaseURI(endpoint) - configureAuthFunc(&serverStartClient.Client) + serverRestartClient, err := serverrestart.NewServerRestartClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ServerRestart client: %+v", err) + } + configureFunc(serverRestartClient.Client) - serverStopClient := serverstop.NewServerStopClientWithBaseURI(endpoint) - configureAuthFunc(&serverStopClient.Client) + serverStartClient, err := serverstart.NewServerStartClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ServerStart client: %+v", err) + } + configureFunc(serverStartClient.Client) - serversClient := servers.NewServersClientWithBaseURI(endpoint) - configureAuthFunc(&serversClient.Client) + serverStopClient, err := serverstop.NewServerStopClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ServerStop client: %+v", err) + } + configureFunc(serverStopClient.Client) - return Client{ - AzureADAdministrators: &azureADAdministratorsClient, - Backups: &backupsClient, - CheckNameAvailability: &checkNameAvailabilityClient, - Configurations: &configurationsClient, - Databases: &databasesClient, - FirewallRules: &firewallRulesClient, - GetPrivateDnsZoneSuffix: &getPrivateDnsZoneSuffixClient, - LocationBasedCapabilities: &locationBasedCapabilitiesClient, - LogFiles: &logFilesClient, - ServerFailover: &serverFailoverClient, - ServerRestart: &serverRestartClient, - ServerStart: &serverStartClient, - ServerStop: &serverStopClient, - Servers: &serversClient, + serversClient, err := servers.NewServersClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Servers client: %+v", err) } + configureFunc(serversClient.Client) + + return &Client{ + AzureADAdministrators: azureADAdministratorsClient, + Backups: backupsClient, + CheckNameAvailability: checkNameAvailabilityClient, + Configurations: configurationsClient, + Databases: databasesClient, + FirewallRules: firewallRulesClient, + GetPrivateDnsZoneSuffix: getPrivateDnsZoneSuffixClient, + LocationBasedCapabilities: locationBasedCapabilitiesClient, + LogFiles: logFilesClient, + ServerFailover: serverFailoverClient, + ServerRestart: serverRestartClient, + ServerStart: serverStartClient, + ServerStop: serverStopClient, + Servers: serversClient, + }, nil } diff --git a/resource-manager/mysql/2022-01-01/configurations/client.go b/resource-manager/mysql/2022-01-01/configurations/client.go index bbe813edd98..c2b3df6d8b8 100644 --- a/resource-manager/mysql/2022-01-01/configurations/client.go +++ b/resource-manager/mysql/2022-01-01/configurations/client.go @@ -1,18 +1,26 @@ package configurations -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 ConfigurationsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewConfigurationsClientWithBaseURI(endpoint string) ConfigurationsClient { - return ConfigurationsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewConfigurationsClientWithBaseURI(api environments.Api) (*ConfigurationsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "configurations", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ConfigurationsClient: %+v", err) } + + return &ConfigurationsClient{ + Client: client, + }, nil } diff --git a/resource-manager/mysql/2022-01-01/configurations/constants.go b/resource-manager/mysql/2022-01-01/configurations/constants.go index 315bd568db4..5508483dcba 100644 --- a/resource-manager/mysql/2022-01-01/configurations/constants.go +++ b/resource-manager/mysql/2022-01-01/configurations/constants.go @@ -1,6 +1,10 @@ package configurations -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. @@ -19,6 +23,19 @@ func PossibleValuesForConfigurationSource() []string { } } +func (s *ConfigurationSource) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConfigurationSource(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseConfigurationSource(input string) (*ConfigurationSource, error) { vals := map[string]ConfigurationSource{ "system-default": ConfigurationSourceSystemNegativedefault, @@ -47,6 +64,19 @@ func PossibleValuesForIsConfigPendingRestart() []string { } } +func (s *IsConfigPendingRestart) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIsConfigPendingRestart(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseIsConfigPendingRestart(input string) (*IsConfigPendingRestart, error) { vals := map[string]IsConfigPendingRestart{ "false": IsConfigPendingRestartFalse, @@ -75,6 +105,19 @@ func PossibleValuesForIsDynamicConfig() []string { } } +func (s *IsDynamicConfig) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIsDynamicConfig(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseIsDynamicConfig(input string) (*IsDynamicConfig, error) { vals := map[string]IsDynamicConfig{ "false": IsDynamicConfigFalse, @@ -103,6 +146,19 @@ func PossibleValuesForIsReadOnly() []string { } } +func (s *IsReadOnly) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIsReadOnly(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseIsReadOnly(input string) (*IsReadOnly, error) { vals := map[string]IsReadOnly{ "false": IsReadOnlyFalse, @@ -131,6 +187,19 @@ func PossibleValuesForResetAllToDefault() []string { } } +func (s *ResetAllToDefault) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResetAllToDefault(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseResetAllToDefault(input string) (*ResetAllToDefault, error) { vals := map[string]ResetAllToDefault{ "false": ResetAllToDefaultFalse, diff --git a/resource-manager/mysql/2022-01-01/configurations/method_batchupdate.go b/resource-manager/mysql/2022-01-01/configurations/method_batchupdate.go new file mode 100644 index 00000000000..d0c2d8f4766 --- /dev/null +++ b/resource-manager/mysql/2022-01-01/configurations/method_batchupdate.go @@ -0,0 +1,74 @@ +package configurations + +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 BatchUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// BatchUpdate ... +func (c ConfigurationsClient) BatchUpdate(ctx context.Context, id FlexibleServerId, input ConfigurationListForBatchUpdate) (result BatchUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/updateConfigurations", 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 +} + +// BatchUpdateThenPoll performs BatchUpdate then polls until it's completed +func (c ConfigurationsClient) BatchUpdateThenPoll(ctx context.Context, id FlexibleServerId, input ConfigurationListForBatchUpdate) error { + result, err := c.BatchUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing BatchUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after BatchUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/mysql/2022-01-01/configurations/method_batchupdate_autorest.go b/resource-manager/mysql/2022-01-01/configurations/method_batchupdate_autorest.go deleted file mode 100644 index db8e7f9f189..00000000000 --- a/resource-manager/mysql/2022-01-01/configurations/method_batchupdate_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package configurations - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type BatchUpdateOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// BatchUpdate ... -func (c ConfigurationsClient) BatchUpdate(ctx context.Context, id FlexibleServerId, input ConfigurationListForBatchUpdate) (result BatchUpdateOperationResponse, err error) { - req, err := c.preparerForBatchUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "configurations.ConfigurationsClient", "BatchUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForBatchUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "configurations.ConfigurationsClient", "BatchUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// BatchUpdateThenPoll performs BatchUpdate then polls until it's completed -func (c ConfigurationsClient) BatchUpdateThenPoll(ctx context.Context, id FlexibleServerId, input ConfigurationListForBatchUpdate) error { - result, err := c.BatchUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing BatchUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after BatchUpdate: %+v", err) - } - - return nil -} - -// preparerForBatchUpdate prepares the BatchUpdate request. -func (c ConfigurationsClient) preparerForBatchUpdate(ctx context.Context, id FlexibleServerId, input ConfigurationListForBatchUpdate) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/updateConfigurations", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForBatchUpdate sends the BatchUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c ConfigurationsClient) senderForBatchUpdate(ctx context.Context, req *http.Request) (future BatchUpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/mysql/2022-01-01/configurations/method_createorupdate.go b/resource-manager/mysql/2022-01-01/configurations/method_createorupdate.go new file mode 100644 index 00000000000..3b1b65a9581 --- /dev/null +++ b/resource-manager/mysql/2022-01-01/configurations/method_createorupdate.go @@ -0,0 +1,74 @@ +package configurations + +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 +} + +// CreateOrUpdate ... +func (c ConfigurationsClient) CreateOrUpdate(ctx context.Context, id ConfigurationId, input Configuration) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 ConfigurationsClient) CreateOrUpdateThenPoll(ctx context.Context, id ConfigurationId, input Configuration) 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 +} diff --git a/resource-manager/mysql/2022-01-01/configurations/method_createorupdate_autorest.go b/resource-manager/mysql/2022-01-01/configurations/method_createorupdate_autorest.go deleted file mode 100644 index c1e771a52d1..00000000000 --- a/resource-manager/mysql/2022-01-01/configurations/method_createorupdate_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package configurations - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateOrUpdate ... -func (c ConfigurationsClient) CreateOrUpdate(ctx context.Context, id ConfigurationId, input Configuration) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "configurations.ConfigurationsClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "configurations.ConfigurationsClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c ConfigurationsClient) CreateOrUpdateThenPoll(ctx context.Context, id ConfigurationId, input Configuration) error { - result, err := c.CreateOrUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateOrUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateOrUpdate: %+v", err) - } - - return nil -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c ConfigurationsClient) preparerForCreateOrUpdate(ctx context.Context, id ConfigurationId, input Configuration) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateOrUpdate sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c ConfigurationsClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/mysql/2022-01-01/configurations/method_get.go b/resource-manager/mysql/2022-01-01/configurations/method_get.go new file mode 100644 index 00000000000..d9bbfb3ea3d --- /dev/null +++ b/resource-manager/mysql/2022-01-01/configurations/method_get.go @@ -0,0 +1,51 @@ +package configurations + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Configuration +} + +// Get ... +func (c ConfigurationsClient) Get(ctx context.Context, id ConfigurationId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/mysql/2022-01-01/configurations/method_get_autorest.go b/resource-manager/mysql/2022-01-01/configurations/method_get_autorest.go deleted file mode 100644 index 2aeb488f91c..00000000000 --- a/resource-manager/mysql/2022-01-01/configurations/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package configurations - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *Configuration -} - -// Get ... -func (c ConfigurationsClient) Get(ctx context.Context, id ConfigurationId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "configurations.ConfigurationsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "configurations.ConfigurationsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "configurations.ConfigurationsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ConfigurationsClient) preparerForGet(ctx context.Context, id ConfigurationId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c ConfigurationsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/mysql/2022-01-01/configurations/method_listbyserver.go b/resource-manager/mysql/2022-01-01/configurations/method_listbyserver.go new file mode 100644 index 00000000000..00b35ec5f85 --- /dev/null +++ b/resource-manager/mysql/2022-01-01/configurations/method_listbyserver.go @@ -0,0 +1,129 @@ +package configurations + +import ( + "context" + "fmt" + "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 ListByServerOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Configuration +} + +type ListByServerCompleteResult struct { + Items []Configuration +} + +type ListByServerOperationOptions struct { + Keyword *string + Page *int64 + PageSize *int64 + Tags *string +} + +func DefaultListByServerOperationOptions() ListByServerOperationOptions { + return ListByServerOperationOptions{} +} + +func (o ListByServerOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByServerOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByServerOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Keyword != nil { + out.Append("keyword", fmt.Sprintf("%v", *o.Keyword)) + } + if o.Page != nil { + out.Append("page", fmt.Sprintf("%v", *o.Page)) + } + if o.PageSize != nil { + out.Append("pageSize", fmt.Sprintf("%v", *o.PageSize)) + } + if o.Tags != nil { + out.Append("tags", fmt.Sprintf("%v", *o.Tags)) + } + return &out +} + +// ListByServer ... +func (c ConfigurationsClient) ListByServer(ctx context.Context, id FlexibleServerId, options ListByServerOperationOptions) (result ListByServerOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/configurations", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Configuration `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServerComplete retrieves all the results into a single object +func (c ConfigurationsClient) ListByServerComplete(ctx context.Context, id FlexibleServerId, options ListByServerOperationOptions) (ListByServerCompleteResult, error) { + return c.ListByServerCompleteMatchingPredicate(ctx, id, options, ConfigurationOperationPredicate{}) +} + +// ListByServerCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ConfigurationsClient) ListByServerCompleteMatchingPredicate(ctx context.Context, id FlexibleServerId, options ListByServerOperationOptions, predicate ConfigurationOperationPredicate) (result ListByServerCompleteResult, err error) { + items := make([]Configuration, 0) + + resp, err := c.ListByServer(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServerCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/mysql/2022-01-01/configurations/method_listbyserver_autorest.go b/resource-manager/mysql/2022-01-01/configurations/method_listbyserver_autorest.go deleted file mode 100644 index b3602ba12ff..00000000000 --- a/resource-manager/mysql/2022-01-01/configurations/method_listbyserver_autorest.go +++ /dev/null @@ -1,230 +0,0 @@ -package configurations - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByServerOperationResponse struct { - HttpResponse *http.Response - Model *[]Configuration - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServerOperationResponse, error) -} - -type ListByServerCompleteResult struct { - Items []Configuration -} - -func (r ListByServerOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServerOperationResponse) LoadMore(ctx context.Context) (resp ListByServerOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByServerOperationOptions struct { - Keyword *string - Page *int64 - PageSize *int64 - Tags *string -} - -func DefaultListByServerOperationOptions() ListByServerOperationOptions { - return ListByServerOperationOptions{} -} - -func (o ListByServerOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByServerOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Keyword != nil { - out["keyword"] = *o.Keyword - } - - if o.Page != nil { - out["page"] = *o.Page - } - - if o.PageSize != nil { - out["pageSize"] = *o.PageSize - } - - if o.Tags != nil { - out["tags"] = *o.Tags - } - - return out -} - -// ListByServer ... -func (c ConfigurationsClient) ListByServer(ctx context.Context, id FlexibleServerId, options ListByServerOperationOptions) (resp ListByServerOperationResponse, err error) { - req, err := c.preparerForListByServer(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "configurations.ConfigurationsClient", "ListByServer", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "configurations.ConfigurationsClient", "ListByServer", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByServer(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "configurations.ConfigurationsClient", "ListByServer", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByServer prepares the ListByServer request. -func (c ConfigurationsClient) preparerForListByServer(ctx context.Context, id FlexibleServerId, options ListByServerOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/configurations", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServerWithNextLink prepares the ListByServer request with the given nextLink token. -func (c ConfigurationsClient) preparerForListByServerWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByServer handles the response to the ListByServer request. The method always -// closes the http.Response Body. -func (c ConfigurationsClient) responderForListByServer(resp *http.Response) (result ListByServerOperationResponse, err error) { - type page struct { - Values []Configuration `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByServerOperationResponse, err error) { - req, err := c.preparerForListByServerWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "configurations.ConfigurationsClient", "ListByServer", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "configurations.ConfigurationsClient", "ListByServer", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByServer(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "configurations.ConfigurationsClient", "ListByServer", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServerComplete retrieves all of the results into a single object -func (c ConfigurationsClient) ListByServerComplete(ctx context.Context, id FlexibleServerId, options ListByServerOperationOptions) (ListByServerCompleteResult, error) { - return c.ListByServerCompleteMatchingPredicate(ctx, id, options, ConfigurationOperationPredicate{}) -} - -// ListByServerCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ConfigurationsClient) ListByServerCompleteMatchingPredicate(ctx context.Context, id FlexibleServerId, options ListByServerOperationOptions, predicate ConfigurationOperationPredicate) (resp ListByServerCompleteResult, err error) { - items := make([]Configuration, 0) - - page, err := c.ListByServer(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServerCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/mysql/2022-01-01/configurations/method_update.go b/resource-manager/mysql/2022-01-01/configurations/method_update.go new file mode 100644 index 00000000000..e9b210b8cbd --- /dev/null +++ b/resource-manager/mysql/2022-01-01/configurations/method_update.go @@ -0,0 +1,74 @@ +package configurations + +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 UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Update ... +func (c ConfigurationsClient) Update(ctx context.Context, id ConfigurationId, input Configuration) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + 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 +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c ConfigurationsClient) UpdateThenPoll(ctx context.Context, id ConfigurationId, input Configuration) error { + result, err := c.Update(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/resource-manager/mysql/2022-01-01/configurations/method_update_autorest.go b/resource-manager/mysql/2022-01-01/configurations/method_update_autorest.go deleted file mode 100644 index 7d79f3dd369..00000000000 --- a/resource-manager/mysql/2022-01-01/configurations/method_update_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package configurations - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Update ... -func (c ConfigurationsClient) Update(ctx context.Context, id ConfigurationId, input Configuration) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "configurations.ConfigurationsClient", "Update", nil, "Failure preparing request") - return - } - - result, err = c.senderForUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "configurations.ConfigurationsClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// UpdateThenPoll performs Update then polls until it's completed -func (c ConfigurationsClient) UpdateThenPoll(ctx context.Context, id ConfigurationId, input Configuration) error { - result, err := c.Update(ctx, id, input) - if err != nil { - return fmt.Errorf("performing Update: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Update: %+v", err) - } - - return nil -} - -// preparerForUpdate prepares the Update request. -func (c ConfigurationsClient) preparerForUpdate(ctx context.Context, id ConfigurationId, input Configuration) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForUpdate sends the Update request. The method will close the -// http.Response Body if it receives an error. -func (c ConfigurationsClient) senderForUpdate(ctx context.Context, req *http.Request) (future UpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/mysql/2022-01-01/databases/client.go b/resource-manager/mysql/2022-01-01/databases/client.go index 5305d65eb6c..bb94a331f78 100644 --- a/resource-manager/mysql/2022-01-01/databases/client.go +++ b/resource-manager/mysql/2022-01-01/databases/client.go @@ -1,18 +1,26 @@ package databases -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 DatabasesClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewDatabasesClientWithBaseURI(endpoint string) DatabasesClient { - return DatabasesClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewDatabasesClientWithBaseURI(api environments.Api) (*DatabasesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "databases", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DatabasesClient: %+v", err) } + + return &DatabasesClient{ + Client: client, + }, nil } diff --git a/resource-manager/mysql/2022-01-01/databases/method_createorupdate.go b/resource-manager/mysql/2022-01-01/databases/method_createorupdate.go new file mode 100644 index 00000000000..6dc4e3e0560 --- /dev/null +++ b/resource-manager/mysql/2022-01-01/databases/method_createorupdate.go @@ -0,0 +1,75 @@ +package databases + +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 +} + +// CreateOrUpdate ... +func (c DatabasesClient) CreateOrUpdate(ctx context.Context, id DatabaseId, input Database) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 DatabasesClient) CreateOrUpdateThenPoll(ctx context.Context, id DatabaseId, input Database) 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 +} diff --git a/resource-manager/mysql/2022-01-01/databases/method_createorupdate_autorest.go b/resource-manager/mysql/2022-01-01/databases/method_createorupdate_autorest.go deleted file mode 100644 index 8046543297d..00000000000 --- a/resource-manager/mysql/2022-01-01/databases/method_createorupdate_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package databases - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateOrUpdate ... -func (c DatabasesClient) CreateOrUpdate(ctx context.Context, id DatabaseId, input Database) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c DatabasesClient) CreateOrUpdateThenPoll(ctx context.Context, id DatabaseId, input Database) error { - result, err := c.CreateOrUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateOrUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateOrUpdate: %+v", err) - } - - return nil -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c DatabasesClient) preparerForCreateOrUpdate(ctx context.Context, id DatabaseId, input Database) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateOrUpdate sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c DatabasesClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/mysql/2022-01-01/databases/method_delete.go b/resource-manager/mysql/2022-01-01/databases/method_delete.go new file mode 100644 index 00000000000..8d10b76fa30 --- /dev/null +++ b/resource-manager/mysql/2022-01-01/databases/method_delete.go @@ -0,0 +1,71 @@ +package databases + +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 DatabasesClient) Delete(ctx context.Context, id DatabaseId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 DatabasesClient) DeleteThenPoll(ctx context.Context, id DatabaseId) 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 +} diff --git a/resource-manager/mysql/2022-01-01/databases/method_delete_autorest.go b/resource-manager/mysql/2022-01-01/databases/method_delete_autorest.go deleted file mode 100644 index 13221da85a6..00000000000 --- a/resource-manager/mysql/2022-01-01/databases/method_delete_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package databases - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// Delete ... -func (c DatabasesClient) Delete(ctx context.Context, id DatabaseId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c DatabasesClient) DeleteThenPoll(ctx context.Context, id DatabaseId) error { - result, err := c.Delete(ctx, id) - if err != nil { - return fmt.Errorf("performing Delete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Delete: %+v", err) - } - - return nil -} - -// preparerForDelete prepares the Delete request. -func (c DatabasesClient) preparerForDelete(ctx context.Context, id DatabaseId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDelete sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (c DatabasesClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/mysql/2022-01-01/databases/method_get.go b/resource-manager/mysql/2022-01-01/databases/method_get.go new file mode 100644 index 00000000000..6f2c4fe3341 --- /dev/null +++ b/resource-manager/mysql/2022-01-01/databases/method_get.go @@ -0,0 +1,51 @@ +package databases + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Database +} + +// Get ... +func (c DatabasesClient) Get(ctx context.Context, id DatabaseId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/mysql/2022-01-01/databases/method_get_autorest.go b/resource-manager/mysql/2022-01-01/databases/method_get_autorest.go deleted file mode 100644 index f35d313d226..00000000000 --- a/resource-manager/mysql/2022-01-01/databases/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package databases - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *Database -} - -// Get ... -func (c DatabasesClient) Get(ctx context.Context, id DatabaseId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c DatabasesClient) preparerForGet(ctx context.Context, id DatabaseId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c DatabasesClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/mysql/2022-01-01/databases/method_listbyserver.go b/resource-manager/mysql/2022-01-01/databases/method_listbyserver.go new file mode 100644 index 00000000000..dca5cb1f346 --- /dev/null +++ b/resource-manager/mysql/2022-01-01/databases/method_listbyserver.go @@ -0,0 +1,89 @@ +package databases + +import ( + "context" + "fmt" + "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 ListByServerOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Database +} + +type ListByServerCompleteResult struct { + Items []Database +} + +// ListByServer ... +func (c DatabasesClient) ListByServer(ctx context.Context, id FlexibleServerId) (result ListByServerOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/databases", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Database `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServerComplete retrieves all the results into a single object +func (c DatabasesClient) ListByServerComplete(ctx context.Context, id FlexibleServerId) (ListByServerCompleteResult, error) { + return c.ListByServerCompleteMatchingPredicate(ctx, id, DatabaseOperationPredicate{}) +} + +// ListByServerCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DatabasesClient) ListByServerCompleteMatchingPredicate(ctx context.Context, id FlexibleServerId, predicate DatabaseOperationPredicate) (result ListByServerCompleteResult, err error) { + items := make([]Database, 0) + + resp, err := c.ListByServer(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServerCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/mysql/2022-01-01/databases/method_listbyserver_autorest.go b/resource-manager/mysql/2022-01-01/databases/method_listbyserver_autorest.go deleted file mode 100644 index 5937f9e8958..00000000000 --- a/resource-manager/mysql/2022-01-01/databases/method_listbyserver_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package databases - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByServerOperationResponse struct { - HttpResponse *http.Response - Model *[]Database - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServerOperationResponse, error) -} - -type ListByServerCompleteResult struct { - Items []Database -} - -func (r ListByServerOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServerOperationResponse) LoadMore(ctx context.Context) (resp ListByServerOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByServer ... -func (c DatabasesClient) ListByServer(ctx context.Context, id FlexibleServerId) (resp ListByServerOperationResponse, err error) { - req, err := c.preparerForListByServer(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "ListByServer", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "ListByServer", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByServer(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "ListByServer", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByServer prepares the ListByServer request. -func (c DatabasesClient) preparerForListByServer(ctx context.Context, id FlexibleServerId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/databases", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServerWithNextLink prepares the ListByServer request with the given nextLink token. -func (c DatabasesClient) preparerForListByServerWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByServer handles the response to the ListByServer request. The method always -// closes the http.Response Body. -func (c DatabasesClient) responderForListByServer(resp *http.Response) (result ListByServerOperationResponse, err error) { - type page struct { - Values []Database `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByServerOperationResponse, err error) { - req, err := c.preparerForListByServerWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "ListByServer", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "ListByServer", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByServer(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "databases.DatabasesClient", "ListByServer", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServerComplete retrieves all of the results into a single object -func (c DatabasesClient) ListByServerComplete(ctx context.Context, id FlexibleServerId) (ListByServerCompleteResult, error) { - return c.ListByServerCompleteMatchingPredicate(ctx, id, DatabaseOperationPredicate{}) -} - -// ListByServerCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c DatabasesClient) ListByServerCompleteMatchingPredicate(ctx context.Context, id FlexibleServerId, predicate DatabaseOperationPredicate) (resp ListByServerCompleteResult, err error) { - items := make([]Database, 0) - - page, err := c.ListByServer(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServerCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/mysql/2022-01-01/firewallrules/client.go b/resource-manager/mysql/2022-01-01/firewallrules/client.go index ac01b0459a1..6493e429eb1 100644 --- a/resource-manager/mysql/2022-01-01/firewallrules/client.go +++ b/resource-manager/mysql/2022-01-01/firewallrules/client.go @@ -1,18 +1,26 @@ package firewallrules -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 FirewallRulesClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewFirewallRulesClientWithBaseURI(endpoint string) FirewallRulesClient { - return FirewallRulesClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewFirewallRulesClientWithBaseURI(api environments.Api) (*FirewallRulesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "firewallrules", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating FirewallRulesClient: %+v", err) } + + return &FirewallRulesClient{ + Client: client, + }, nil } diff --git a/resource-manager/mysql/2022-01-01/firewallrules/method_createorupdate.go b/resource-manager/mysql/2022-01-01/firewallrules/method_createorupdate.go new file mode 100644 index 00000000000..dc64d3809d0 --- /dev/null +++ b/resource-manager/mysql/2022-01-01/firewallrules/method_createorupdate.go @@ -0,0 +1,75 @@ +package firewallrules + +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 +} + +// CreateOrUpdate ... +func (c FirewallRulesClient) CreateOrUpdate(ctx context.Context, id FirewallRuleId, input FirewallRule) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 FirewallRulesClient) CreateOrUpdateThenPoll(ctx context.Context, id FirewallRuleId, input FirewallRule) 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 +} diff --git a/resource-manager/mysql/2022-01-01/firewallrules/method_createorupdate_autorest.go b/resource-manager/mysql/2022-01-01/firewallrules/method_createorupdate_autorest.go deleted file mode 100644 index 0dfa761f1a0..00000000000 --- a/resource-manager/mysql/2022-01-01/firewallrules/method_createorupdate_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package firewallrules - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateOrUpdate ... -func (c FirewallRulesClient) CreateOrUpdate(ctx context.Context, id FirewallRuleId, input FirewallRule) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "firewallrules.FirewallRulesClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "firewallrules.FirewallRulesClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c FirewallRulesClient) CreateOrUpdateThenPoll(ctx context.Context, id FirewallRuleId, input FirewallRule) error { - result, err := c.CreateOrUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateOrUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateOrUpdate: %+v", err) - } - - return nil -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c FirewallRulesClient) preparerForCreateOrUpdate(ctx context.Context, id FirewallRuleId, input FirewallRule) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateOrUpdate sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c FirewallRulesClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/mysql/2022-01-01/firewallrules/method_delete.go b/resource-manager/mysql/2022-01-01/firewallrules/method_delete.go new file mode 100644 index 00000000000..0b8a33693c0 --- /dev/null +++ b/resource-manager/mysql/2022-01-01/firewallrules/method_delete.go @@ -0,0 +1,71 @@ +package firewallrules + +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 FirewallRulesClient) Delete(ctx context.Context, id FirewallRuleId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 FirewallRulesClient) DeleteThenPoll(ctx context.Context, id FirewallRuleId) 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 +} diff --git a/resource-manager/mysql/2022-01-01/firewallrules/method_delete_autorest.go b/resource-manager/mysql/2022-01-01/firewallrules/method_delete_autorest.go deleted file mode 100644 index ec4b290ecdd..00000000000 --- a/resource-manager/mysql/2022-01-01/firewallrules/method_delete_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package firewallrules - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// Delete ... -func (c FirewallRulesClient) Delete(ctx context.Context, id FirewallRuleId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "firewallrules.FirewallRulesClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "firewallrules.FirewallRulesClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c FirewallRulesClient) DeleteThenPoll(ctx context.Context, id FirewallRuleId) error { - result, err := c.Delete(ctx, id) - if err != nil { - return fmt.Errorf("performing Delete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Delete: %+v", err) - } - - return nil -} - -// preparerForDelete prepares the Delete request. -func (c FirewallRulesClient) preparerForDelete(ctx context.Context, id FirewallRuleId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDelete sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (c FirewallRulesClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/mysql/2022-01-01/firewallrules/method_get.go b/resource-manager/mysql/2022-01-01/firewallrules/method_get.go new file mode 100644 index 00000000000..f14c6b31f8d --- /dev/null +++ b/resource-manager/mysql/2022-01-01/firewallrules/method_get.go @@ -0,0 +1,51 @@ +package firewallrules + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *FirewallRule +} + +// Get ... +func (c FirewallRulesClient) Get(ctx context.Context, id FirewallRuleId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/mysql/2022-01-01/firewallrules/method_get_autorest.go b/resource-manager/mysql/2022-01-01/firewallrules/method_get_autorest.go deleted file mode 100644 index 1391c01ba1a..00000000000 --- a/resource-manager/mysql/2022-01-01/firewallrules/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package firewallrules - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *FirewallRule -} - -// Get ... -func (c FirewallRulesClient) Get(ctx context.Context, id FirewallRuleId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "firewallrules.FirewallRulesClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "firewallrules.FirewallRulesClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "firewallrules.FirewallRulesClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c FirewallRulesClient) preparerForGet(ctx context.Context, id FirewallRuleId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c FirewallRulesClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/mysql/2022-01-01/firewallrules/method_listbyserver.go b/resource-manager/mysql/2022-01-01/firewallrules/method_listbyserver.go new file mode 100644 index 00000000000..e187720f151 --- /dev/null +++ b/resource-manager/mysql/2022-01-01/firewallrules/method_listbyserver.go @@ -0,0 +1,89 @@ +package firewallrules + +import ( + "context" + "fmt" + "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 ListByServerOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]FirewallRule +} + +type ListByServerCompleteResult struct { + Items []FirewallRule +} + +// ListByServer ... +func (c FirewallRulesClient) ListByServer(ctx context.Context, id FlexibleServerId) (result ListByServerOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/firewallRules", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]FirewallRule `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServerComplete retrieves all the results into a single object +func (c FirewallRulesClient) ListByServerComplete(ctx context.Context, id FlexibleServerId) (ListByServerCompleteResult, error) { + return c.ListByServerCompleteMatchingPredicate(ctx, id, FirewallRuleOperationPredicate{}) +} + +// ListByServerCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c FirewallRulesClient) ListByServerCompleteMatchingPredicate(ctx context.Context, id FlexibleServerId, predicate FirewallRuleOperationPredicate) (result ListByServerCompleteResult, err error) { + items := make([]FirewallRule, 0) + + resp, err := c.ListByServer(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServerCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/mysql/2022-01-01/firewallrules/method_listbyserver_autorest.go b/resource-manager/mysql/2022-01-01/firewallrules/method_listbyserver_autorest.go deleted file mode 100644 index 82fe51aed30..00000000000 --- a/resource-manager/mysql/2022-01-01/firewallrules/method_listbyserver_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package firewallrules - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByServerOperationResponse struct { - HttpResponse *http.Response - Model *[]FirewallRule - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServerOperationResponse, error) -} - -type ListByServerCompleteResult struct { - Items []FirewallRule -} - -func (r ListByServerOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServerOperationResponse) LoadMore(ctx context.Context) (resp ListByServerOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByServer ... -func (c FirewallRulesClient) ListByServer(ctx context.Context, id FlexibleServerId) (resp ListByServerOperationResponse, err error) { - req, err := c.preparerForListByServer(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "firewallrules.FirewallRulesClient", "ListByServer", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "firewallrules.FirewallRulesClient", "ListByServer", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByServer(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "firewallrules.FirewallRulesClient", "ListByServer", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByServer prepares the ListByServer request. -func (c FirewallRulesClient) preparerForListByServer(ctx context.Context, id FlexibleServerId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/firewallRules", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServerWithNextLink prepares the ListByServer request with the given nextLink token. -func (c FirewallRulesClient) preparerForListByServerWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByServer handles the response to the ListByServer request. The method always -// closes the http.Response Body. -func (c FirewallRulesClient) responderForListByServer(resp *http.Response) (result ListByServerOperationResponse, err error) { - type page struct { - Values []FirewallRule `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByServerOperationResponse, err error) { - req, err := c.preparerForListByServerWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "firewallrules.FirewallRulesClient", "ListByServer", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "firewallrules.FirewallRulesClient", "ListByServer", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByServer(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "firewallrules.FirewallRulesClient", "ListByServer", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServerComplete retrieves all of the results into a single object -func (c FirewallRulesClient) ListByServerComplete(ctx context.Context, id FlexibleServerId) (ListByServerCompleteResult, error) { - return c.ListByServerCompleteMatchingPredicate(ctx, id, FirewallRuleOperationPredicate{}) -} - -// ListByServerCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c FirewallRulesClient) ListByServerCompleteMatchingPredicate(ctx context.Context, id FlexibleServerId, predicate FirewallRuleOperationPredicate) (resp ListByServerCompleteResult, err error) { - items := make([]FirewallRule, 0) - - page, err := c.ListByServer(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServerCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/mysql/2022-01-01/getprivatednszonesuffix/client.go b/resource-manager/mysql/2022-01-01/getprivatednszonesuffix/client.go index ce9cceb6b9a..39cc68bc144 100644 --- a/resource-manager/mysql/2022-01-01/getprivatednszonesuffix/client.go +++ b/resource-manager/mysql/2022-01-01/getprivatednszonesuffix/client.go @@ -1,18 +1,26 @@ package getprivatednszonesuffix -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 GetPrivateDnsZoneSuffixClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewGetPrivateDnsZoneSuffixClientWithBaseURI(endpoint string) GetPrivateDnsZoneSuffixClient { - return GetPrivateDnsZoneSuffixClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewGetPrivateDnsZoneSuffixClientWithBaseURI(api environments.Api) (*GetPrivateDnsZoneSuffixClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "getprivatednszonesuffix", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating GetPrivateDnsZoneSuffixClient: %+v", err) } + + return &GetPrivateDnsZoneSuffixClient{ + Client: client, + }, nil } diff --git a/resource-manager/mysql/2022-01-01/getprivatednszonesuffix/method_execute.go b/resource-manager/mysql/2022-01-01/getprivatednszonesuffix/method_execute.go new file mode 100644 index 00000000000..f00af054dec --- /dev/null +++ b/resource-manager/mysql/2022-01-01/getprivatednszonesuffix/method_execute.go @@ -0,0 +1,51 @@ +package getprivatednszonesuffix + +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 ExecuteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *GetPrivateDnsZoneSuffixResponse +} + +// Execute ... +func (c GetPrivateDnsZoneSuffixClient) Execute(ctx context.Context) (result ExecuteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: "/providers/Microsoft.DBforMySQL/getPrivateDnsZoneSuffix", + } + + 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 +} diff --git a/resource-manager/mysql/2022-01-01/getprivatednszonesuffix/method_execute_autorest.go b/resource-manager/mysql/2022-01-01/getprivatednszonesuffix/method_execute_autorest.go deleted file mode 100644 index e8091abed30..00000000000 --- a/resource-manager/mysql/2022-01-01/getprivatednszonesuffix/method_execute_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package getprivatednszonesuffix - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ExecuteOperationResponse struct { - HttpResponse *http.Response - Model *GetPrivateDnsZoneSuffixResponse -} - -// Execute ... -func (c GetPrivateDnsZoneSuffixClient) Execute(ctx context.Context) (result ExecuteOperationResponse, err error) { - req, err := c.preparerForExecute(ctx) - if err != nil { - err = autorest.NewErrorWithError(err, "getprivatednszonesuffix.GetPrivateDnsZoneSuffixClient", "Execute", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "getprivatednszonesuffix.GetPrivateDnsZoneSuffixClient", "Execute", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForExecute(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "getprivatednszonesuffix.GetPrivateDnsZoneSuffixClient", "Execute", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForExecute prepares the Execute request. -func (c GetPrivateDnsZoneSuffixClient) preparerForExecute(ctx context.Context) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath("/providers/Microsoft.DBforMySQL/getPrivateDnsZoneSuffix"), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForExecute handles the response to the Execute request. The method always -// closes the http.Response Body. -func (c GetPrivateDnsZoneSuffixClient) responderForExecute(resp *http.Response) (result ExecuteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/mysql/2022-01-01/locationbasedcapabilities/client.go b/resource-manager/mysql/2022-01-01/locationbasedcapabilities/client.go index 7c8f88e30d1..c7ed45f57a6 100644 --- a/resource-manager/mysql/2022-01-01/locationbasedcapabilities/client.go +++ b/resource-manager/mysql/2022-01-01/locationbasedcapabilities/client.go @@ -1,18 +1,26 @@ package locationbasedcapabilities -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 LocationBasedCapabilitiesClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewLocationBasedCapabilitiesClientWithBaseURI(endpoint string) LocationBasedCapabilitiesClient { - return LocationBasedCapabilitiesClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewLocationBasedCapabilitiesClientWithBaseURI(api environments.Api) (*LocationBasedCapabilitiesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "locationbasedcapabilities", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating LocationBasedCapabilitiesClient: %+v", err) } + + return &LocationBasedCapabilitiesClient{ + Client: client, + }, nil } diff --git a/resource-manager/mysql/2022-01-01/locationbasedcapabilities/method_list.go b/resource-manager/mysql/2022-01-01/locationbasedcapabilities/method_list.go new file mode 100644 index 00000000000..34b87056703 --- /dev/null +++ b/resource-manager/mysql/2022-01-01/locationbasedcapabilities/method_list.go @@ -0,0 +1,89 @@ +package locationbasedcapabilities + +import ( + "context" + "fmt" + "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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CapabilityProperties +} + +type ListCompleteResult struct { + Items []CapabilityProperties +} + +// List ... +func (c LocationBasedCapabilitiesClient) List(ctx context.Context, id LocationId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/capabilities", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]CapabilityProperties `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c LocationBasedCapabilitiesClient) ListComplete(ctx context.Context, id LocationId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, CapabilityPropertiesOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c LocationBasedCapabilitiesClient) ListCompleteMatchingPredicate(ctx context.Context, id LocationId, predicate CapabilityPropertiesOperationPredicate) (result ListCompleteResult, err error) { + items := make([]CapabilityProperties, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/mysql/2022-01-01/locationbasedcapabilities/method_list_autorest.go b/resource-manager/mysql/2022-01-01/locationbasedcapabilities/method_list_autorest.go deleted file mode 100644 index 0d25a07068a..00000000000 --- a/resource-manager/mysql/2022-01-01/locationbasedcapabilities/method_list_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package locationbasedcapabilities - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListOperationResponse struct { - HttpResponse *http.Response - Model *[]CapabilityProperties - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []CapabilityProperties -} - -func (r ListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// List ... -func (c LocationBasedCapabilitiesClient) List(ctx context.Context, id LocationId) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "locationbasedcapabilities.LocationBasedCapabilitiesClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "locationbasedcapabilities.LocationBasedCapabilitiesClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "locationbasedcapabilities.LocationBasedCapabilitiesClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c LocationBasedCapabilitiesClient) preparerForList(ctx context.Context, id LocationId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/capabilities", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c LocationBasedCapabilitiesClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForList handles the response to the List request. The method always -// closes the http.Response Body. -func (c LocationBasedCapabilitiesClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []CapabilityProperties `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { - req, err := c.preparerForListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "locationbasedcapabilities.LocationBasedCapabilitiesClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "locationbasedcapabilities.LocationBasedCapabilitiesClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "locationbasedcapabilities.LocationBasedCapabilitiesClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c LocationBasedCapabilitiesClient) ListComplete(ctx context.Context, id LocationId) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, CapabilityPropertiesOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c LocationBasedCapabilitiesClient) ListCompleteMatchingPredicate(ctx context.Context, id LocationId, predicate CapabilityPropertiesOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]CapabilityProperties, 0) - - page, err := c.List(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/mysql/2022-01-01/logfiles/client.go b/resource-manager/mysql/2022-01-01/logfiles/client.go index 5b776366d70..99d5dad075a 100644 --- a/resource-manager/mysql/2022-01-01/logfiles/client.go +++ b/resource-manager/mysql/2022-01-01/logfiles/client.go @@ -1,18 +1,26 @@ package logfiles -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 LogFilesClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewLogFilesClientWithBaseURI(endpoint string) LogFilesClient { - return LogFilesClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewLogFilesClientWithBaseURI(api environments.Api) (*LogFilesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "logfiles", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating LogFilesClient: %+v", err) } + + return &LogFilesClient{ + Client: client, + }, nil } diff --git a/resource-manager/mysql/2022-01-01/logfiles/method_listbyserver.go b/resource-manager/mysql/2022-01-01/logfiles/method_listbyserver.go new file mode 100644 index 00000000000..515deb3cc8c --- /dev/null +++ b/resource-manager/mysql/2022-01-01/logfiles/method_listbyserver.go @@ -0,0 +1,89 @@ +package logfiles + +import ( + "context" + "fmt" + "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 ListByServerOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]LogFile +} + +type ListByServerCompleteResult struct { + Items []LogFile +} + +// ListByServer ... +func (c LogFilesClient) ListByServer(ctx context.Context, id FlexibleServerId) (result ListByServerOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/logFiles", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]LogFile `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByServerComplete retrieves all the results into a single object +func (c LogFilesClient) ListByServerComplete(ctx context.Context, id FlexibleServerId) (ListByServerCompleteResult, error) { + return c.ListByServerCompleteMatchingPredicate(ctx, id, LogFileOperationPredicate{}) +} + +// ListByServerCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c LogFilesClient) ListByServerCompleteMatchingPredicate(ctx context.Context, id FlexibleServerId, predicate LogFileOperationPredicate) (result ListByServerCompleteResult, err error) { + items := make([]LogFile, 0) + + resp, err := c.ListByServer(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByServerCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/mysql/2022-01-01/logfiles/method_listbyserver_autorest.go b/resource-manager/mysql/2022-01-01/logfiles/method_listbyserver_autorest.go deleted file mode 100644 index 1ec55821c53..00000000000 --- a/resource-manager/mysql/2022-01-01/logfiles/method_listbyserver_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package logfiles - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByServerOperationResponse struct { - HttpResponse *http.Response - Model *[]LogFile - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByServerOperationResponse, error) -} - -type ListByServerCompleteResult struct { - Items []LogFile -} - -func (r ListByServerOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByServerOperationResponse) LoadMore(ctx context.Context) (resp ListByServerOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByServer ... -func (c LogFilesClient) ListByServer(ctx context.Context, id FlexibleServerId) (resp ListByServerOperationResponse, err error) { - req, err := c.preparerForListByServer(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "logfiles.LogFilesClient", "ListByServer", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "logfiles.LogFilesClient", "ListByServer", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByServer(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "logfiles.LogFilesClient", "ListByServer", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByServer prepares the ListByServer request. -func (c LogFilesClient) preparerForListByServer(ctx context.Context, id FlexibleServerId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/logFiles", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByServerWithNextLink prepares the ListByServer request with the given nextLink token. -func (c LogFilesClient) preparerForListByServerWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByServer handles the response to the ListByServer request. The method always -// closes the http.Response Body. -func (c LogFilesClient) responderForListByServer(resp *http.Response) (result ListByServerOperationResponse, err error) { - type page struct { - Values []LogFile `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByServerOperationResponse, err error) { - req, err := c.preparerForListByServerWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "logfiles.LogFilesClient", "ListByServer", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "logfiles.LogFilesClient", "ListByServer", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByServer(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "logfiles.LogFilesClient", "ListByServer", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByServerComplete retrieves all of the results into a single object -func (c LogFilesClient) ListByServerComplete(ctx context.Context, id FlexibleServerId) (ListByServerCompleteResult, error) { - return c.ListByServerCompleteMatchingPredicate(ctx, id, LogFileOperationPredicate{}) -} - -// ListByServerCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c LogFilesClient) ListByServerCompleteMatchingPredicate(ctx context.Context, id FlexibleServerId, predicate LogFileOperationPredicate) (resp ListByServerCompleteResult, err error) { - items := make([]LogFile, 0) - - page, err := c.ListByServer(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByServerCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/mysql/2022-01-01/serverfailover/client.go b/resource-manager/mysql/2022-01-01/serverfailover/client.go index f723c8a149d..d90a9229592 100644 --- a/resource-manager/mysql/2022-01-01/serverfailover/client.go +++ b/resource-manager/mysql/2022-01-01/serverfailover/client.go @@ -1,18 +1,26 @@ package serverfailover -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 ServerFailoverClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewServerFailoverClientWithBaseURI(endpoint string) ServerFailoverClient { - return ServerFailoverClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewServerFailoverClientWithBaseURI(api environments.Api) (*ServerFailoverClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "serverfailover", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ServerFailoverClient: %+v", err) } + + return &ServerFailoverClient{ + Client: client, + }, nil } diff --git a/resource-manager/mysql/2022-01-01/serverfailover/method_serversfailover.go b/resource-manager/mysql/2022-01-01/serverfailover/method_serversfailover.go new file mode 100644 index 00000000000..aa31c631dd0 --- /dev/null +++ b/resource-manager/mysql/2022-01-01/serverfailover/method_serversfailover.go @@ -0,0 +1,70 @@ +package serverfailover + +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 ServersFailoverOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ServersFailover ... +func (c ServerFailoverClient) ServersFailover(ctx context.Context, id FlexibleServerId) (result ServersFailoverOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/failover", 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 +} + +// ServersFailoverThenPoll performs ServersFailover then polls until it's completed +func (c ServerFailoverClient) ServersFailoverThenPoll(ctx context.Context, id FlexibleServerId) error { + result, err := c.ServersFailover(ctx, id) + if err != nil { + return fmt.Errorf("performing ServersFailover: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ServersFailover: %+v", err) + } + + return nil +} diff --git a/resource-manager/mysql/2022-01-01/serverfailover/method_serversfailover_autorest.go b/resource-manager/mysql/2022-01-01/serverfailover/method_serversfailover_autorest.go deleted file mode 100644 index a3d79cc5efa..00000000000 --- a/resource-manager/mysql/2022-01-01/serverfailover/method_serversfailover_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package serverfailover - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ServersFailoverOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// ServersFailover ... -func (c ServerFailoverClient) ServersFailover(ctx context.Context, id FlexibleServerId) (result ServersFailoverOperationResponse, err error) { - req, err := c.preparerForServersFailover(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "serverfailover.ServerFailoverClient", "ServersFailover", nil, "Failure preparing request") - return - } - - result, err = c.senderForServersFailover(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "serverfailover.ServerFailoverClient", "ServersFailover", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// ServersFailoverThenPoll performs ServersFailover then polls until it's completed -func (c ServerFailoverClient) ServersFailoverThenPoll(ctx context.Context, id FlexibleServerId) error { - result, err := c.ServersFailover(ctx, id) - if err != nil { - return fmt.Errorf("performing ServersFailover: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after ServersFailover: %+v", err) - } - - return nil -} - -// preparerForServersFailover prepares the ServersFailover request. -func (c ServerFailoverClient) preparerForServersFailover(ctx context.Context, id FlexibleServerId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/failover", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForServersFailover sends the ServersFailover request. The method will close the -// http.Response Body if it receives an error. -func (c ServerFailoverClient) senderForServersFailover(ctx context.Context, req *http.Request) (future ServersFailoverOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/mysql/2022-01-01/serverrestart/client.go b/resource-manager/mysql/2022-01-01/serverrestart/client.go index 7e3313f4726..dda19ef0b54 100644 --- a/resource-manager/mysql/2022-01-01/serverrestart/client.go +++ b/resource-manager/mysql/2022-01-01/serverrestart/client.go @@ -1,18 +1,26 @@ package serverrestart -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 ServerRestartClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewServerRestartClientWithBaseURI(endpoint string) ServerRestartClient { - return ServerRestartClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewServerRestartClientWithBaseURI(api environments.Api) (*ServerRestartClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "serverrestart", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ServerRestartClient: %+v", err) } + + return &ServerRestartClient{ + Client: client, + }, nil } diff --git a/resource-manager/mysql/2022-01-01/serverrestart/constants.go b/resource-manager/mysql/2022-01-01/serverrestart/constants.go index 136ece086bc..0ce79f8aedc 100644 --- a/resource-manager/mysql/2022-01-01/serverrestart/constants.go +++ b/resource-manager/mysql/2022-01-01/serverrestart/constants.go @@ -1,6 +1,10 @@ package serverrestart -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. @@ -19,6 +23,19 @@ func PossibleValuesForEnableStatusEnum() []string { } } +func (s *EnableStatusEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEnableStatusEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseEnableStatusEnum(input string) (*EnableStatusEnum, error) { vals := map[string]EnableStatusEnum{ "disabled": EnableStatusEnumDisabled, diff --git a/resource-manager/mysql/2022-01-01/serverrestart/method_serversrestart.go b/resource-manager/mysql/2022-01-01/serverrestart/method_serversrestart.go new file mode 100644 index 00000000000..8954c04f305 --- /dev/null +++ b/resource-manager/mysql/2022-01-01/serverrestart/method_serversrestart.go @@ -0,0 +1,74 @@ +package serverrestart + +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 ServersRestartOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ServersRestart ... +func (c ServerRestartClient) ServersRestart(ctx context.Context, id FlexibleServerId, input ServerRestartParameter) (result ServersRestartOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restart", 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 +} + +// ServersRestartThenPoll performs ServersRestart then polls until it's completed +func (c ServerRestartClient) ServersRestartThenPoll(ctx context.Context, id FlexibleServerId, input ServerRestartParameter) error { + result, err := c.ServersRestart(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ServersRestart: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ServersRestart: %+v", err) + } + + return nil +} diff --git a/resource-manager/mysql/2022-01-01/serverrestart/method_serversrestart_autorest.go b/resource-manager/mysql/2022-01-01/serverrestart/method_serversrestart_autorest.go deleted file mode 100644 index c0c843cd1e2..00000000000 --- a/resource-manager/mysql/2022-01-01/serverrestart/method_serversrestart_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package serverrestart - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ServersRestartOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// ServersRestart ... -func (c ServerRestartClient) ServersRestart(ctx context.Context, id FlexibleServerId, input ServerRestartParameter) (result ServersRestartOperationResponse, err error) { - req, err := c.preparerForServersRestart(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "serverrestart.ServerRestartClient", "ServersRestart", nil, "Failure preparing request") - return - } - - result, err = c.senderForServersRestart(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "serverrestart.ServerRestartClient", "ServersRestart", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// ServersRestartThenPoll performs ServersRestart then polls until it's completed -func (c ServerRestartClient) ServersRestartThenPoll(ctx context.Context, id FlexibleServerId, input ServerRestartParameter) error { - result, err := c.ServersRestart(ctx, id, input) - if err != nil { - return fmt.Errorf("performing ServersRestart: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after ServersRestart: %+v", err) - } - - return nil -} - -// preparerForServersRestart prepares the ServersRestart request. -func (c ServerRestartClient) preparerForServersRestart(ctx context.Context, id FlexibleServerId, input ServerRestartParameter) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/restart", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForServersRestart sends the ServersRestart request. The method will close the -// http.Response Body if it receives an error. -func (c ServerRestartClient) senderForServersRestart(ctx context.Context, req *http.Request) (future ServersRestartOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/mysql/2022-01-01/servers/client.go b/resource-manager/mysql/2022-01-01/servers/client.go index fd9e02ba599..a1e11668771 100644 --- a/resource-manager/mysql/2022-01-01/servers/client.go +++ b/resource-manager/mysql/2022-01-01/servers/client.go @@ -1,18 +1,26 @@ package servers -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 ServersClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewServersClientWithBaseURI(endpoint string) ServersClient { - return ServersClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewServersClientWithBaseURI(api environments.Api) (*ServersClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "servers", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ServersClient: %+v", err) } + + return &ServersClient{ + Client: client, + }, nil } diff --git a/resource-manager/mysql/2022-01-01/servers/constants.go b/resource-manager/mysql/2022-01-01/servers/constants.go index 9c01b32c11d..38f0dee4a21 100644 --- a/resource-manager/mysql/2022-01-01/servers/constants.go +++ b/resource-manager/mysql/2022-01-01/servers/constants.go @@ -1,6 +1,10 @@ package servers -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. @@ -23,6 +27,19 @@ func PossibleValuesForCreateMode() []string { } } +func (s *CreateMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCreateMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseCreateMode(input string) (*CreateMode, error) { vals := map[string]CreateMode{ "default": CreateModeDefault, @@ -53,6 +70,19 @@ func PossibleValuesForDataEncryptionType() []string { } } +func (s *DataEncryptionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDataEncryptionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseDataEncryptionType(input string) (*DataEncryptionType, error) { vals := map[string]DataEncryptionType{ "azurekeyvault": DataEncryptionTypeAzureKeyVault, @@ -81,6 +111,19 @@ func PossibleValuesForEnableStatusEnum() []string { } } +func (s *EnableStatusEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEnableStatusEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseEnableStatusEnum(input string) (*EnableStatusEnum, error) { vals := map[string]EnableStatusEnum{ "disabled": EnableStatusEnumDisabled, @@ -111,6 +154,19 @@ func PossibleValuesForHighAvailabilityMode() []string { } } +func (s *HighAvailabilityMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHighAvailabilityMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseHighAvailabilityMode(input string) (*HighAvailabilityMode, error) { vals := map[string]HighAvailabilityMode{ "disabled": HighAvailabilityModeDisabled, @@ -146,6 +202,19 @@ func PossibleValuesForHighAvailabilityState() []string { } } +func (s *HighAvailabilityState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHighAvailabilityState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseHighAvailabilityState(input string) (*HighAvailabilityState, error) { vals := map[string]HighAvailabilityState{ "creatingstandby": HighAvailabilityStateCreatingStandby, @@ -175,6 +244,19 @@ func PossibleValuesForManagedServiceIdentityType() []string { } } +func (s *ManagedServiceIdentityType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedServiceIdentityType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseManagedServiceIdentityType(input string) (*ManagedServiceIdentityType, error) { vals := map[string]ManagedServiceIdentityType{ "userassigned": ManagedServiceIdentityTypeUserAssigned, @@ -204,6 +286,19 @@ func PossibleValuesForReplicationRole() []string { } } +func (s *ReplicationRole) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseReplicationRole(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseReplicationRole(input string) (*ReplicationRole, error) { vals := map[string]ReplicationRole{ "none": ReplicationRoleNone, @@ -243,6 +338,19 @@ func PossibleValuesForServerState() []string { } } +func (s *ServerState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServerState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseServerState(input string) (*ServerState, error) { vals := map[string]ServerState{ "disabled": ServerStateDisabled, @@ -276,6 +384,19 @@ func PossibleValuesForServerVersion() []string { } } +func (s *ServerVersion) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServerVersion(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseServerVersion(input string) (*ServerVersion, error) { vals := map[string]ServerVersion{ "8.0.21": ServerVersionEightPointZeroPointTwoOne, @@ -306,6 +427,19 @@ func PossibleValuesForSkuTier() []string { } } +func (s *SkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseSkuTier(input string) (*SkuTier, error) { vals := map[string]SkuTier{ "burstable": SkuTierBurstable, diff --git a/resource-manager/mysql/2022-01-01/servers/method_create.go b/resource-manager/mysql/2022-01-01/servers/method_create.go new file mode 100644 index 00000000000..7d5c992b539 --- /dev/null +++ b/resource-manager/mysql/2022-01-01/servers/method_create.go @@ -0,0 +1,75 @@ +package servers + +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 CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Create ... +func (c ServersClient) Create(ctx context.Context, id FlexibleServerId, input Server) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c ServersClient) CreateThenPoll(ctx context.Context, id FlexibleServerId, input Server) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/mysql/2022-01-01/servers/method_create_autorest.go b/resource-manager/mysql/2022-01-01/servers/method_create_autorest.go deleted file mode 100644 index f7cd73566e6..00000000000 --- a/resource-manager/mysql/2022-01-01/servers/method_create_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package servers - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Create ... -func (c ServersClient) Create(ctx context.Context, id FlexibleServerId, input Server) (result CreateOperationResponse, err error) { - req, err := c.preparerForCreate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "Create", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "Create", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateThenPoll performs Create then polls until it's completed -func (c ServersClient) CreateThenPoll(ctx context.Context, id FlexibleServerId, input Server) error { - result, err := c.Create(ctx, id, input) - if err != nil { - return fmt.Errorf("performing Create: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Create: %+v", err) - } - - return nil -} - -// preparerForCreate prepares the Create request. -func (c ServersClient) preparerForCreate(ctx context.Context, id FlexibleServerId, input Server) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreate sends the Create request. The method will close the -// http.Response Body if it receives an error. -func (c ServersClient) senderForCreate(ctx context.Context, req *http.Request) (future CreateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/mysql/2022-01-01/servers/method_delete.go b/resource-manager/mysql/2022-01-01/servers/method_delete.go new file mode 100644 index 00000000000..c2dab4be6e1 --- /dev/null +++ b/resource-manager/mysql/2022-01-01/servers/method_delete.go @@ -0,0 +1,71 @@ +package servers + +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 ServersClient) Delete(ctx context.Context, id FlexibleServerId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 ServersClient) DeleteThenPoll(ctx context.Context, id FlexibleServerId) 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 +} diff --git a/resource-manager/mysql/2022-01-01/servers/method_delete_autorest.go b/resource-manager/mysql/2022-01-01/servers/method_delete_autorest.go deleted file mode 100644 index d05fd1a076a..00000000000 --- a/resource-manager/mysql/2022-01-01/servers/method_delete_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package servers - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// Delete ... -func (c ServersClient) Delete(ctx context.Context, id FlexibleServerId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c ServersClient) DeleteThenPoll(ctx context.Context, id FlexibleServerId) error { - result, err := c.Delete(ctx, id) - if err != nil { - return fmt.Errorf("performing Delete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Delete: %+v", err) - } - - return nil -} - -// preparerForDelete prepares the Delete request. -func (c ServersClient) preparerForDelete(ctx context.Context, id FlexibleServerId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDelete sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (c ServersClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/mysql/2022-01-01/servers/method_get.go b/resource-manager/mysql/2022-01-01/servers/method_get.go new file mode 100644 index 00000000000..7ec2c3f3db3 --- /dev/null +++ b/resource-manager/mysql/2022-01-01/servers/method_get.go @@ -0,0 +1,51 @@ +package servers + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Server +} + +// Get ... +func (c ServersClient) Get(ctx context.Context, id FlexibleServerId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/mysql/2022-01-01/servers/method_get_autorest.go b/resource-manager/mysql/2022-01-01/servers/method_get_autorest.go deleted file mode 100644 index bb0074a3085..00000000000 --- a/resource-manager/mysql/2022-01-01/servers/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package servers - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *Server -} - -// Get ... -func (c ServersClient) Get(ctx context.Context, id FlexibleServerId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ServersClient) preparerForGet(ctx context.Context, id FlexibleServerId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c ServersClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/mysql/2022-01-01/servers/method_list.go b/resource-manager/mysql/2022-01-01/servers/method_list.go new file mode 100644 index 00000000000..50c7b1709d1 --- /dev/null +++ b/resource-manager/mysql/2022-01-01/servers/method_list.go @@ -0,0 +1,90 @@ +package servers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Server +} + +type ListCompleteResult struct { + Items []Server +} + +// List ... +func (c ServersClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.DBforMySQL/flexibleServers", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Server `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ServersClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, ServerOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ServersClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ServerOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Server, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/mysql/2022-01-01/servers/method_list_autorest.go b/resource-manager/mysql/2022-01-01/servers/method_list_autorest.go deleted file mode 100644 index fb15e88ae69..00000000000 --- a/resource-manager/mysql/2022-01-01/servers/method_list_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package servers - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListOperationResponse struct { - HttpResponse *http.Response - Model *[]Server - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []Server -} - -func (r ListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// List ... -func (c ServersClient) List(ctx context.Context, id commonids.SubscriptionId) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c ServersClient) preparerForList(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.DBforMySQL/flexibleServers", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c ServersClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForList handles the response to the List request. The method always -// closes the http.Response Body. -func (c ServersClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []Server `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { - req, err := c.preparerForListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c ServersClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, ServerOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ServersClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ServerOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]Server, 0) - - page, err := c.List(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/mysql/2022-01-01/servers/method_listbyresourcegroup.go b/resource-manager/mysql/2022-01-01/servers/method_listbyresourcegroup.go new file mode 100644 index 00000000000..d7037bf20b2 --- /dev/null +++ b/resource-manager/mysql/2022-01-01/servers/method_listbyresourcegroup.go @@ -0,0 +1,90 @@ +package servers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Server +} + +type ListByResourceGroupCompleteResult struct { + Items []Server +} + +// ListByResourceGroup ... +func (c ServersClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.DBforMySQL/flexibleServers", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Server `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c ServersClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, ServerOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ServersClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ServerOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]Server, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/mysql/2022-01-01/servers/method_listbyresourcegroup_autorest.go b/resource-manager/mysql/2022-01-01/servers/method_listbyresourcegroup_autorest.go deleted file mode 100644 index 6d0822e633f..00000000000 --- a/resource-manager/mysql/2022-01-01/servers/method_listbyresourcegroup_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package servers - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByResourceGroupOperationResponse struct { - HttpResponse *http.Response - Model *[]Server - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByResourceGroupOperationResponse, error) -} - -type ListByResourceGroupCompleteResult struct { - Items []Server -} - -func (r ListByResourceGroupOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByResourceGroupOperationResponse) LoadMore(ctx context.Context) (resp ListByResourceGroupOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByResourceGroup ... -func (c ServersClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (resp ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroup(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "ListByResourceGroup", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByResourceGroup(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "ListByResourceGroup", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByResourceGroup prepares the ListByResourceGroup request. -func (c ServersClient) preparerForListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.DBforMySQL/flexibleServers", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByResourceGroupWithNextLink prepares the ListByResourceGroup request with the given nextLink token. -func (c ServersClient) preparerForListByResourceGroupWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByResourceGroup handles the response to the ListByResourceGroup request. The method always -// closes the http.Response Body. -func (c ServersClient) responderForListByResourceGroup(resp *http.Response) (result ListByResourceGroupOperationResponse, err error) { - type page struct { - Values []Server `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroupWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "ListByResourceGroup", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByResourceGroup(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "ListByResourceGroup", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByResourceGroupComplete retrieves all of the results into a single object -func (c ServersClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { - return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, ServerOperationPredicate{}) -} - -// ListByResourceGroupCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ServersClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ServerOperationPredicate) (resp ListByResourceGroupCompleteResult, err error) { - items := make([]Server, 0) - - page, err := c.ListByResourceGroup(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByResourceGroupCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/mysql/2022-01-01/servers/method_replicaslistbyserver.go b/resource-manager/mysql/2022-01-01/servers/method_replicaslistbyserver.go new file mode 100644 index 00000000000..91d61596f4f --- /dev/null +++ b/resource-manager/mysql/2022-01-01/servers/method_replicaslistbyserver.go @@ -0,0 +1,89 @@ +package servers + +import ( + "context" + "fmt" + "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 ReplicasListByServerOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Server +} + +type ReplicasListByServerCompleteResult struct { + Items []Server +} + +// ReplicasListByServer ... +func (c ServersClient) ReplicasListByServer(ctx context.Context, id FlexibleServerId) (result ReplicasListByServerOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/replicas", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Server `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ReplicasListByServerComplete retrieves all the results into a single object +func (c ServersClient) ReplicasListByServerComplete(ctx context.Context, id FlexibleServerId) (ReplicasListByServerCompleteResult, error) { + return c.ReplicasListByServerCompleteMatchingPredicate(ctx, id, ServerOperationPredicate{}) +} + +// ReplicasListByServerCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ServersClient) ReplicasListByServerCompleteMatchingPredicate(ctx context.Context, id FlexibleServerId, predicate ServerOperationPredicate) (result ReplicasListByServerCompleteResult, err error) { + items := make([]Server, 0) + + resp, err := c.ReplicasListByServer(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ReplicasListByServerCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/mysql/2022-01-01/servers/method_replicaslistbyserver_autorest.go b/resource-manager/mysql/2022-01-01/servers/method_replicaslistbyserver_autorest.go deleted file mode 100644 index c0bf40cf8b3..00000000000 --- a/resource-manager/mysql/2022-01-01/servers/method_replicaslistbyserver_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package servers - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ReplicasListByServerOperationResponse struct { - HttpResponse *http.Response - Model *[]Server - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ReplicasListByServerOperationResponse, error) -} - -type ReplicasListByServerCompleteResult struct { - Items []Server -} - -func (r ReplicasListByServerOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ReplicasListByServerOperationResponse) LoadMore(ctx context.Context) (resp ReplicasListByServerOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ReplicasListByServer ... -func (c ServersClient) ReplicasListByServer(ctx context.Context, id FlexibleServerId) (resp ReplicasListByServerOperationResponse, err error) { - req, err := c.preparerForReplicasListByServer(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "ReplicasListByServer", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "ReplicasListByServer", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForReplicasListByServer(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "ReplicasListByServer", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForReplicasListByServer prepares the ReplicasListByServer request. -func (c ServersClient) preparerForReplicasListByServer(ctx context.Context, id FlexibleServerId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/replicas", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForReplicasListByServerWithNextLink prepares the ReplicasListByServer request with the given nextLink token. -func (c ServersClient) preparerForReplicasListByServerWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForReplicasListByServer handles the response to the ReplicasListByServer request. The method always -// closes the http.Response Body. -func (c ServersClient) responderForReplicasListByServer(resp *http.Response) (result ReplicasListByServerOperationResponse, err error) { - type page struct { - Values []Server `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ReplicasListByServerOperationResponse, err error) { - req, err := c.preparerForReplicasListByServerWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "ReplicasListByServer", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "ReplicasListByServer", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForReplicasListByServer(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "ReplicasListByServer", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ReplicasListByServerComplete retrieves all of the results into a single object -func (c ServersClient) ReplicasListByServerComplete(ctx context.Context, id FlexibleServerId) (ReplicasListByServerCompleteResult, error) { - return c.ReplicasListByServerCompleteMatchingPredicate(ctx, id, ServerOperationPredicate{}) -} - -// ReplicasListByServerCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ServersClient) ReplicasListByServerCompleteMatchingPredicate(ctx context.Context, id FlexibleServerId, predicate ServerOperationPredicate) (resp ReplicasListByServerCompleteResult, err error) { - items := make([]Server, 0) - - page, err := c.ReplicasListByServer(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ReplicasListByServerCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/mysql/2022-01-01/servers/method_update.go b/resource-manager/mysql/2022-01-01/servers/method_update.go new file mode 100644 index 00000000000..c25f4634b6d --- /dev/null +++ b/resource-manager/mysql/2022-01-01/servers/method_update.go @@ -0,0 +1,74 @@ +package servers + +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 UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Update ... +func (c ServersClient) Update(ctx context.Context, id FlexibleServerId, input ServerForUpdate) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + 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 +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c ServersClient) UpdateThenPoll(ctx context.Context, id FlexibleServerId, input ServerForUpdate) error { + result, err := c.Update(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/resource-manager/mysql/2022-01-01/servers/method_update_autorest.go b/resource-manager/mysql/2022-01-01/servers/method_update_autorest.go deleted file mode 100644 index 588b1305994..00000000000 --- a/resource-manager/mysql/2022-01-01/servers/method_update_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package servers - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Update ... -func (c ServersClient) Update(ctx context.Context, id FlexibleServerId, input ServerForUpdate) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "Update", nil, "Failure preparing request") - return - } - - result, err = c.senderForUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "servers.ServersClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// UpdateThenPoll performs Update then polls until it's completed -func (c ServersClient) UpdateThenPoll(ctx context.Context, id FlexibleServerId, input ServerForUpdate) error { - result, err := c.Update(ctx, id, input) - if err != nil { - return fmt.Errorf("performing Update: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Update: %+v", err) - } - - return nil -} - -// preparerForUpdate prepares the Update request. -func (c ServersClient) preparerForUpdate(ctx context.Context, id FlexibleServerId, input ServerForUpdate) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForUpdate sends the Update request. The method will close the -// http.Response Body if it receives an error. -func (c ServersClient) senderForUpdate(ctx context.Context, req *http.Request) (future UpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/mysql/2022-01-01/serverstart/client.go b/resource-manager/mysql/2022-01-01/serverstart/client.go index 035bd9107ce..f24d38e00f9 100644 --- a/resource-manager/mysql/2022-01-01/serverstart/client.go +++ b/resource-manager/mysql/2022-01-01/serverstart/client.go @@ -1,18 +1,26 @@ package serverstart -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 ServerStartClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewServerStartClientWithBaseURI(endpoint string) ServerStartClient { - return ServerStartClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewServerStartClientWithBaseURI(api environments.Api) (*ServerStartClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "serverstart", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ServerStartClient: %+v", err) } + + return &ServerStartClient{ + Client: client, + }, nil } diff --git a/resource-manager/mysql/2022-01-01/serverstart/method_serversstart.go b/resource-manager/mysql/2022-01-01/serverstart/method_serversstart.go new file mode 100644 index 00000000000..195d7ff6855 --- /dev/null +++ b/resource-manager/mysql/2022-01-01/serverstart/method_serversstart.go @@ -0,0 +1,70 @@ +package serverstart + +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 ServersStartOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ServersStart ... +func (c ServerStartClient) ServersStart(ctx context.Context, id FlexibleServerId) (result ServersStartOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/start", 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 +} + +// ServersStartThenPoll performs ServersStart then polls until it's completed +func (c ServerStartClient) ServersStartThenPoll(ctx context.Context, id FlexibleServerId) error { + result, err := c.ServersStart(ctx, id) + if err != nil { + return fmt.Errorf("performing ServersStart: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ServersStart: %+v", err) + } + + return nil +} diff --git a/resource-manager/mysql/2022-01-01/serverstart/method_serversstart_autorest.go b/resource-manager/mysql/2022-01-01/serverstart/method_serversstart_autorest.go deleted file mode 100644 index d9ba15437e8..00000000000 --- a/resource-manager/mysql/2022-01-01/serverstart/method_serversstart_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package serverstart - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ServersStartOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// ServersStart ... -func (c ServerStartClient) ServersStart(ctx context.Context, id FlexibleServerId) (result ServersStartOperationResponse, err error) { - req, err := c.preparerForServersStart(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "serverstart.ServerStartClient", "ServersStart", nil, "Failure preparing request") - return - } - - result, err = c.senderForServersStart(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "serverstart.ServerStartClient", "ServersStart", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// ServersStartThenPoll performs ServersStart then polls until it's completed -func (c ServerStartClient) ServersStartThenPoll(ctx context.Context, id FlexibleServerId) error { - result, err := c.ServersStart(ctx, id) - if err != nil { - return fmt.Errorf("performing ServersStart: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after ServersStart: %+v", err) - } - - return nil -} - -// preparerForServersStart prepares the ServersStart request. -func (c ServerStartClient) preparerForServersStart(ctx context.Context, id FlexibleServerId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/start", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForServersStart sends the ServersStart request. The method will close the -// http.Response Body if it receives an error. -func (c ServerStartClient) senderForServersStart(ctx context.Context, req *http.Request) (future ServersStartOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/mysql/2022-01-01/serverstop/client.go b/resource-manager/mysql/2022-01-01/serverstop/client.go index 488dece59ac..c47cb0e7335 100644 --- a/resource-manager/mysql/2022-01-01/serverstop/client.go +++ b/resource-manager/mysql/2022-01-01/serverstop/client.go @@ -1,18 +1,26 @@ package serverstop -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 ServerStopClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewServerStopClientWithBaseURI(endpoint string) ServerStopClient { - return ServerStopClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewServerStopClientWithBaseURI(api environments.Api) (*ServerStopClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "serverstop", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ServerStopClient: %+v", err) } + + return &ServerStopClient{ + Client: client, + }, nil } diff --git a/resource-manager/mysql/2022-01-01/serverstop/method_serversstop.go b/resource-manager/mysql/2022-01-01/serverstop/method_serversstop.go new file mode 100644 index 00000000000..f63fd390edb --- /dev/null +++ b/resource-manager/mysql/2022-01-01/serverstop/method_serversstop.go @@ -0,0 +1,70 @@ +package serverstop + +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 ServersStopOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ServersStop ... +func (c ServerStopClient) ServersStop(ctx context.Context, id FlexibleServerId) (result ServersStopOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/stop", 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 +} + +// ServersStopThenPoll performs ServersStop then polls until it's completed +func (c ServerStopClient) ServersStopThenPoll(ctx context.Context, id FlexibleServerId) error { + result, err := c.ServersStop(ctx, id) + if err != nil { + return fmt.Errorf("performing ServersStop: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ServersStop: %+v", err) + } + + return nil +} diff --git a/resource-manager/mysql/2022-01-01/serverstop/method_serversstop_autorest.go b/resource-manager/mysql/2022-01-01/serverstop/method_serversstop_autorest.go deleted file mode 100644 index cc1b5c74e6a..00000000000 --- a/resource-manager/mysql/2022-01-01/serverstop/method_serversstop_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package serverstop - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ServersStopOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// ServersStop ... -func (c ServerStopClient) ServersStop(ctx context.Context, id FlexibleServerId) (result ServersStopOperationResponse, err error) { - req, err := c.preparerForServersStop(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "serverstop.ServerStopClient", "ServersStop", nil, "Failure preparing request") - return - } - - result, err = c.senderForServersStop(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "serverstop.ServerStopClient", "ServersStop", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// ServersStopThenPoll performs ServersStop then polls until it's completed -func (c ServerStopClient) ServersStopThenPoll(ctx context.Context, id FlexibleServerId) error { - result, err := c.ServersStop(ctx, id) - if err != nil { - return fmt.Errorf("performing ServersStop: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after ServersStop: %+v", err) - } - - return nil -} - -// preparerForServersStop prepares the ServersStop request. -func (c ServerStopClient) preparerForServersStop(ctx context.Context, id FlexibleServerId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/stop", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForServersStop sends the ServersStop request. The method will close the -// http.Response Body if it receives an error. -func (c ServerStopClient) senderForServersStop(ctx context.Context, req *http.Request) (future ServersStopOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/orbital/2022-11-01/client.go b/resource-manager/orbital/2022-11-01/client.go index 26b54f14d68..96c203b4eef 100644 --- a/resource-manager/orbital/2022-11-01/client.go +++ b/resource-manager/orbital/2022-11-01/client.go @@ -4,11 +4,14 @@ package v2022_11_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/orbital/2022-11-01/contact" "github.com/hashicorp/go-azure-sdk/resource-manager/orbital/2022-11-01/contactprofile" "github.com/hashicorp/go-azure-sdk/resource-manager/orbital/2022-11-01/groundstation" "github.com/hashicorp/go-azure-sdk/resource-manager/orbital/2022-11-01/spacecraft" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/environments" ) type Client struct { @@ -18,24 +21,35 @@ type Client struct { Spacecraft *spacecraft.SpacecraftClient } -func NewClientWithBaseURI(endpoint string, configureAuthFunc func(c *autorest.Client)) Client { - - contactClient := contact.NewContactClientWithBaseURI(endpoint) - configureAuthFunc(&contactClient.Client) - - contactProfileClient := contactprofile.NewContactProfileClientWithBaseURI(endpoint) - configureAuthFunc(&contactProfileClient.Client) +func NewClientWithBaseURI(api environments.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + contactClient, err := contact.NewContactClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Contact client: %+v", err) + } + configureFunc(contactClient.Client) - groundStationClient := groundstation.NewGroundStationClientWithBaseURI(endpoint) - configureAuthFunc(&groundStationClient.Client) + contactProfileClient, err := contactprofile.NewContactProfileClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ContactProfile client: %+v", err) + } + configureFunc(contactProfileClient.Client) - spacecraftClient := spacecraft.NewSpacecraftClientWithBaseURI(endpoint) - configureAuthFunc(&spacecraftClient.Client) + groundStationClient, err := groundstation.NewGroundStationClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building GroundStation client: %+v", err) + } + configureFunc(groundStationClient.Client) - return Client{ - Contact: &contactClient, - ContactProfile: &contactProfileClient, - GroundStation: &groundStationClient, - Spacecraft: &spacecraftClient, + spacecraftClient, err := spacecraft.NewSpacecraftClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Spacecraft client: %+v", err) } + configureFunc(spacecraftClient.Client) + + return &Client{ + Contact: contactClient, + ContactProfile: contactProfileClient, + GroundStation: groundStationClient, + Spacecraft: spacecraftClient, + }, nil } diff --git a/resource-manager/orbital/2022-11-01/contact/client.go b/resource-manager/orbital/2022-11-01/contact/client.go index ff7cb641ed8..1330f436ede 100644 --- a/resource-manager/orbital/2022-11-01/contact/client.go +++ b/resource-manager/orbital/2022-11-01/contact/client.go @@ -1,18 +1,26 @@ package contact -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 ContactClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewContactClientWithBaseURI(endpoint string) ContactClient { - return ContactClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewContactClientWithBaseURI(api environments.Api) (*ContactClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "contact", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ContactClient: %+v", err) } + + return &ContactClient{ + Client: client, + }, nil } diff --git a/resource-manager/orbital/2022-11-01/contact/constants.go b/resource-manager/orbital/2022-11-01/contact/constants.go index 00df14ebc3d..b485cf4e665 100644 --- a/resource-manager/orbital/2022-11-01/contact/constants.go +++ b/resource-manager/orbital/2022-11-01/contact/constants.go @@ -1,6 +1,10 @@ package contact -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. @@ -25,6 +29,19 @@ func PossibleValuesForContactsStatus() []string { } } +func (s *ContactsStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseContactsStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseContactsStatus(input string) (*ContactsStatus, error) { vals := map[string]ContactsStatus{ "cancelled": ContactsStatusCancelled, @@ -64,6 +81,19 @@ func PossibleValuesForProvisioningState() []string { } } +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseProvisioningState(input string) (*ProvisioningState, error) { vals := map[string]ProvisioningState{ "canceled": ProvisioningStateCanceled, diff --git a/resource-manager/orbital/2022-11-01/contact/method_create.go b/resource-manager/orbital/2022-11-01/contact/method_create.go new file mode 100644 index 00000000000..9efedea4233 --- /dev/null +++ b/resource-manager/orbital/2022-11-01/contact/method_create.go @@ -0,0 +1,74 @@ +package contact + +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 CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Create ... +func (c ContactClient) Create(ctx context.Context, id ContactId, input Contact) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c ContactClient) CreateThenPoll(ctx context.Context, id ContactId, input Contact) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/orbital/2022-11-01/contact/method_create_autorest.go b/resource-manager/orbital/2022-11-01/contact/method_create_autorest.go deleted file mode 100644 index 1adb20e5486..00000000000 --- a/resource-manager/orbital/2022-11-01/contact/method_create_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package contact - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Create ... -func (c ContactClient) Create(ctx context.Context, id ContactId, input Contact) (result CreateOperationResponse, err error) { - req, err := c.preparerForCreate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "contact.ContactClient", "Create", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "contact.ContactClient", "Create", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateThenPoll performs Create then polls until it's completed -func (c ContactClient) CreateThenPoll(ctx context.Context, id ContactId, input Contact) error { - result, err := c.Create(ctx, id, input) - if err != nil { - return fmt.Errorf("performing Create: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Create: %+v", err) - } - - return nil -} - -// preparerForCreate prepares the Create request. -func (c ContactClient) preparerForCreate(ctx context.Context, id ContactId, input Contact) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreate sends the Create request. The method will close the -// http.Response Body if it receives an error. -func (c ContactClient) senderForCreate(ctx context.Context, req *http.Request) (future CreateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/orbital/2022-11-01/contact/method_delete.go b/resource-manager/orbital/2022-11-01/contact/method_delete.go new file mode 100644 index 00000000000..2f61106229b --- /dev/null +++ b/resource-manager/orbital/2022-11-01/contact/method_delete.go @@ -0,0 +1,71 @@ +package contact + +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 ContactClient) Delete(ctx context.Context, id ContactId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 ContactClient) DeleteThenPoll(ctx context.Context, id ContactId) 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 +} diff --git a/resource-manager/orbital/2022-11-01/contact/method_delete_autorest.go b/resource-manager/orbital/2022-11-01/contact/method_delete_autorest.go deleted file mode 100644 index 2a53c31219a..00000000000 --- a/resource-manager/orbital/2022-11-01/contact/method_delete_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package contact - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// Delete ... -func (c ContactClient) Delete(ctx context.Context, id ContactId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "contact.ContactClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "contact.ContactClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c ContactClient) DeleteThenPoll(ctx context.Context, id ContactId) error { - result, err := c.Delete(ctx, id) - if err != nil { - return fmt.Errorf("performing Delete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Delete: %+v", err) - } - - return nil -} - -// preparerForDelete prepares the Delete request. -func (c ContactClient) preparerForDelete(ctx context.Context, id ContactId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDelete sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (c ContactClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/orbital/2022-11-01/contact/method_get.go b/resource-manager/orbital/2022-11-01/contact/method_get.go new file mode 100644 index 00000000000..72fa8b2d36e --- /dev/null +++ b/resource-manager/orbital/2022-11-01/contact/method_get.go @@ -0,0 +1,51 @@ +package contact + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Contact +} + +// Get ... +func (c ContactClient) Get(ctx context.Context, id ContactId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/orbital/2022-11-01/contact/method_get_autorest.go b/resource-manager/orbital/2022-11-01/contact/method_get_autorest.go deleted file mode 100644 index c28088588f1..00000000000 --- a/resource-manager/orbital/2022-11-01/contact/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package contact - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *Contact -} - -// Get ... -func (c ContactClient) Get(ctx context.Context, id ContactId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "contact.ContactClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "contact.ContactClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "contact.ContactClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ContactClient) preparerForGet(ctx context.Context, id ContactId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c ContactClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/orbital/2022-11-01/contact/method_list.go b/resource-manager/orbital/2022-11-01/contact/method_list.go new file mode 100644 index 00000000000..0adbe2941ae --- /dev/null +++ b/resource-manager/orbital/2022-11-01/contact/method_list.go @@ -0,0 +1,89 @@ +package contact + +import ( + "context" + "fmt" + "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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Contact +} + +type ListCompleteResult struct { + Items []Contact +} + +// List ... +func (c ContactClient) List(ctx context.Context, id SpacecraftId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/contacts", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Contact `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ContactClient) ListComplete(ctx context.Context, id SpacecraftId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, ContactOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ContactClient) ListCompleteMatchingPredicate(ctx context.Context, id SpacecraftId, predicate ContactOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Contact, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/orbital/2022-11-01/contact/method_list_autorest.go b/resource-manager/orbital/2022-11-01/contact/method_list_autorest.go deleted file mode 100644 index bd504ab68bd..00000000000 --- a/resource-manager/orbital/2022-11-01/contact/method_list_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package contact - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListOperationResponse struct { - HttpResponse *http.Response - Model *[]Contact - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []Contact -} - -func (r ListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// List ... -func (c ContactClient) List(ctx context.Context, id SpacecraftId) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "contact.ContactClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "contact.ContactClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "contact.ContactClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c ContactClient) preparerForList(ctx context.Context, id SpacecraftId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/contacts", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c ContactClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForList handles the response to the List request. The method always -// closes the http.Response Body. -func (c ContactClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []Contact `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { - req, err := c.preparerForListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "contact.ContactClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "contact.ContactClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "contact.ContactClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c ContactClient) ListComplete(ctx context.Context, id SpacecraftId) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, ContactOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ContactClient) ListCompleteMatchingPredicate(ctx context.Context, id SpacecraftId, predicate ContactOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]Contact, 0) - - page, err := c.List(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/orbital/2022-11-01/contact/method_spacecraftslistavailablecontacts.go b/resource-manager/orbital/2022-11-01/contact/method_spacecraftslistavailablecontacts.go new file mode 100644 index 00000000000..a8c5a21a386 --- /dev/null +++ b/resource-manager/orbital/2022-11-01/contact/method_spacecraftslistavailablecontacts.go @@ -0,0 +1,88 @@ +package contact + +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 SpacecraftsListAvailableContactsOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *[]AvailableContacts +} + +type SpacecraftsListAvailableContactsCompleteResult struct { + Items []AvailableContacts +} + +// SpacecraftsListAvailableContacts ... +func (c ContactClient) SpacecraftsListAvailableContacts(ctx context.Context, id SpacecraftId, input ContactParameters) (result SpacecraftsListAvailableContactsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listAvailableContacts", 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 + } + + var values struct { + Values *[]AvailableContacts `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// SpacecraftsListAvailableContactsThenPoll performs SpacecraftsListAvailableContacts then polls until it's completed +func (c ContactClient) SpacecraftsListAvailableContactsThenPoll(ctx context.Context, id SpacecraftId, input ContactParameters) error { + result, err := c.SpacecraftsListAvailableContacts(ctx, id, input) + if err != nil { + return fmt.Errorf("performing SpacecraftsListAvailableContacts: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SpacecraftsListAvailableContacts: %+v", err) + } + + return nil +} diff --git a/resource-manager/orbital/2022-11-01/contact/method_spacecraftslistavailablecontacts_autorest.go b/resource-manager/orbital/2022-11-01/contact/method_spacecraftslistavailablecontacts_autorest.go deleted file mode 100644 index a767002c487..00000000000 --- a/resource-manager/orbital/2022-11-01/contact/method_spacecraftslistavailablecontacts_autorest.go +++ /dev/null @@ -1,125 +0,0 @@ -package contact - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type SpacecraftsListAvailableContactsOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response - Model *[]AvailableContacts - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (SpacecraftsListAvailableContactsOperationResponse, error) -} - -type SpacecraftsListAvailableContactsCompleteResult struct { - Items []AvailableContacts -} - -func (r SpacecraftsListAvailableContactsOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r SpacecraftsListAvailableContactsOperationResponse) LoadMore(ctx context.Context) (resp SpacecraftsListAvailableContactsOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// SpacecraftsListAvailableContacts ... -func (c ContactClient) SpacecraftsListAvailableContacts(ctx context.Context, id SpacecraftId, input ContactParameters) (result SpacecraftsListAvailableContactsOperationResponse, err error) { - req, err := c.preparerForSpacecraftsListAvailableContacts(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "contact.ContactClient", "SpacecraftsListAvailableContacts", nil, "Failure preparing request") - return - } - - result, err = c.senderForSpacecraftsListAvailableContacts(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "contact.ContactClient", "SpacecraftsListAvailableContacts", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// SpacecraftsListAvailableContactsThenPoll performs SpacecraftsListAvailableContacts then polls until it's completed -func (c ContactClient) SpacecraftsListAvailableContactsThenPoll(ctx context.Context, id SpacecraftId, input ContactParameters) error { - result, err := c.SpacecraftsListAvailableContacts(ctx, id, input) - if err != nil { - return fmt.Errorf("performing SpacecraftsListAvailableContacts: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after SpacecraftsListAvailableContacts: %+v", err) - } - - return nil -} - -// preparerForSpacecraftsListAvailableContacts prepares the SpacecraftsListAvailableContacts request. -func (c ContactClient) preparerForSpacecraftsListAvailableContacts(ctx context.Context, id SpacecraftId, input ContactParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/listAvailableContacts", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForSpacecraftsListAvailableContactsWithNextLink prepares the SpacecraftsListAvailableContacts request with the given nextLink token. -func (c ContactClient) preparerForSpacecraftsListAvailableContactsWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForSpacecraftsListAvailableContacts sends the SpacecraftsListAvailableContacts request. The method will close the -// http.Response Body if it receives an error. -func (c ContactClient) senderForSpacecraftsListAvailableContacts(ctx context.Context, req *http.Request) (future SpacecraftsListAvailableContactsOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/orbital/2022-11-01/contactprofile/client.go b/resource-manager/orbital/2022-11-01/contactprofile/client.go index a46f4d053ec..08576043ed3 100644 --- a/resource-manager/orbital/2022-11-01/contactprofile/client.go +++ b/resource-manager/orbital/2022-11-01/contactprofile/client.go @@ -1,18 +1,26 @@ package contactprofile -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 ContactProfileClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewContactProfileClientWithBaseURI(endpoint string) ContactProfileClient { - return ContactProfileClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewContactProfileClientWithBaseURI(api environments.Api) (*ContactProfileClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "contactprofile", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ContactProfileClient: %+v", err) } + + return &ContactProfileClient{ + Client: client, + }, nil } diff --git a/resource-manager/orbital/2022-11-01/contactprofile/constants.go b/resource-manager/orbital/2022-11-01/contactprofile/constants.go index 1a61e972a54..6ceacb048ac 100644 --- a/resource-manager/orbital/2022-11-01/contactprofile/constants.go +++ b/resource-manager/orbital/2022-11-01/contactprofile/constants.go @@ -1,6 +1,10 @@ package contactprofile -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. @@ -21,6 +25,19 @@ func PossibleValuesForAutoTrackingConfiguration() []string { } } +func (s *AutoTrackingConfiguration) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutoTrackingConfiguration(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAutoTrackingConfiguration(input string) (*AutoTrackingConfiguration, error) { vals := map[string]AutoTrackingConfiguration{ "disabled": AutoTrackingConfigurationDisabled, @@ -50,6 +67,19 @@ func PossibleValuesForDirection() []string { } } +func (s *Direction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDirection(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseDirection(input string) (*Direction, error) { vals := map[string]Direction{ "downlink": DirectionDownlink, @@ -82,6 +112,19 @@ func PossibleValuesForPolarization() []string { } } +func (s *Polarization) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePolarization(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePolarization(input string) (*Polarization, error) { vals := map[string]Polarization{ "lhcp": PolarizationLHCP, @@ -112,6 +155,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{ "tcp": ProtocolTCP, @@ -148,6 +204,19 @@ func PossibleValuesForProvisioningState() []string { } } +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseProvisioningState(input string) (*ProvisioningState, error) { vals := map[string]ProvisioningState{ "canceled": ProvisioningStateCanceled, diff --git a/resource-manager/orbital/2022-11-01/contactprofile/method_contactprofilescreateorupdate.go b/resource-manager/orbital/2022-11-01/contactprofile/method_contactprofilescreateorupdate.go new file mode 100644 index 00000000000..abf1ea29f90 --- /dev/null +++ b/resource-manager/orbital/2022-11-01/contactprofile/method_contactprofilescreateorupdate.go @@ -0,0 +1,74 @@ +package contactprofile + +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 ContactProfilesCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ContactProfilesCreateOrUpdate ... +func (c ContactProfileClient) ContactProfilesCreateOrUpdate(ctx context.Context, id ContactProfileId, input ContactProfile) (result ContactProfilesCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 +} + +// ContactProfilesCreateOrUpdateThenPoll performs ContactProfilesCreateOrUpdate then polls until it's completed +func (c ContactProfileClient) ContactProfilesCreateOrUpdateThenPoll(ctx context.Context, id ContactProfileId, input ContactProfile) error { + result, err := c.ContactProfilesCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ContactProfilesCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ContactProfilesCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/orbital/2022-11-01/contactprofile/method_contactprofilescreateorupdate_autorest.go b/resource-manager/orbital/2022-11-01/contactprofile/method_contactprofilescreateorupdate_autorest.go deleted file mode 100644 index 5a08e142f91..00000000000 --- a/resource-manager/orbital/2022-11-01/contactprofile/method_contactprofilescreateorupdate_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package contactprofile - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ContactProfilesCreateOrUpdateOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// ContactProfilesCreateOrUpdate ... -func (c ContactProfileClient) ContactProfilesCreateOrUpdate(ctx context.Context, id ContactProfileId, input ContactProfile) (result ContactProfilesCreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForContactProfilesCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "contactprofile.ContactProfileClient", "ContactProfilesCreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForContactProfilesCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "contactprofile.ContactProfileClient", "ContactProfilesCreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// ContactProfilesCreateOrUpdateThenPoll performs ContactProfilesCreateOrUpdate then polls until it's completed -func (c ContactProfileClient) ContactProfilesCreateOrUpdateThenPoll(ctx context.Context, id ContactProfileId, input ContactProfile) error { - result, err := c.ContactProfilesCreateOrUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing ContactProfilesCreateOrUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after ContactProfilesCreateOrUpdate: %+v", err) - } - - return nil -} - -// preparerForContactProfilesCreateOrUpdate prepares the ContactProfilesCreateOrUpdate request. -func (c ContactProfileClient) preparerForContactProfilesCreateOrUpdate(ctx context.Context, id ContactProfileId, input ContactProfile) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForContactProfilesCreateOrUpdate sends the ContactProfilesCreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c ContactProfileClient) senderForContactProfilesCreateOrUpdate(ctx context.Context, req *http.Request) (future ContactProfilesCreateOrUpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/orbital/2022-11-01/contactprofile/method_contactprofilesdelete.go b/resource-manager/orbital/2022-11-01/contactprofile/method_contactprofilesdelete.go new file mode 100644 index 00000000000..5df4da959cc --- /dev/null +++ b/resource-manager/orbital/2022-11-01/contactprofile/method_contactprofilesdelete.go @@ -0,0 +1,71 @@ +package contactprofile + +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 ContactProfilesDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ContactProfilesDelete ... +func (c ContactProfileClient) ContactProfilesDelete(ctx context.Context, id ContactProfileId) (result ContactProfilesDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 +} + +// ContactProfilesDeleteThenPoll performs ContactProfilesDelete then polls until it's completed +func (c ContactProfileClient) ContactProfilesDeleteThenPoll(ctx context.Context, id ContactProfileId) error { + result, err := c.ContactProfilesDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing ContactProfilesDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ContactProfilesDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/orbital/2022-11-01/contactprofile/method_contactprofilesdelete_autorest.go b/resource-manager/orbital/2022-11-01/contactprofile/method_contactprofilesdelete_autorest.go deleted file mode 100644 index 08f2d705f09..00000000000 --- a/resource-manager/orbital/2022-11-01/contactprofile/method_contactprofilesdelete_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package contactprofile - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ContactProfilesDeleteOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// ContactProfilesDelete ... -func (c ContactProfileClient) ContactProfilesDelete(ctx context.Context, id ContactProfileId) (result ContactProfilesDeleteOperationResponse, err error) { - req, err := c.preparerForContactProfilesDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "contactprofile.ContactProfileClient", "ContactProfilesDelete", nil, "Failure preparing request") - return - } - - result, err = c.senderForContactProfilesDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "contactprofile.ContactProfileClient", "ContactProfilesDelete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// ContactProfilesDeleteThenPoll performs ContactProfilesDelete then polls until it's completed -func (c ContactProfileClient) ContactProfilesDeleteThenPoll(ctx context.Context, id ContactProfileId) error { - result, err := c.ContactProfilesDelete(ctx, id) - if err != nil { - return fmt.Errorf("performing ContactProfilesDelete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after ContactProfilesDelete: %+v", err) - } - - return nil -} - -// preparerForContactProfilesDelete prepares the ContactProfilesDelete request. -func (c ContactProfileClient) preparerForContactProfilesDelete(ctx context.Context, id ContactProfileId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForContactProfilesDelete sends the ContactProfilesDelete request. The method will close the -// http.Response Body if it receives an error. -func (c ContactProfileClient) senderForContactProfilesDelete(ctx context.Context, req *http.Request) (future ContactProfilesDeleteOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/orbital/2022-11-01/contactprofile/method_contactprofilesget.go b/resource-manager/orbital/2022-11-01/contactprofile/method_contactprofilesget.go new file mode 100644 index 00000000000..ee450fdf1bf --- /dev/null +++ b/resource-manager/orbital/2022-11-01/contactprofile/method_contactprofilesget.go @@ -0,0 +1,51 @@ +package contactprofile + +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 ContactProfilesGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ContactProfile +} + +// ContactProfilesGet ... +func (c ContactProfileClient) ContactProfilesGet(ctx context.Context, id ContactProfileId) (result ContactProfilesGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/orbital/2022-11-01/contactprofile/method_contactprofilesget_autorest.go b/resource-manager/orbital/2022-11-01/contactprofile/method_contactprofilesget_autorest.go deleted file mode 100644 index 200c00a149d..00000000000 --- a/resource-manager/orbital/2022-11-01/contactprofile/method_contactprofilesget_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package contactprofile - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ContactProfilesGetOperationResponse struct { - HttpResponse *http.Response - Model *ContactProfile -} - -// ContactProfilesGet ... -func (c ContactProfileClient) ContactProfilesGet(ctx context.Context, id ContactProfileId) (result ContactProfilesGetOperationResponse, err error) { - req, err := c.preparerForContactProfilesGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "contactprofile.ContactProfileClient", "ContactProfilesGet", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "contactprofile.ContactProfileClient", "ContactProfilesGet", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForContactProfilesGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "contactprofile.ContactProfileClient", "ContactProfilesGet", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForContactProfilesGet prepares the ContactProfilesGet request. -func (c ContactProfileClient) preparerForContactProfilesGet(ctx context.Context, id ContactProfileId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForContactProfilesGet handles the response to the ContactProfilesGet request. The method always -// closes the http.Response Body. -func (c ContactProfileClient) responderForContactProfilesGet(resp *http.Response) (result ContactProfilesGetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/orbital/2022-11-01/contactprofile/method_contactprofileslist.go b/resource-manager/orbital/2022-11-01/contactprofile/method_contactprofileslist.go new file mode 100644 index 00000000000..e3f00ee7164 --- /dev/null +++ b/resource-manager/orbital/2022-11-01/contactprofile/method_contactprofileslist.go @@ -0,0 +1,90 @@ +package contactprofile + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ContactProfilesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ContactProfile +} + +type ContactProfilesListCompleteResult struct { + Items []ContactProfile +} + +// ContactProfilesList ... +func (c ContactProfileClient) ContactProfilesList(ctx context.Context, id commonids.ResourceGroupId) (result ContactProfilesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Orbital/contactProfiles", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ContactProfile `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ContactProfilesListComplete retrieves all the results into a single object +func (c ContactProfileClient) ContactProfilesListComplete(ctx context.Context, id commonids.ResourceGroupId) (ContactProfilesListCompleteResult, error) { + return c.ContactProfilesListCompleteMatchingPredicate(ctx, id, ContactProfileOperationPredicate{}) +} + +// ContactProfilesListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ContactProfileClient) ContactProfilesListCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ContactProfileOperationPredicate) (result ContactProfilesListCompleteResult, err error) { + items := make([]ContactProfile, 0) + + resp, err := c.ContactProfilesList(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ContactProfilesListCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/orbital/2022-11-01/contactprofile/method_contactprofileslist_autorest.go b/resource-manager/orbital/2022-11-01/contactprofile/method_contactprofileslist_autorest.go deleted file mode 100644 index 247e74550b9..00000000000 --- a/resource-manager/orbital/2022-11-01/contactprofile/method_contactprofileslist_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package contactprofile - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ContactProfilesListOperationResponse struct { - HttpResponse *http.Response - Model *[]ContactProfile - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ContactProfilesListOperationResponse, error) -} - -type ContactProfilesListCompleteResult struct { - Items []ContactProfile -} - -func (r ContactProfilesListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ContactProfilesListOperationResponse) LoadMore(ctx context.Context) (resp ContactProfilesListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ContactProfilesList ... -func (c ContactProfileClient) ContactProfilesList(ctx context.Context, id commonids.ResourceGroupId) (resp ContactProfilesListOperationResponse, err error) { - req, err := c.preparerForContactProfilesList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "contactprofile.ContactProfileClient", "ContactProfilesList", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "contactprofile.ContactProfileClient", "ContactProfilesList", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForContactProfilesList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "contactprofile.ContactProfileClient", "ContactProfilesList", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForContactProfilesList prepares the ContactProfilesList request. -func (c ContactProfileClient) preparerForContactProfilesList(ctx context.Context, id commonids.ResourceGroupId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Orbital/contactProfiles", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForContactProfilesListWithNextLink prepares the ContactProfilesList request with the given nextLink token. -func (c ContactProfileClient) preparerForContactProfilesListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForContactProfilesList handles the response to the ContactProfilesList request. The method always -// closes the http.Response Body. -func (c ContactProfileClient) responderForContactProfilesList(resp *http.Response) (result ContactProfilesListOperationResponse, err error) { - type page struct { - Values []ContactProfile `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ContactProfilesListOperationResponse, err error) { - req, err := c.preparerForContactProfilesListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "contactprofile.ContactProfileClient", "ContactProfilesList", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "contactprofile.ContactProfileClient", "ContactProfilesList", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForContactProfilesList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "contactprofile.ContactProfileClient", "ContactProfilesList", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ContactProfilesListComplete retrieves all of the results into a single object -func (c ContactProfileClient) ContactProfilesListComplete(ctx context.Context, id commonids.ResourceGroupId) (ContactProfilesListCompleteResult, error) { - return c.ContactProfilesListCompleteMatchingPredicate(ctx, id, ContactProfileOperationPredicate{}) -} - -// ContactProfilesListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ContactProfileClient) ContactProfilesListCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ContactProfileOperationPredicate) (resp ContactProfilesListCompleteResult, err error) { - items := make([]ContactProfile, 0) - - page, err := c.ContactProfilesList(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ContactProfilesListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/orbital/2022-11-01/contactprofile/method_contactprofileslistbysubscription.go b/resource-manager/orbital/2022-11-01/contactprofile/method_contactprofileslistbysubscription.go new file mode 100644 index 00000000000..de2a9c166db --- /dev/null +++ b/resource-manager/orbital/2022-11-01/contactprofile/method_contactprofileslistbysubscription.go @@ -0,0 +1,90 @@ +package contactprofile + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ContactProfilesListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ContactProfile +} + +type ContactProfilesListBySubscriptionCompleteResult struct { + Items []ContactProfile +} + +// ContactProfilesListBySubscription ... +func (c ContactProfileClient) ContactProfilesListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ContactProfilesListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Orbital/contactProfiles", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ContactProfile `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ContactProfilesListBySubscriptionComplete retrieves all the results into a single object +func (c ContactProfileClient) ContactProfilesListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ContactProfilesListBySubscriptionCompleteResult, error) { + return c.ContactProfilesListBySubscriptionCompleteMatchingPredicate(ctx, id, ContactProfileOperationPredicate{}) +} + +// ContactProfilesListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ContactProfileClient) ContactProfilesListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ContactProfileOperationPredicate) (result ContactProfilesListBySubscriptionCompleteResult, err error) { + items := make([]ContactProfile, 0) + + resp, err := c.ContactProfilesListBySubscription(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ContactProfilesListBySubscriptionCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/orbital/2022-11-01/contactprofile/method_contactprofileslistbysubscription_autorest.go b/resource-manager/orbital/2022-11-01/contactprofile/method_contactprofileslistbysubscription_autorest.go deleted file mode 100644 index 4e33b1767ed..00000000000 --- a/resource-manager/orbital/2022-11-01/contactprofile/method_contactprofileslistbysubscription_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package contactprofile - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ContactProfilesListBySubscriptionOperationResponse struct { - HttpResponse *http.Response - Model *[]ContactProfile - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ContactProfilesListBySubscriptionOperationResponse, error) -} - -type ContactProfilesListBySubscriptionCompleteResult struct { - Items []ContactProfile -} - -func (r ContactProfilesListBySubscriptionOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ContactProfilesListBySubscriptionOperationResponse) LoadMore(ctx context.Context) (resp ContactProfilesListBySubscriptionOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ContactProfilesListBySubscription ... -func (c ContactProfileClient) ContactProfilesListBySubscription(ctx context.Context, id commonids.SubscriptionId) (resp ContactProfilesListBySubscriptionOperationResponse, err error) { - req, err := c.preparerForContactProfilesListBySubscription(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "contactprofile.ContactProfileClient", "ContactProfilesListBySubscription", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "contactprofile.ContactProfileClient", "ContactProfilesListBySubscription", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForContactProfilesListBySubscription(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "contactprofile.ContactProfileClient", "ContactProfilesListBySubscription", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForContactProfilesListBySubscription prepares the ContactProfilesListBySubscription request. -func (c ContactProfileClient) preparerForContactProfilesListBySubscription(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Orbital/contactProfiles", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForContactProfilesListBySubscriptionWithNextLink prepares the ContactProfilesListBySubscription request with the given nextLink token. -func (c ContactProfileClient) preparerForContactProfilesListBySubscriptionWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForContactProfilesListBySubscription handles the response to the ContactProfilesListBySubscription request. The method always -// closes the http.Response Body. -func (c ContactProfileClient) responderForContactProfilesListBySubscription(resp *http.Response) (result ContactProfilesListBySubscriptionOperationResponse, err error) { - type page struct { - Values []ContactProfile `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ContactProfilesListBySubscriptionOperationResponse, err error) { - req, err := c.preparerForContactProfilesListBySubscriptionWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "contactprofile.ContactProfileClient", "ContactProfilesListBySubscription", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "contactprofile.ContactProfileClient", "ContactProfilesListBySubscription", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForContactProfilesListBySubscription(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "contactprofile.ContactProfileClient", "ContactProfilesListBySubscription", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ContactProfilesListBySubscriptionComplete retrieves all of the results into a single object -func (c ContactProfileClient) ContactProfilesListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ContactProfilesListBySubscriptionCompleteResult, error) { - return c.ContactProfilesListBySubscriptionCompleteMatchingPredicate(ctx, id, ContactProfileOperationPredicate{}) -} - -// ContactProfilesListBySubscriptionCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ContactProfileClient) ContactProfilesListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ContactProfileOperationPredicate) (resp ContactProfilesListBySubscriptionCompleteResult, err error) { - items := make([]ContactProfile, 0) - - page, err := c.ContactProfilesListBySubscription(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ContactProfilesListBySubscriptionCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/orbital/2022-11-01/contactprofile/method_contactprofilesupdatetags.go b/resource-manager/orbital/2022-11-01/contactprofile/method_contactprofilesupdatetags.go new file mode 100644 index 00000000000..6adc87bdf58 --- /dev/null +++ b/resource-manager/orbital/2022-11-01/contactprofile/method_contactprofilesupdatetags.go @@ -0,0 +1,74 @@ +package contactprofile + +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 ContactProfilesUpdateTagsOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ContactProfilesUpdateTags ... +func (c ContactProfileClient) ContactProfilesUpdateTags(ctx context.Context, id ContactProfileId, input TagsObject) (result ContactProfilesUpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + 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 +} + +// ContactProfilesUpdateTagsThenPoll performs ContactProfilesUpdateTags then polls until it's completed +func (c ContactProfileClient) ContactProfilesUpdateTagsThenPoll(ctx context.Context, id ContactProfileId, input TagsObject) error { + result, err := c.ContactProfilesUpdateTags(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ContactProfilesUpdateTags: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ContactProfilesUpdateTags: %+v", err) + } + + return nil +} diff --git a/resource-manager/orbital/2022-11-01/contactprofile/method_contactprofilesupdatetags_autorest.go b/resource-manager/orbital/2022-11-01/contactprofile/method_contactprofilesupdatetags_autorest.go deleted file mode 100644 index 8a23aecf55b..00000000000 --- a/resource-manager/orbital/2022-11-01/contactprofile/method_contactprofilesupdatetags_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package contactprofile - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ContactProfilesUpdateTagsOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// ContactProfilesUpdateTags ... -func (c ContactProfileClient) ContactProfilesUpdateTags(ctx context.Context, id ContactProfileId, input TagsObject) (result ContactProfilesUpdateTagsOperationResponse, err error) { - req, err := c.preparerForContactProfilesUpdateTags(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "contactprofile.ContactProfileClient", "ContactProfilesUpdateTags", nil, "Failure preparing request") - return - } - - result, err = c.senderForContactProfilesUpdateTags(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "contactprofile.ContactProfileClient", "ContactProfilesUpdateTags", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// ContactProfilesUpdateTagsThenPoll performs ContactProfilesUpdateTags then polls until it's completed -func (c ContactProfileClient) ContactProfilesUpdateTagsThenPoll(ctx context.Context, id ContactProfileId, input TagsObject) error { - result, err := c.ContactProfilesUpdateTags(ctx, id, input) - if err != nil { - return fmt.Errorf("performing ContactProfilesUpdateTags: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after ContactProfilesUpdateTags: %+v", err) - } - - return nil -} - -// preparerForContactProfilesUpdateTags prepares the ContactProfilesUpdateTags request. -func (c ContactProfileClient) preparerForContactProfilesUpdateTags(ctx context.Context, id ContactProfileId, input TagsObject) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForContactProfilesUpdateTags sends the ContactProfilesUpdateTags request. The method will close the -// http.Response Body if it receives an error. -func (c ContactProfileClient) senderForContactProfilesUpdateTags(ctx context.Context, req *http.Request) (future ContactProfilesUpdateTagsOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/orbital/2022-11-01/groundstation/client.go b/resource-manager/orbital/2022-11-01/groundstation/client.go index aa6f10df6e5..d025dd7c309 100644 --- a/resource-manager/orbital/2022-11-01/groundstation/client.go +++ b/resource-manager/orbital/2022-11-01/groundstation/client.go @@ -1,18 +1,26 @@ package groundstation -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 GroundStationClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewGroundStationClientWithBaseURI(endpoint string) GroundStationClient { - return GroundStationClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewGroundStationClientWithBaseURI(api environments.Api) (*GroundStationClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "groundstation", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating GroundStationClient: %+v", err) } + + return &GroundStationClient{ + Client: client, + }, nil } diff --git a/resource-manager/orbital/2022-11-01/groundstation/constants.go b/resource-manager/orbital/2022-11-01/groundstation/constants.go index 8df58c6d329..58d3d279639 100644 --- a/resource-manager/orbital/2022-11-01/groundstation/constants.go +++ b/resource-manager/orbital/2022-11-01/groundstation/constants.go @@ -1,6 +1,10 @@ package groundstation -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. @@ -19,6 +23,19 @@ func PossibleValuesForCapabilityParameter() []string { } } +func (s *CapabilityParameter) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCapabilityParameter(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseCapabilityParameter(input string) (*CapabilityParameter, error) { vals := map[string]CapabilityParameter{ "communication": CapabilityParameterCommunication, @@ -47,6 +64,19 @@ func PossibleValuesForReleaseMode() []string { } } +func (s *ReleaseMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseReleaseMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseReleaseMode(input string) (*ReleaseMode, error) { vals := map[string]ReleaseMode{ "ga": ReleaseModeGA, diff --git a/resource-manager/orbital/2022-11-01/groundstation/method_availablegroundstationslistbycapability.go b/resource-manager/orbital/2022-11-01/groundstation/method_availablegroundstationslistbycapability.go new file mode 100644 index 00000000000..a14952a87bf --- /dev/null +++ b/resource-manager/orbital/2022-11-01/groundstation/method_availablegroundstationslistbycapability.go @@ -0,0 +1,118 @@ +package groundstation + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 AvailableGroundStationsListByCapabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AvailableGroundStation +} + +type AvailableGroundStationsListByCapabilityCompleteResult struct { + Items []AvailableGroundStation +} + +type AvailableGroundStationsListByCapabilityOperationOptions struct { + Capability *CapabilityParameter +} + +func DefaultAvailableGroundStationsListByCapabilityOperationOptions() AvailableGroundStationsListByCapabilityOperationOptions { + return AvailableGroundStationsListByCapabilityOperationOptions{} +} + +func (o AvailableGroundStationsListByCapabilityOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o AvailableGroundStationsListByCapabilityOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o AvailableGroundStationsListByCapabilityOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Capability != nil { + out.Append("capability", fmt.Sprintf("%v", *o.Capability)) + } + return &out +} + +// AvailableGroundStationsListByCapability ... +func (c GroundStationClient) AvailableGroundStationsListByCapability(ctx context.Context, id commonids.SubscriptionId, options AvailableGroundStationsListByCapabilityOperationOptions) (result AvailableGroundStationsListByCapabilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Orbital/availableGroundStations", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AvailableGroundStation `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// AvailableGroundStationsListByCapabilityComplete retrieves all the results into a single object +func (c GroundStationClient) AvailableGroundStationsListByCapabilityComplete(ctx context.Context, id commonids.SubscriptionId, options AvailableGroundStationsListByCapabilityOperationOptions) (AvailableGroundStationsListByCapabilityCompleteResult, error) { + return c.AvailableGroundStationsListByCapabilityCompleteMatchingPredicate(ctx, id, options, AvailableGroundStationOperationPredicate{}) +} + +// AvailableGroundStationsListByCapabilityCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c GroundStationClient) AvailableGroundStationsListByCapabilityCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options AvailableGroundStationsListByCapabilityOperationOptions, predicate AvailableGroundStationOperationPredicate) (result AvailableGroundStationsListByCapabilityCompleteResult, err error) { + items := make([]AvailableGroundStation, 0) + + resp, err := c.AvailableGroundStationsListByCapability(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = AvailableGroundStationsListByCapabilityCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/orbital/2022-11-01/groundstation/method_availablegroundstationslistbycapability_autorest.go b/resource-manager/orbital/2022-11-01/groundstation/method_availablegroundstationslistbycapability_autorest.go deleted file mode 100644 index 2ef8b5ea5d4..00000000000 --- a/resource-manager/orbital/2022-11-01/groundstation/method_availablegroundstationslistbycapability_autorest.go +++ /dev/null @@ -1,216 +0,0 @@ -package groundstation - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type AvailableGroundStationsListByCapabilityOperationResponse struct { - HttpResponse *http.Response - Model *[]AvailableGroundStation - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (AvailableGroundStationsListByCapabilityOperationResponse, error) -} - -type AvailableGroundStationsListByCapabilityCompleteResult struct { - Items []AvailableGroundStation -} - -func (r AvailableGroundStationsListByCapabilityOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r AvailableGroundStationsListByCapabilityOperationResponse) LoadMore(ctx context.Context) (resp AvailableGroundStationsListByCapabilityOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type AvailableGroundStationsListByCapabilityOperationOptions struct { - Capability *CapabilityParameter -} - -func DefaultAvailableGroundStationsListByCapabilityOperationOptions() AvailableGroundStationsListByCapabilityOperationOptions { - return AvailableGroundStationsListByCapabilityOperationOptions{} -} - -func (o AvailableGroundStationsListByCapabilityOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o AvailableGroundStationsListByCapabilityOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Capability != nil { - out["capability"] = *o.Capability - } - - return out -} - -// AvailableGroundStationsListByCapability ... -func (c GroundStationClient) AvailableGroundStationsListByCapability(ctx context.Context, id commonids.SubscriptionId, options AvailableGroundStationsListByCapabilityOperationOptions) (resp AvailableGroundStationsListByCapabilityOperationResponse, err error) { - req, err := c.preparerForAvailableGroundStationsListByCapability(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "groundstation.GroundStationClient", "AvailableGroundStationsListByCapability", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "groundstation.GroundStationClient", "AvailableGroundStationsListByCapability", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForAvailableGroundStationsListByCapability(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "groundstation.GroundStationClient", "AvailableGroundStationsListByCapability", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForAvailableGroundStationsListByCapability prepares the AvailableGroundStationsListByCapability request. -func (c GroundStationClient) preparerForAvailableGroundStationsListByCapability(ctx context.Context, id commonids.SubscriptionId, options AvailableGroundStationsListByCapabilityOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Orbital/availableGroundStations", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForAvailableGroundStationsListByCapabilityWithNextLink prepares the AvailableGroundStationsListByCapability request with the given nextLink token. -func (c GroundStationClient) preparerForAvailableGroundStationsListByCapabilityWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForAvailableGroundStationsListByCapability handles the response to the AvailableGroundStationsListByCapability request. The method always -// closes the http.Response Body. -func (c GroundStationClient) responderForAvailableGroundStationsListByCapability(resp *http.Response) (result AvailableGroundStationsListByCapabilityOperationResponse, err error) { - type page struct { - Values []AvailableGroundStation `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result AvailableGroundStationsListByCapabilityOperationResponse, err error) { - req, err := c.preparerForAvailableGroundStationsListByCapabilityWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "groundstation.GroundStationClient", "AvailableGroundStationsListByCapability", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "groundstation.GroundStationClient", "AvailableGroundStationsListByCapability", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForAvailableGroundStationsListByCapability(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "groundstation.GroundStationClient", "AvailableGroundStationsListByCapability", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// AvailableGroundStationsListByCapabilityComplete retrieves all of the results into a single object -func (c GroundStationClient) AvailableGroundStationsListByCapabilityComplete(ctx context.Context, id commonids.SubscriptionId, options AvailableGroundStationsListByCapabilityOperationOptions) (AvailableGroundStationsListByCapabilityCompleteResult, error) { - return c.AvailableGroundStationsListByCapabilityCompleteMatchingPredicate(ctx, id, options, AvailableGroundStationOperationPredicate{}) -} - -// AvailableGroundStationsListByCapabilityCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c GroundStationClient) AvailableGroundStationsListByCapabilityCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options AvailableGroundStationsListByCapabilityOperationOptions, predicate AvailableGroundStationOperationPredicate) (resp AvailableGroundStationsListByCapabilityCompleteResult, err error) { - items := make([]AvailableGroundStation, 0) - - page, err := c.AvailableGroundStationsListByCapability(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := AvailableGroundStationsListByCapabilityCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/orbital/2022-11-01/spacecraft/client.go b/resource-manager/orbital/2022-11-01/spacecraft/client.go index b5c2ccabab6..555471a9a8b 100644 --- a/resource-manager/orbital/2022-11-01/spacecraft/client.go +++ b/resource-manager/orbital/2022-11-01/spacecraft/client.go @@ -1,18 +1,26 @@ package spacecraft -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 SpacecraftClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewSpacecraftClientWithBaseURI(endpoint string) SpacecraftClient { - return SpacecraftClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewSpacecraftClientWithBaseURI(api environments.Api) (*SpacecraftClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "spacecraft", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SpacecraftClient: %+v", err) } + + return &SpacecraftClient{ + Client: client, + }, nil } diff --git a/resource-manager/orbital/2022-11-01/spacecraft/constants.go b/resource-manager/orbital/2022-11-01/spacecraft/constants.go index 20e58a4ac9c..4ab7cf6fde3 100644 --- a/resource-manager/orbital/2022-11-01/spacecraft/constants.go +++ b/resource-manager/orbital/2022-11-01/spacecraft/constants.go @@ -1,6 +1,10 @@ package spacecraft -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. @@ -19,6 +23,19 @@ func PossibleValuesForDirection() []string { } } +func (s *Direction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDirection(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseDirection(input string) (*Direction, error) { vals := map[string]Direction{ "downlink": DirectionDownlink, @@ -51,6 +68,19 @@ func PossibleValuesForPolarization() []string { } } +func (s *Polarization) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePolarization(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePolarization(input string) (*Polarization, error) { vals := map[string]Polarization{ "lhcp": PolarizationLHCP, @@ -89,6 +119,19 @@ func PossibleValuesForProvisioningState() []string { } } +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseProvisioningState(input string) (*ProvisioningState, error) { vals := map[string]ProvisioningState{ "canceled": ProvisioningStateCanceled, diff --git a/resource-manager/orbital/2022-11-01/spacecraft/method_createorupdate.go b/resource-manager/orbital/2022-11-01/spacecraft/method_createorupdate.go new file mode 100644 index 00000000000..26e175a699b --- /dev/null +++ b/resource-manager/orbital/2022-11-01/spacecraft/method_createorupdate.go @@ -0,0 +1,74 @@ +package spacecraft + +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 +} + +// CreateOrUpdate ... +func (c SpacecraftClient) CreateOrUpdate(ctx context.Context, id SpacecraftId, input Spacecraft) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 SpacecraftClient) CreateOrUpdateThenPoll(ctx context.Context, id SpacecraftId, input Spacecraft) 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 +} diff --git a/resource-manager/orbital/2022-11-01/spacecraft/method_createorupdate_autorest.go b/resource-manager/orbital/2022-11-01/spacecraft/method_createorupdate_autorest.go deleted file mode 100644 index 7b56cad06ba..00000000000 --- a/resource-manager/orbital/2022-11-01/spacecraft/method_createorupdate_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package spacecraft - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateOrUpdate ... -func (c SpacecraftClient) CreateOrUpdate(ctx context.Context, id SpacecraftId, input Spacecraft) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "spacecraft.SpacecraftClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "spacecraft.SpacecraftClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c SpacecraftClient) CreateOrUpdateThenPoll(ctx context.Context, id SpacecraftId, input Spacecraft) error { - result, err := c.CreateOrUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateOrUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateOrUpdate: %+v", err) - } - - return nil -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c SpacecraftClient) preparerForCreateOrUpdate(ctx context.Context, id SpacecraftId, input Spacecraft) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateOrUpdate sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c SpacecraftClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/orbital/2022-11-01/spacecraft/method_delete.go b/resource-manager/orbital/2022-11-01/spacecraft/method_delete.go new file mode 100644 index 00000000000..78686059247 --- /dev/null +++ b/resource-manager/orbital/2022-11-01/spacecraft/method_delete.go @@ -0,0 +1,71 @@ +package spacecraft + +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 SpacecraftClient) Delete(ctx context.Context, id SpacecraftId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 SpacecraftClient) DeleteThenPoll(ctx context.Context, id SpacecraftId) 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 +} diff --git a/resource-manager/orbital/2022-11-01/spacecraft/method_delete_autorest.go b/resource-manager/orbital/2022-11-01/spacecraft/method_delete_autorest.go deleted file mode 100644 index c2ee787941e..00000000000 --- a/resource-manager/orbital/2022-11-01/spacecraft/method_delete_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package spacecraft - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// Delete ... -func (c SpacecraftClient) Delete(ctx context.Context, id SpacecraftId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "spacecraft.SpacecraftClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "spacecraft.SpacecraftClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c SpacecraftClient) DeleteThenPoll(ctx context.Context, id SpacecraftId) error { - result, err := c.Delete(ctx, id) - if err != nil { - return fmt.Errorf("performing Delete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Delete: %+v", err) - } - - return nil -} - -// preparerForDelete prepares the Delete request. -func (c SpacecraftClient) preparerForDelete(ctx context.Context, id SpacecraftId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDelete sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (c SpacecraftClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/orbital/2022-11-01/spacecraft/method_get.go b/resource-manager/orbital/2022-11-01/spacecraft/method_get.go new file mode 100644 index 00000000000..ea36958852a --- /dev/null +++ b/resource-manager/orbital/2022-11-01/spacecraft/method_get.go @@ -0,0 +1,51 @@ +package spacecraft + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Spacecraft +} + +// Get ... +func (c SpacecraftClient) Get(ctx context.Context, id SpacecraftId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/orbital/2022-11-01/spacecraft/method_get_autorest.go b/resource-manager/orbital/2022-11-01/spacecraft/method_get_autorest.go deleted file mode 100644 index 7327081e66a..00000000000 --- a/resource-manager/orbital/2022-11-01/spacecraft/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package spacecraft - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *Spacecraft -} - -// Get ... -func (c SpacecraftClient) Get(ctx context.Context, id SpacecraftId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "spacecraft.SpacecraftClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "spacecraft.SpacecraftClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "spacecraft.SpacecraftClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c SpacecraftClient) preparerForGet(ctx context.Context, id SpacecraftId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c SpacecraftClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/orbital/2022-11-01/spacecraft/method_list.go b/resource-manager/orbital/2022-11-01/spacecraft/method_list.go new file mode 100644 index 00000000000..bf3c32696e7 --- /dev/null +++ b/resource-manager/orbital/2022-11-01/spacecraft/method_list.go @@ -0,0 +1,90 @@ +package spacecraft + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Spacecraft +} + +type ListCompleteResult struct { + Items []Spacecraft +} + +// List ... +func (c SpacecraftClient) List(ctx context.Context, id commonids.ResourceGroupId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Orbital/spacecrafts", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Spacecraft `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c SpacecraftClient) ListComplete(ctx context.Context, id commonids.ResourceGroupId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, SpacecraftOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SpacecraftClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate SpacecraftOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Spacecraft, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/orbital/2022-11-01/spacecraft/method_list_autorest.go b/resource-manager/orbital/2022-11-01/spacecraft/method_list_autorest.go deleted file mode 100644 index dbd038c9975..00000000000 --- a/resource-manager/orbital/2022-11-01/spacecraft/method_list_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package spacecraft - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListOperationResponse struct { - HttpResponse *http.Response - Model *[]Spacecraft - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []Spacecraft -} - -func (r ListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// List ... -func (c SpacecraftClient) List(ctx context.Context, id commonids.ResourceGroupId) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "spacecraft.SpacecraftClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "spacecraft.SpacecraftClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "spacecraft.SpacecraftClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c SpacecraftClient) preparerForList(ctx context.Context, id commonids.ResourceGroupId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Orbital/spacecrafts", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c SpacecraftClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForList handles the response to the List request. The method always -// closes the http.Response Body. -func (c SpacecraftClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []Spacecraft `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { - req, err := c.preparerForListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "spacecraft.SpacecraftClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "spacecraft.SpacecraftClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "spacecraft.SpacecraftClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c SpacecraftClient) ListComplete(ctx context.Context, id commonids.ResourceGroupId) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, SpacecraftOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c SpacecraftClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate SpacecraftOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]Spacecraft, 0) - - page, err := c.List(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/orbital/2022-11-01/spacecraft/method_listbysubscription.go b/resource-manager/orbital/2022-11-01/spacecraft/method_listbysubscription.go new file mode 100644 index 00000000000..23b21f7b2f4 --- /dev/null +++ b/resource-manager/orbital/2022-11-01/spacecraft/method_listbysubscription.go @@ -0,0 +1,90 @@ +package spacecraft + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Spacecraft +} + +type ListBySubscriptionCompleteResult struct { + Items []Spacecraft +} + +// ListBySubscription ... +func (c SpacecraftClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Orbital/spacecrafts", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Spacecraft `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c SpacecraftClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, SpacecraftOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SpacecraftClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate SpacecraftOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]Spacecraft, 0) + + resp, err := c.ListBySubscription(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListBySubscriptionCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/orbital/2022-11-01/spacecraft/method_listbysubscription_autorest.go b/resource-manager/orbital/2022-11-01/spacecraft/method_listbysubscription_autorest.go deleted file mode 100644 index fd75f9d77a1..00000000000 --- a/resource-manager/orbital/2022-11-01/spacecraft/method_listbysubscription_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package spacecraft - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListBySubscriptionOperationResponse struct { - HttpResponse *http.Response - Model *[]Spacecraft - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListBySubscriptionOperationResponse, error) -} - -type ListBySubscriptionCompleteResult struct { - Items []Spacecraft -} - -func (r ListBySubscriptionOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListBySubscriptionOperationResponse) LoadMore(ctx context.Context) (resp ListBySubscriptionOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListBySubscription ... -func (c SpacecraftClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (resp ListBySubscriptionOperationResponse, err error) { - req, err := c.preparerForListBySubscription(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "spacecraft.SpacecraftClient", "ListBySubscription", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "spacecraft.SpacecraftClient", "ListBySubscription", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListBySubscription(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "spacecraft.SpacecraftClient", "ListBySubscription", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListBySubscription prepares the ListBySubscription request. -func (c SpacecraftClient) preparerForListBySubscription(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Orbital/spacecrafts", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListBySubscriptionWithNextLink prepares the ListBySubscription request with the given nextLink token. -func (c SpacecraftClient) preparerForListBySubscriptionWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListBySubscription handles the response to the ListBySubscription request. The method always -// closes the http.Response Body. -func (c SpacecraftClient) responderForListBySubscription(resp *http.Response) (result ListBySubscriptionOperationResponse, err error) { - type page struct { - Values []Spacecraft `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListBySubscriptionOperationResponse, err error) { - req, err := c.preparerForListBySubscriptionWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "spacecraft.SpacecraftClient", "ListBySubscription", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "spacecraft.SpacecraftClient", "ListBySubscription", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListBySubscription(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "spacecraft.SpacecraftClient", "ListBySubscription", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListBySubscriptionComplete retrieves all of the results into a single object -func (c SpacecraftClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { - return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, SpacecraftOperationPredicate{}) -} - -// ListBySubscriptionCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c SpacecraftClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate SpacecraftOperationPredicate) (resp ListBySubscriptionCompleteResult, err error) { - items := make([]Spacecraft, 0) - - page, err := c.ListBySubscription(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListBySubscriptionCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/orbital/2022-11-01/spacecraft/method_updatetags.go b/resource-manager/orbital/2022-11-01/spacecraft/method_updatetags.go new file mode 100644 index 00000000000..74fe2ffbba2 --- /dev/null +++ b/resource-manager/orbital/2022-11-01/spacecraft/method_updatetags.go @@ -0,0 +1,74 @@ +package spacecraft + +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 UpdateTagsOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// UpdateTags ... +func (c SpacecraftClient) UpdateTags(ctx context.Context, id SpacecraftId, input TagsObject) (result UpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + 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 +} + +// UpdateTagsThenPoll performs UpdateTags then polls until it's completed +func (c SpacecraftClient) UpdateTagsThenPoll(ctx context.Context, id SpacecraftId, input TagsObject) error { + result, err := c.UpdateTags(ctx, id, input) + if err != nil { + return fmt.Errorf("performing UpdateTags: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after UpdateTags: %+v", err) + } + + return nil +} diff --git a/resource-manager/orbital/2022-11-01/spacecraft/method_updatetags_autorest.go b/resource-manager/orbital/2022-11-01/spacecraft/method_updatetags_autorest.go deleted file mode 100644 index bc69cc2c5c0..00000000000 --- a/resource-manager/orbital/2022-11-01/spacecraft/method_updatetags_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package spacecraft - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateTagsOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// UpdateTags ... -func (c SpacecraftClient) UpdateTags(ctx context.Context, id SpacecraftId, input TagsObject) (result UpdateTagsOperationResponse, err error) { - req, err := c.preparerForUpdateTags(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "spacecraft.SpacecraftClient", "UpdateTags", nil, "Failure preparing request") - return - } - - result, err = c.senderForUpdateTags(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "spacecraft.SpacecraftClient", "UpdateTags", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// UpdateTagsThenPoll performs UpdateTags then polls until it's completed -func (c SpacecraftClient) UpdateTagsThenPoll(ctx context.Context, id SpacecraftId, input TagsObject) error { - result, err := c.UpdateTags(ctx, id, input) - if err != nil { - return fmt.Errorf("performing UpdateTags: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after UpdateTags: %+v", err) - } - - return nil -} - -// preparerForUpdateTags prepares the UpdateTags request. -func (c SpacecraftClient) preparerForUpdateTags(ctx context.Context, id SpacecraftId, input TagsObject) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForUpdateTags sends the UpdateTags request. The method will close the -// http.Response Body if it receives an error. -func (c SpacecraftClient) senderForUpdateTags(ctx context.Context, req *http.Request) (future UpdateTagsOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/powerbidedicated/2021-01-01/autoscalevcores/client.go b/resource-manager/powerbidedicated/2021-01-01/autoscalevcores/client.go index 1a2f60adb0a..295f4a2ad2e 100644 --- a/resource-manager/powerbidedicated/2021-01-01/autoscalevcores/client.go +++ b/resource-manager/powerbidedicated/2021-01-01/autoscalevcores/client.go @@ -1,18 +1,26 @@ package autoscalevcores -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 AutoScaleVCoresClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewAutoScaleVCoresClientWithBaseURI(endpoint string) AutoScaleVCoresClient { - return AutoScaleVCoresClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewAutoScaleVCoresClientWithBaseURI(api environments.Api) (*AutoScaleVCoresClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "autoscalevcores", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AutoScaleVCoresClient: %+v", err) } + + return &AutoScaleVCoresClient{ + Client: client, + }, nil } diff --git a/resource-manager/powerbidedicated/2021-01-01/autoscalevcores/constants.go b/resource-manager/powerbidedicated/2021-01-01/autoscalevcores/constants.go index 97669564818..8324dad2af2 100644 --- a/resource-manager/powerbidedicated/2021-01-01/autoscalevcores/constants.go +++ b/resource-manager/powerbidedicated/2021-01-01/autoscalevcores/constants.go @@ -1,6 +1,10 @@ package autoscalevcores -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. @@ -17,6 +21,19 @@ func PossibleValuesForVCoreProvisioningState() []string { } } +func (s *VCoreProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVCoreProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseVCoreProvisioningState(input string) (*VCoreProvisioningState, error) { vals := map[string]VCoreProvisioningState{ "succeeded": VCoreProvisioningStateSucceeded, @@ -42,6 +59,19 @@ func PossibleValuesForVCoreSkuTier() []string { } } +func (s *VCoreSkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVCoreSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseVCoreSkuTier(input string) (*VCoreSkuTier, error) { vals := map[string]VCoreSkuTier{ "autoscale": VCoreSkuTierAutoScale, diff --git a/resource-manager/powerbidedicated/2021-01-01/autoscalevcores/method_create.go b/resource-manager/powerbidedicated/2021-01-01/autoscalevcores/method_create.go new file mode 100644 index 00000000000..32bc2e2be41 --- /dev/null +++ b/resource-manager/powerbidedicated/2021-01-01/autoscalevcores/method_create.go @@ -0,0 +1,55 @@ +package autoscalevcores + +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 CreateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AutoScaleVCore +} + +// Create ... +func (c AutoScaleVCoresClient) Create(ctx context.Context, id AutoScaleVCoreId, input AutoScaleVCore) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 +} diff --git a/resource-manager/powerbidedicated/2021-01-01/autoscalevcores/method_create_autorest.go b/resource-manager/powerbidedicated/2021-01-01/autoscalevcores/method_create_autorest.go deleted file mode 100644 index 5f6087562dd..00000000000 --- a/resource-manager/powerbidedicated/2021-01-01/autoscalevcores/method_create_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package autoscalevcores - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOperationResponse struct { - HttpResponse *http.Response - Model *AutoScaleVCore -} - -// Create ... -func (c AutoScaleVCoresClient) Create(ctx context.Context, id AutoScaleVCoreId, input AutoScaleVCore) (result CreateOperationResponse, err error) { - req, err := c.preparerForCreate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "autoscalevcores.AutoScaleVCoresClient", "Create", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "autoscalevcores.AutoScaleVCoresClient", "Create", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "autoscalevcores.AutoScaleVCoresClient", "Create", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreate prepares the Create request. -func (c AutoScaleVCoresClient) preparerForCreate(ctx context.Context, id AutoScaleVCoreId, input AutoScaleVCore) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreate handles the response to the Create request. The method always -// closes the http.Response Body. -func (c AutoScaleVCoresClient) responderForCreate(resp *http.Response) (result CreateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/powerbidedicated/2021-01-01/autoscalevcores/method_delete.go b/resource-manager/powerbidedicated/2021-01-01/autoscalevcores/method_delete.go new file mode 100644 index 00000000000..aa453f91ae1 --- /dev/null +++ b/resource-manager/powerbidedicated/2021-01-01/autoscalevcores/method_delete.go @@ -0,0 +1,47 @@ +package autoscalevcores + +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 +} + +// Delete ... +func (c AutoScaleVCoresClient) Delete(ctx context.Context, id AutoScaleVCoreId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 + } + + return +} diff --git a/resource-manager/powerbidedicated/2021-01-01/autoscalevcores/method_delete_autorest.go b/resource-manager/powerbidedicated/2021-01-01/autoscalevcores/method_delete_autorest.go deleted file mode 100644 index 111cd25fb86..00000000000 --- a/resource-manager/powerbidedicated/2021-01-01/autoscalevcores/method_delete_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package autoscalevcores - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// 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 -} - -// Delete ... -func (c AutoScaleVCoresClient) Delete(ctx context.Context, id AutoScaleVCoreId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "autoscalevcores.AutoScaleVCoresClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "autoscalevcores.AutoScaleVCoresClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "autoscalevcores.AutoScaleVCoresClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c AutoScaleVCoresClient) preparerForDelete(ctx context.Context, id AutoScaleVCoreId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c AutoScaleVCoresClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/powerbidedicated/2021-01-01/autoscalevcores/method_get.go b/resource-manager/powerbidedicated/2021-01-01/autoscalevcores/method_get.go new file mode 100644 index 00000000000..f6cfbba3540 --- /dev/null +++ b/resource-manager/powerbidedicated/2021-01-01/autoscalevcores/method_get.go @@ -0,0 +1,51 @@ +package autoscalevcores + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AutoScaleVCore +} + +// Get ... +func (c AutoScaleVCoresClient) Get(ctx context.Context, id AutoScaleVCoreId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/powerbidedicated/2021-01-01/autoscalevcores/method_get_autorest.go b/resource-manager/powerbidedicated/2021-01-01/autoscalevcores/method_get_autorest.go deleted file mode 100644 index 7bb6af55635..00000000000 --- a/resource-manager/powerbidedicated/2021-01-01/autoscalevcores/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package autoscalevcores - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *AutoScaleVCore -} - -// Get ... -func (c AutoScaleVCoresClient) Get(ctx context.Context, id AutoScaleVCoreId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "autoscalevcores.AutoScaleVCoresClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "autoscalevcores.AutoScaleVCoresClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "autoscalevcores.AutoScaleVCoresClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c AutoScaleVCoresClient) preparerForGet(ctx context.Context, id AutoScaleVCoreId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c AutoScaleVCoresClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/powerbidedicated/2021-01-01/autoscalevcores/method_listbyresourcegroup.go b/resource-manager/powerbidedicated/2021-01-01/autoscalevcores/method_listbyresourcegroup.go new file mode 100644 index 00000000000..d8d77b294d0 --- /dev/null +++ b/resource-manager/powerbidedicated/2021-01-01/autoscalevcores/method_listbyresourcegroup.go @@ -0,0 +1,53 @@ +package autoscalevcores + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AutoScaleVCoreListResult +} + +// ListByResourceGroup ... +func (c AutoScaleVCoresClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.PowerBIDedicated/autoScaleVCores", 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 +} diff --git a/resource-manager/powerbidedicated/2021-01-01/autoscalevcores/method_listbyresourcegroup_autorest.go b/resource-manager/powerbidedicated/2021-01-01/autoscalevcores/method_listbyresourcegroup_autorest.go deleted file mode 100644 index 16723aeb4cc..00000000000 --- a/resource-manager/powerbidedicated/2021-01-01/autoscalevcores/method_listbyresourcegroup_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package autoscalevcores - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByResourceGroupOperationResponse struct { - HttpResponse *http.Response - Model *AutoScaleVCoreListResult -} - -// ListByResourceGroup ... -func (c AutoScaleVCoresClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroup(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "autoscalevcores.AutoScaleVCoresClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "autoscalevcores.AutoScaleVCoresClient", "ListByResourceGroup", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByResourceGroup(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "autoscalevcores.AutoScaleVCoresClient", "ListByResourceGroup", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListByResourceGroup prepares the ListByResourceGroup request. -func (c AutoScaleVCoresClient) preparerForListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.PowerBIDedicated/autoScaleVCores", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByResourceGroup handles the response to the ListByResourceGroup request. The method always -// closes the http.Response Body. -func (c AutoScaleVCoresClient) responderForListByResourceGroup(resp *http.Response) (result ListByResourceGroupOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/powerbidedicated/2021-01-01/autoscalevcores/method_listbysubscription.go b/resource-manager/powerbidedicated/2021-01-01/autoscalevcores/method_listbysubscription.go new file mode 100644 index 00000000000..6f2ffb05a01 --- /dev/null +++ b/resource-manager/powerbidedicated/2021-01-01/autoscalevcores/method_listbysubscription.go @@ -0,0 +1,53 @@ +package autoscalevcores + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AutoScaleVCoreListResult +} + +// ListBySubscription ... +func (c AutoScaleVCoresClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.PowerBIDedicated/autoScaleVCores", 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 +} diff --git a/resource-manager/powerbidedicated/2021-01-01/autoscalevcores/method_listbysubscription_autorest.go b/resource-manager/powerbidedicated/2021-01-01/autoscalevcores/method_listbysubscription_autorest.go deleted file mode 100644 index 03acb6121f1..00000000000 --- a/resource-manager/powerbidedicated/2021-01-01/autoscalevcores/method_listbysubscription_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package autoscalevcores - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListBySubscriptionOperationResponse struct { - HttpResponse *http.Response - Model *AutoScaleVCoreListResult -} - -// ListBySubscription ... -func (c AutoScaleVCoresClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { - req, err := c.preparerForListBySubscription(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "autoscalevcores.AutoScaleVCoresClient", "ListBySubscription", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "autoscalevcores.AutoScaleVCoresClient", "ListBySubscription", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListBySubscription(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "autoscalevcores.AutoScaleVCoresClient", "ListBySubscription", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListBySubscription prepares the ListBySubscription request. -func (c AutoScaleVCoresClient) preparerForListBySubscription(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.PowerBIDedicated/autoScaleVCores", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListBySubscription handles the response to the ListBySubscription request. The method always -// closes the http.Response Body. -func (c AutoScaleVCoresClient) responderForListBySubscription(resp *http.Response) (result ListBySubscriptionOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/powerbidedicated/2021-01-01/autoscalevcores/method_update.go b/resource-manager/powerbidedicated/2021-01-01/autoscalevcores/method_update.go new file mode 100644 index 00000000000..17be718b58b --- /dev/null +++ b/resource-manager/powerbidedicated/2021-01-01/autoscalevcores/method_update.go @@ -0,0 +1,55 @@ +package autoscalevcores + +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 UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AutoScaleVCore +} + +// Update ... +func (c AutoScaleVCoresClient) Update(ctx context.Context, id AutoScaleVCoreId, input AutoScaleVCoreUpdateParameters) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + 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 +} diff --git a/resource-manager/powerbidedicated/2021-01-01/autoscalevcores/method_update_autorest.go b/resource-manager/powerbidedicated/2021-01-01/autoscalevcores/method_update_autorest.go deleted file mode 100644 index 7d93a8fcd63..00000000000 --- a/resource-manager/powerbidedicated/2021-01-01/autoscalevcores/method_update_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package autoscalevcores - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateOperationResponse struct { - HttpResponse *http.Response - Model *AutoScaleVCore -} - -// Update ... -func (c AutoScaleVCoresClient) Update(ctx context.Context, id AutoScaleVCoreId, input AutoScaleVCoreUpdateParameters) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "autoscalevcores.AutoScaleVCoresClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "autoscalevcores.AutoScaleVCoresClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "autoscalevcores.AutoScaleVCoresClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c AutoScaleVCoresClient) preparerForUpdate(ctx context.Context, id AutoScaleVCoreId, input AutoScaleVCoreUpdateParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdate handles the response to the Update request. The method always -// closes the http.Response Body. -func (c AutoScaleVCoresClient) responderForUpdate(resp *http.Response) (result UpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/powerbidedicated/2021-01-01/capacities/client.go b/resource-manager/powerbidedicated/2021-01-01/capacities/client.go index 2a8b5cafc6b..c78d8757822 100644 --- a/resource-manager/powerbidedicated/2021-01-01/capacities/client.go +++ b/resource-manager/powerbidedicated/2021-01-01/capacities/client.go @@ -1,18 +1,26 @@ package capacities -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 CapacitiesClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewCapacitiesClientWithBaseURI(endpoint string) CapacitiesClient { - return CapacitiesClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewCapacitiesClientWithBaseURI(api environments.Api) (*CapacitiesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "capacities", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CapacitiesClient: %+v", err) } + + return &CapacitiesClient{ + Client: client, + }, nil } diff --git a/resource-manager/powerbidedicated/2021-01-01/capacities/constants.go b/resource-manager/powerbidedicated/2021-01-01/capacities/constants.go index e613550aae4..5cf6a63792c 100644 --- a/resource-manager/powerbidedicated/2021-01-01/capacities/constants.go +++ b/resource-manager/powerbidedicated/2021-01-01/capacities/constants.go @@ -1,6 +1,10 @@ package capacities -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. @@ -39,6 +43,19 @@ func PossibleValuesForCapacityProvisioningState() []string { } } +func (s *CapacityProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCapacityProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseCapacityProvisioningState(input string) (*CapacityProvisioningState, error) { vals := map[string]CapacityProvisioningState{ "deleting": CapacityProvisioningStateDeleting, @@ -79,6 +96,19 @@ func PossibleValuesForCapacitySkuTier() []string { } } +func (s *CapacitySkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCapacitySkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseCapacitySkuTier(input string) (*CapacitySkuTier, error) { vals := map[string]CapacitySkuTier{ "autopremiumhost": CapacitySkuTierAutoPremiumHost, @@ -108,6 +138,19 @@ func PossibleValuesForMode() []string { } } +func (s *Mode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseMode(input string) (*Mode, error) { vals := map[string]Mode{ "gen1": ModeGenOne, @@ -156,6 +199,19 @@ func PossibleValuesForState() []string { } } +func (s *State) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseState(input string) (*State, error) { vals := map[string]State{ "deleting": StateDeleting, diff --git a/resource-manager/powerbidedicated/2021-01-01/capacities/method_checknameavailability.go b/resource-manager/powerbidedicated/2021-01-01/capacities/method_checknameavailability.go new file mode 100644 index 00000000000..681e204b96f --- /dev/null +++ b/resource-manager/powerbidedicated/2021-01-01/capacities/method_checknameavailability.go @@ -0,0 +1,56 @@ +package capacities + +import ( + "context" + "fmt" + "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 CheckNameAvailabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CheckCapacityNameAvailabilityResult +} + +// CheckNameAvailability ... +func (c CapacitiesClient) CheckNameAvailability(ctx context.Context, id LocationId, input CheckCapacityNameAvailabilityParameters) (result CheckNameAvailabilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/checkNameAvailability", 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 +} diff --git a/resource-manager/powerbidedicated/2021-01-01/capacities/method_checknameavailability_autorest.go b/resource-manager/powerbidedicated/2021-01-01/capacities/method_checknameavailability_autorest.go deleted file mode 100644 index 3b4bae555c0..00000000000 --- a/resource-manager/powerbidedicated/2021-01-01/capacities/method_checknameavailability_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package capacities - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CheckNameAvailabilityOperationResponse struct { - HttpResponse *http.Response - Model *CheckCapacityNameAvailabilityResult -} - -// CheckNameAvailability ... -func (c CapacitiesClient) CheckNameAvailability(ctx context.Context, id LocationId, input CheckCapacityNameAvailabilityParameters) (result CheckNameAvailabilityOperationResponse, err error) { - req, err := c.preparerForCheckNameAvailability(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "capacities.CapacitiesClient", "CheckNameAvailability", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "capacities.CapacitiesClient", "CheckNameAvailability", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCheckNameAvailability(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "capacities.CapacitiesClient", "CheckNameAvailability", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCheckNameAvailability prepares the CheckNameAvailability request. -func (c CapacitiesClient) preparerForCheckNameAvailability(ctx context.Context, id LocationId, input CheckCapacityNameAvailabilityParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/checkNameAvailability", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCheckNameAvailability handles the response to the CheckNameAvailability request. The method always -// closes the http.Response Body. -func (c CapacitiesClient) responderForCheckNameAvailability(resp *http.Response) (result CheckNameAvailabilityOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/powerbidedicated/2021-01-01/capacities/method_create.go b/resource-manager/powerbidedicated/2021-01-01/capacities/method_create.go new file mode 100644 index 00000000000..551fdffe720 --- /dev/null +++ b/resource-manager/powerbidedicated/2021-01-01/capacities/method_create.go @@ -0,0 +1,74 @@ +package capacities + +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 CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Create ... +func (c CapacitiesClient) Create(ctx context.Context, id CapacityId, input DedicatedCapacity) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 +} + +// CreateThenPoll performs Create then polls until it's completed +func (c CapacitiesClient) CreateThenPoll(ctx context.Context, id CapacityId, input DedicatedCapacity) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/powerbidedicated/2021-01-01/capacities/method_create_autorest.go b/resource-manager/powerbidedicated/2021-01-01/capacities/method_create_autorest.go deleted file mode 100644 index 609690fa2f9..00000000000 --- a/resource-manager/powerbidedicated/2021-01-01/capacities/method_create_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package capacities - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Create ... -func (c CapacitiesClient) Create(ctx context.Context, id CapacityId, input DedicatedCapacity) (result CreateOperationResponse, err error) { - req, err := c.preparerForCreate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "capacities.CapacitiesClient", "Create", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "capacities.CapacitiesClient", "Create", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateThenPoll performs Create then polls until it's completed -func (c CapacitiesClient) CreateThenPoll(ctx context.Context, id CapacityId, input DedicatedCapacity) error { - result, err := c.Create(ctx, id, input) - if err != nil { - return fmt.Errorf("performing Create: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Create: %+v", err) - } - - return nil -} - -// preparerForCreate prepares the Create request. -func (c CapacitiesClient) preparerForCreate(ctx context.Context, id CapacityId, input DedicatedCapacity) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreate sends the Create request. The method will close the -// http.Response Body if it receives an error. -func (c CapacitiesClient) senderForCreate(ctx context.Context, req *http.Request) (future CreateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/powerbidedicated/2021-01-01/capacities/method_delete.go b/resource-manager/powerbidedicated/2021-01-01/capacities/method_delete.go new file mode 100644 index 00000000000..bc8d28e6e9a --- /dev/null +++ b/resource-manager/powerbidedicated/2021-01-01/capacities/method_delete.go @@ -0,0 +1,71 @@ +package capacities + +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 CapacitiesClient) Delete(ctx context.Context, id CapacityId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 CapacitiesClient) DeleteThenPoll(ctx context.Context, id CapacityId) 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 +} diff --git a/resource-manager/powerbidedicated/2021-01-01/capacities/method_delete_autorest.go b/resource-manager/powerbidedicated/2021-01-01/capacities/method_delete_autorest.go deleted file mode 100644 index 65a87e90c5d..00000000000 --- a/resource-manager/powerbidedicated/2021-01-01/capacities/method_delete_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package capacities - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// Delete ... -func (c CapacitiesClient) Delete(ctx context.Context, id CapacityId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "capacities.CapacitiesClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "capacities.CapacitiesClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c CapacitiesClient) DeleteThenPoll(ctx context.Context, id CapacityId) error { - result, err := c.Delete(ctx, id) - if err != nil { - return fmt.Errorf("performing Delete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Delete: %+v", err) - } - - return nil -} - -// preparerForDelete prepares the Delete request. -func (c CapacitiesClient) preparerForDelete(ctx context.Context, id CapacityId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDelete sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (c CapacitiesClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/powerbidedicated/2021-01-01/capacities/method_getdetails.go b/resource-manager/powerbidedicated/2021-01-01/capacities/method_getdetails.go new file mode 100644 index 00000000000..993b15b5a65 --- /dev/null +++ b/resource-manager/powerbidedicated/2021-01-01/capacities/method_getdetails.go @@ -0,0 +1,51 @@ +package capacities + +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 GetDetailsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DedicatedCapacity +} + +// GetDetails ... +func (c CapacitiesClient) GetDetails(ctx context.Context, id CapacityId) (result GetDetailsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/powerbidedicated/2021-01-01/capacities/method_getdetails_autorest.go b/resource-manager/powerbidedicated/2021-01-01/capacities/method_getdetails_autorest.go deleted file mode 100644 index 919dccd56c1..00000000000 --- a/resource-manager/powerbidedicated/2021-01-01/capacities/method_getdetails_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package capacities - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetDetailsOperationResponse struct { - HttpResponse *http.Response - Model *DedicatedCapacity -} - -// GetDetails ... -func (c CapacitiesClient) GetDetails(ctx context.Context, id CapacityId) (result GetDetailsOperationResponse, err error) { - req, err := c.preparerForGetDetails(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "capacities.CapacitiesClient", "GetDetails", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "capacities.CapacitiesClient", "GetDetails", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetDetails(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "capacities.CapacitiesClient", "GetDetails", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetDetails prepares the GetDetails request. -func (c CapacitiesClient) preparerForGetDetails(ctx context.Context, id CapacityId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetDetails handles the response to the GetDetails request. The method always -// closes the http.Response Body. -func (c CapacitiesClient) responderForGetDetails(resp *http.Response) (result GetDetailsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/powerbidedicated/2021-01-01/capacities/method_list.go b/resource-manager/powerbidedicated/2021-01-01/capacities/method_list.go new file mode 100644 index 00000000000..dd990b8d590 --- /dev/null +++ b/resource-manager/powerbidedicated/2021-01-01/capacities/method_list.go @@ -0,0 +1,53 @@ +package capacities + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DedicatedCapacities +} + +// List ... +func (c CapacitiesClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.PowerBIDedicated/capacities", 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 +} diff --git a/resource-manager/powerbidedicated/2021-01-01/capacities/method_list_autorest.go b/resource-manager/powerbidedicated/2021-01-01/capacities/method_list_autorest.go deleted file mode 100644 index e65db7b1873..00000000000 --- a/resource-manager/powerbidedicated/2021-01-01/capacities/method_list_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package capacities - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListOperationResponse struct { - HttpResponse *http.Response - Model *DedicatedCapacities -} - -// List ... -func (c CapacitiesClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "capacities.CapacitiesClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "capacities.CapacitiesClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "capacities.CapacitiesClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForList prepares the List request. -func (c CapacitiesClient) preparerForList(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.PowerBIDedicated/capacities", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForList handles the response to the List request. The method always -// closes the http.Response Body. -func (c CapacitiesClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/powerbidedicated/2021-01-01/capacities/method_listbyresourcegroup.go b/resource-manager/powerbidedicated/2021-01-01/capacities/method_listbyresourcegroup.go new file mode 100644 index 00000000000..e199cd47344 --- /dev/null +++ b/resource-manager/powerbidedicated/2021-01-01/capacities/method_listbyresourcegroup.go @@ -0,0 +1,53 @@ +package capacities + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DedicatedCapacities +} + +// ListByResourceGroup ... +func (c CapacitiesClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.PowerBIDedicated/capacities", 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 +} diff --git a/resource-manager/powerbidedicated/2021-01-01/capacities/method_listbyresourcegroup_autorest.go b/resource-manager/powerbidedicated/2021-01-01/capacities/method_listbyresourcegroup_autorest.go deleted file mode 100644 index e1b2345465c..00000000000 --- a/resource-manager/powerbidedicated/2021-01-01/capacities/method_listbyresourcegroup_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package capacities - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByResourceGroupOperationResponse struct { - HttpResponse *http.Response - Model *DedicatedCapacities -} - -// ListByResourceGroup ... -func (c CapacitiesClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroup(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "capacities.CapacitiesClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "capacities.CapacitiesClient", "ListByResourceGroup", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByResourceGroup(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "capacities.CapacitiesClient", "ListByResourceGroup", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListByResourceGroup prepares the ListByResourceGroup request. -func (c CapacitiesClient) preparerForListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.PowerBIDedicated/capacities", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByResourceGroup handles the response to the ListByResourceGroup request. The method always -// closes the http.Response Body. -func (c CapacitiesClient) responderForListByResourceGroup(resp *http.Response) (result ListByResourceGroupOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/powerbidedicated/2021-01-01/capacities/method_listskusforcapacity.go b/resource-manager/powerbidedicated/2021-01-01/capacities/method_listskusforcapacity.go new file mode 100644 index 00000000000..680b2280da7 --- /dev/null +++ b/resource-manager/powerbidedicated/2021-01-01/capacities/method_listskusforcapacity.go @@ -0,0 +1,52 @@ +package capacities + +import ( + "context" + "fmt" + "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 ListSkusForCapacityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SkuEnumerationForExistingResourceResult +} + +// ListSkusForCapacity ... +func (c CapacitiesClient) ListSkusForCapacity(ctx context.Context, id CapacityId) (result ListSkusForCapacityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/skus", 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 +} diff --git a/resource-manager/powerbidedicated/2021-01-01/capacities/method_listskusforcapacity_autorest.go b/resource-manager/powerbidedicated/2021-01-01/capacities/method_listskusforcapacity_autorest.go deleted file mode 100644 index 308f3577c50..00000000000 --- a/resource-manager/powerbidedicated/2021-01-01/capacities/method_listskusforcapacity_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package capacities - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListSkusForCapacityOperationResponse struct { - HttpResponse *http.Response - Model *SkuEnumerationForExistingResourceResult -} - -// ListSkusForCapacity ... -func (c CapacitiesClient) ListSkusForCapacity(ctx context.Context, id CapacityId) (result ListSkusForCapacityOperationResponse, err error) { - req, err := c.preparerForListSkusForCapacity(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "capacities.CapacitiesClient", "ListSkusForCapacity", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "capacities.CapacitiesClient", "ListSkusForCapacity", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListSkusForCapacity(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "capacities.CapacitiesClient", "ListSkusForCapacity", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListSkusForCapacity prepares the ListSkusForCapacity request. -func (c CapacitiesClient) preparerForListSkusForCapacity(ctx context.Context, id CapacityId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/skus", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListSkusForCapacity handles the response to the ListSkusForCapacity request. The method always -// closes the http.Response Body. -func (c CapacitiesClient) responderForListSkusForCapacity(resp *http.Response) (result ListSkusForCapacityOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/powerbidedicated/2021-01-01/capacities/method_resume.go b/resource-manager/powerbidedicated/2021-01-01/capacities/method_resume.go new file mode 100644 index 00000000000..07a0064f6d7 --- /dev/null +++ b/resource-manager/powerbidedicated/2021-01-01/capacities/method_resume.go @@ -0,0 +1,70 @@ +package capacities + +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 ResumeOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Resume ... +func (c CapacitiesClient) Resume(ctx context.Context, id CapacityId) (result ResumeOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resume", 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 +} + +// ResumeThenPoll performs Resume then polls until it's completed +func (c CapacitiesClient) ResumeThenPoll(ctx context.Context, id CapacityId) error { + result, err := c.Resume(ctx, id) + if err != nil { + return fmt.Errorf("performing Resume: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Resume: %+v", err) + } + + return nil +} diff --git a/resource-manager/powerbidedicated/2021-01-01/capacities/method_resume_autorest.go b/resource-manager/powerbidedicated/2021-01-01/capacities/method_resume_autorest.go deleted file mode 100644 index fd657558e91..00000000000 --- a/resource-manager/powerbidedicated/2021-01-01/capacities/method_resume_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package capacities - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ResumeOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Resume ... -func (c CapacitiesClient) Resume(ctx context.Context, id CapacityId) (result ResumeOperationResponse, err error) { - req, err := c.preparerForResume(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "capacities.CapacitiesClient", "Resume", nil, "Failure preparing request") - return - } - - result, err = c.senderForResume(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "capacities.CapacitiesClient", "Resume", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// ResumeThenPoll performs Resume then polls until it's completed -func (c CapacitiesClient) ResumeThenPoll(ctx context.Context, id CapacityId) error { - result, err := c.Resume(ctx, id) - if err != nil { - return fmt.Errorf("performing Resume: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Resume: %+v", err) - } - - return nil -} - -// preparerForResume prepares the Resume request. -func (c CapacitiesClient) preparerForResume(ctx context.Context, id CapacityId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/resume", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForResume sends the Resume request. The method will close the -// http.Response Body if it receives an error. -func (c CapacitiesClient) senderForResume(ctx context.Context, req *http.Request) (future ResumeOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/powerbidedicated/2021-01-01/capacities/method_suspend.go b/resource-manager/powerbidedicated/2021-01-01/capacities/method_suspend.go new file mode 100644 index 00000000000..33eb04d169f --- /dev/null +++ b/resource-manager/powerbidedicated/2021-01-01/capacities/method_suspend.go @@ -0,0 +1,70 @@ +package capacities + +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 SuspendOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Suspend ... +func (c CapacitiesClient) Suspend(ctx context.Context, id CapacityId) (result SuspendOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/suspend", 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 +} + +// SuspendThenPoll performs Suspend then polls until it's completed +func (c CapacitiesClient) SuspendThenPoll(ctx context.Context, id CapacityId) error { + result, err := c.Suspend(ctx, id) + if err != nil { + return fmt.Errorf("performing Suspend: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Suspend: %+v", err) + } + + return nil +} diff --git a/resource-manager/powerbidedicated/2021-01-01/capacities/method_suspend_autorest.go b/resource-manager/powerbidedicated/2021-01-01/capacities/method_suspend_autorest.go deleted file mode 100644 index 469769a22dd..00000000000 --- a/resource-manager/powerbidedicated/2021-01-01/capacities/method_suspend_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package capacities - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type SuspendOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Suspend ... -func (c CapacitiesClient) Suspend(ctx context.Context, id CapacityId) (result SuspendOperationResponse, err error) { - req, err := c.preparerForSuspend(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "capacities.CapacitiesClient", "Suspend", nil, "Failure preparing request") - return - } - - result, err = c.senderForSuspend(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "capacities.CapacitiesClient", "Suspend", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// SuspendThenPoll performs Suspend then polls until it's completed -func (c CapacitiesClient) SuspendThenPoll(ctx context.Context, id CapacityId) error { - result, err := c.Suspend(ctx, id) - if err != nil { - return fmt.Errorf("performing Suspend: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Suspend: %+v", err) - } - - return nil -} - -// preparerForSuspend prepares the Suspend request. -func (c CapacitiesClient) preparerForSuspend(ctx context.Context, id CapacityId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/suspend", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForSuspend sends the Suspend request. The method will close the -// http.Response Body if it receives an error. -func (c CapacitiesClient) senderForSuspend(ctx context.Context, req *http.Request) (future SuspendOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/powerbidedicated/2021-01-01/capacities/method_update.go b/resource-manager/powerbidedicated/2021-01-01/capacities/method_update.go new file mode 100644 index 00000000000..898bc375d2e --- /dev/null +++ b/resource-manager/powerbidedicated/2021-01-01/capacities/method_update.go @@ -0,0 +1,74 @@ +package capacities + +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 UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Update ... +func (c CapacitiesClient) Update(ctx context.Context, id CapacityId, input DedicatedCapacityUpdateParameters) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + 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 +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c CapacitiesClient) UpdateThenPoll(ctx context.Context, id CapacityId, input DedicatedCapacityUpdateParameters) error { + result, err := c.Update(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/resource-manager/powerbidedicated/2021-01-01/capacities/method_update_autorest.go b/resource-manager/powerbidedicated/2021-01-01/capacities/method_update_autorest.go deleted file mode 100644 index 3d41a9da152..00000000000 --- a/resource-manager/powerbidedicated/2021-01-01/capacities/method_update_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package capacities - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Update ... -func (c CapacitiesClient) Update(ctx context.Context, id CapacityId, input DedicatedCapacityUpdateParameters) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "capacities.CapacitiesClient", "Update", nil, "Failure preparing request") - return - } - - result, err = c.senderForUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "capacities.CapacitiesClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// UpdateThenPoll performs Update then polls until it's completed -func (c CapacitiesClient) UpdateThenPoll(ctx context.Context, id CapacityId, input DedicatedCapacityUpdateParameters) error { - result, err := c.Update(ctx, id, input) - if err != nil { - return fmt.Errorf("performing Update: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Update: %+v", err) - } - - return nil -} - -// preparerForUpdate prepares the Update request. -func (c CapacitiesClient) preparerForUpdate(ctx context.Context, id CapacityId, input DedicatedCapacityUpdateParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForUpdate sends the Update request. The method will close the -// http.Response Body if it receives an error. -func (c CapacitiesClient) senderForUpdate(ctx context.Context, req *http.Request) (future UpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/powerbidedicated/2021-01-01/client.go b/resource-manager/powerbidedicated/2021-01-01/client.go index 738f960d96b..97f0925513e 100644 --- a/resource-manager/powerbidedicated/2021-01-01/client.go +++ b/resource-manager/powerbidedicated/2021-01-01/client.go @@ -4,10 +4,13 @@ package v2021_01_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/powerbidedicated/2021-01-01/autoscalevcores" "github.com/hashicorp/go-azure-sdk/resource-manager/powerbidedicated/2021-01-01/capacities" "github.com/hashicorp/go-azure-sdk/resource-manager/powerbidedicated/2021-01-01/powerbidedicated" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/environments" ) type Client struct { @@ -16,20 +19,28 @@ type Client struct { PowerBIDedicated *powerbidedicated.PowerBIDedicatedClient } -func NewClientWithBaseURI(endpoint string, configureAuthFunc func(c *autorest.Client)) Client { - - autoScaleVCoresClient := autoscalevcores.NewAutoScaleVCoresClientWithBaseURI(endpoint) - configureAuthFunc(&autoScaleVCoresClient.Client) - - capacitiesClient := capacities.NewCapacitiesClientWithBaseURI(endpoint) - configureAuthFunc(&capacitiesClient.Client) +func NewClientWithBaseURI(api environments.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + autoScaleVCoresClient, err := autoscalevcores.NewAutoScaleVCoresClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building AutoScaleVCores client: %+v", err) + } + configureFunc(autoScaleVCoresClient.Client) - powerBIDedicatedClient := powerbidedicated.NewPowerBIDedicatedClientWithBaseURI(endpoint) - configureAuthFunc(&powerBIDedicatedClient.Client) + capacitiesClient, err := capacities.NewCapacitiesClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Capacities client: %+v", err) + } + configureFunc(capacitiesClient.Client) - return Client{ - AutoScaleVCores: &autoScaleVCoresClient, - Capacities: &capacitiesClient, - PowerBIDedicated: &powerBIDedicatedClient, + powerBIDedicatedClient, err := powerbidedicated.NewPowerBIDedicatedClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building PowerBIDedicated client: %+v", err) } + configureFunc(powerBIDedicatedClient.Client) + + return &Client{ + AutoScaleVCores: autoScaleVCoresClient, + Capacities: capacitiesClient, + PowerBIDedicated: powerBIDedicatedClient, + }, nil } diff --git a/resource-manager/powerbidedicated/2021-01-01/powerbidedicated/client.go b/resource-manager/powerbidedicated/2021-01-01/powerbidedicated/client.go index a93f73e8166..b49577e57a6 100644 --- a/resource-manager/powerbidedicated/2021-01-01/powerbidedicated/client.go +++ b/resource-manager/powerbidedicated/2021-01-01/powerbidedicated/client.go @@ -1,18 +1,26 @@ package powerbidedicated -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 PowerBIDedicatedClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewPowerBIDedicatedClientWithBaseURI(endpoint string) PowerBIDedicatedClient { - return PowerBIDedicatedClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewPowerBIDedicatedClientWithBaseURI(api environments.Api) (*PowerBIDedicatedClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "powerbidedicated", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PowerBIDedicatedClient: %+v", err) } + + return &PowerBIDedicatedClient{ + Client: client, + }, nil } diff --git a/resource-manager/powerbidedicated/2021-01-01/powerbidedicated/constants.go b/resource-manager/powerbidedicated/2021-01-01/powerbidedicated/constants.go index 610f28c21eb..7889a33e595 100644 --- a/resource-manager/powerbidedicated/2021-01-01/powerbidedicated/constants.go +++ b/resource-manager/powerbidedicated/2021-01-01/powerbidedicated/constants.go @@ -1,6 +1,10 @@ package powerbidedicated -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. @@ -21,6 +25,19 @@ func PossibleValuesForCapacitySkuTier() []string { } } +func (s *CapacitySkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCapacitySkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseCapacitySkuTier(input string) (*CapacitySkuTier, error) { vals := map[string]CapacitySkuTier{ "autopremiumhost": CapacitySkuTierAutoPremiumHost, diff --git a/resource-manager/powerbidedicated/2021-01-01/powerbidedicated/method_capacitieslistskus.go b/resource-manager/powerbidedicated/2021-01-01/powerbidedicated/method_capacitieslistskus.go new file mode 100644 index 00000000000..bb6a3ccf2e0 --- /dev/null +++ b/resource-manager/powerbidedicated/2021-01-01/powerbidedicated/method_capacitieslistskus.go @@ -0,0 +1,53 @@ +package powerbidedicated + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 CapacitiesListSkusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SkuEnumerationForNewResourceResult +} + +// CapacitiesListSkus ... +func (c PowerBIDedicatedClient) CapacitiesListSkus(ctx context.Context, id commonids.SubscriptionId) (result CapacitiesListSkusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.PowerBIDedicated/skus", 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 +} diff --git a/resource-manager/powerbidedicated/2021-01-01/powerbidedicated/method_capacitieslistskus_autorest.go b/resource-manager/powerbidedicated/2021-01-01/powerbidedicated/method_capacitieslistskus_autorest.go deleted file mode 100644 index d47229ea0b1..00000000000 --- a/resource-manager/powerbidedicated/2021-01-01/powerbidedicated/method_capacitieslistskus_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package powerbidedicated - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CapacitiesListSkusOperationResponse struct { - HttpResponse *http.Response - Model *SkuEnumerationForNewResourceResult -} - -// CapacitiesListSkus ... -func (c PowerBIDedicatedClient) CapacitiesListSkus(ctx context.Context, id commonids.SubscriptionId) (result CapacitiesListSkusOperationResponse, err error) { - req, err := c.preparerForCapacitiesListSkus(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "powerbidedicated.PowerBIDedicatedClient", "CapacitiesListSkus", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "powerbidedicated.PowerBIDedicatedClient", "CapacitiesListSkus", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCapacitiesListSkus(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "powerbidedicated.PowerBIDedicatedClient", "CapacitiesListSkus", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCapacitiesListSkus prepares the CapacitiesListSkus request. -func (c PowerBIDedicatedClient) preparerForCapacitiesListSkus(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.PowerBIDedicated/skus", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCapacitiesListSkus handles the response to the CapacitiesListSkus request. The method always -// closes the http.Response Body. -func (c PowerBIDedicatedClient) responderForCapacitiesListSkus(resp *http.Response) (result CapacitiesListSkusOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/privatedns/2020-06-01/client.go b/resource-manager/privatedns/2020-06-01/client.go index 17b4eb1be8b..392ac0c7b11 100644 --- a/resource-manager/privatedns/2020-06-01/client.go +++ b/resource-manager/privatedns/2020-06-01/client.go @@ -4,10 +4,13 @@ package v2020_06_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/privatedns/2020-06-01/privatezones" "github.com/hashicorp/go-azure-sdk/resource-manager/privatedns/2020-06-01/recordsets" "github.com/hashicorp/go-azure-sdk/resource-manager/privatedns/2020-06-01/virtualnetworklinks" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/environments" ) type Client struct { @@ -16,20 +19,28 @@ type Client struct { VirtualNetworkLinks *virtualnetworklinks.VirtualNetworkLinksClient } -func NewClientWithBaseURI(endpoint string, configureAuthFunc func(c *autorest.Client)) Client { - - privateZonesClient := privatezones.NewPrivateZonesClientWithBaseURI(endpoint) - configureAuthFunc(&privateZonesClient.Client) - - recordSetsClient := recordsets.NewRecordSetsClientWithBaseURI(endpoint) - configureAuthFunc(&recordSetsClient.Client) +func NewClientWithBaseURI(api environments.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + privateZonesClient, err := privatezones.NewPrivateZonesClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building PrivateZones client: %+v", err) + } + configureFunc(privateZonesClient.Client) - virtualNetworkLinksClient := virtualnetworklinks.NewVirtualNetworkLinksClientWithBaseURI(endpoint) - configureAuthFunc(&virtualNetworkLinksClient.Client) + recordSetsClient, err := recordsets.NewRecordSetsClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building RecordSets client: %+v", err) + } + configureFunc(recordSetsClient.Client) - return Client{ - PrivateZones: &privateZonesClient, - RecordSets: &recordSetsClient, - VirtualNetworkLinks: &virtualNetworkLinksClient, + virtualNetworkLinksClient, err := virtualnetworklinks.NewVirtualNetworkLinksClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building VirtualNetworkLinks client: %+v", err) } + configureFunc(virtualNetworkLinksClient.Client) + + return &Client{ + PrivateZones: privateZonesClient, + RecordSets: recordSetsClient, + VirtualNetworkLinks: virtualNetworkLinksClient, + }, nil } diff --git a/resource-manager/privatedns/2020-06-01/privatezones/client.go b/resource-manager/privatedns/2020-06-01/privatezones/client.go index 6dd4e3a74cb..bd67016d31b 100644 --- a/resource-manager/privatedns/2020-06-01/privatezones/client.go +++ b/resource-manager/privatedns/2020-06-01/privatezones/client.go @@ -1,18 +1,26 @@ package privatezones -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 PrivateZonesClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewPrivateZonesClientWithBaseURI(endpoint string) PrivateZonesClient { - return PrivateZonesClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewPrivateZonesClientWithBaseURI(api environments.Api) (*PrivateZonesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "privatezones", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PrivateZonesClient: %+v", err) } + + return &PrivateZonesClient{ + Client: client, + }, nil } diff --git a/resource-manager/privatedns/2020-06-01/privatezones/constants.go b/resource-manager/privatedns/2020-06-01/privatezones/constants.go index 324a9b57967..9ce4e5ddbb9 100644 --- a/resource-manager/privatedns/2020-06-01/privatezones/constants.go +++ b/resource-manager/privatedns/2020-06-01/privatezones/constants.go @@ -1,6 +1,10 @@ package privatezones -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. @@ -27,6 +31,19 @@ func PossibleValuesForProvisioningState() []string { } } +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseProvisioningState(input string) (*ProvisioningState, error) { vals := map[string]ProvisioningState{ "canceled": ProvisioningStateCanceled, diff --git a/resource-manager/privatedns/2020-06-01/privatezones/method_createorupdate.go b/resource-manager/privatedns/2020-06-01/privatezones/method_createorupdate.go new file mode 100644 index 00000000000..09492cbe7d7 --- /dev/null +++ b/resource-manager/privatedns/2020-06-01/privatezones/method_createorupdate.go @@ -0,0 +1,107 @@ +package privatezones + +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 + 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 PrivateZonesClient) CreateOrUpdate(ctx context.Context, id PrivateDnsZoneId, input PrivateZone, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 PrivateZonesClient) CreateOrUpdateThenPoll(ctx context.Context, id PrivateDnsZoneId, input PrivateZone, 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 +} diff --git a/resource-manager/privatedns/2020-06-01/privatezones/method_createorupdate_autorest.go b/resource-manager/privatedns/2020-06-01/privatezones/method_createorupdate_autorest.go deleted file mode 100644 index ccd19d4a6fa..00000000000 --- a/resource-manager/privatedns/2020-06-01/privatezones/method_createorupdate_autorest.go +++ /dev/null @@ -1,113 +0,0 @@ -package privatezones - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string - IfNoneMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - if o.IfNoneMatch != nil { - out["If-None-Match"] = *o.IfNoneMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c PrivateZonesClient) CreateOrUpdate(ctx context.Context, id PrivateDnsZoneId, input PrivateZone, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "privatezones.PrivateZonesClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "privatezones.PrivateZonesClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c PrivateZonesClient) CreateOrUpdateThenPoll(ctx context.Context, id PrivateDnsZoneId, input PrivateZone, 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(); err != nil { - return fmt.Errorf("polling after CreateOrUpdate: %+v", err) - } - - return nil -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c PrivateZonesClient) preparerForCreateOrUpdate(ctx context.Context, id PrivateDnsZoneId, input PrivateZone, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateOrUpdate sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c PrivateZonesClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/privatedns/2020-06-01/privatezones/method_delete.go b/resource-manager/privatedns/2020-06-01/privatezones/method_delete.go new file mode 100644 index 00000000000..48e22b378a8 --- /dev/null +++ b/resource-manager/privatedns/2020-06-01/privatezones/method_delete.go @@ -0,0 +1,99 @@ +package privatezones + +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 +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c PrivateZonesClient) Delete(ctx context.Context, id PrivateDnsZoneId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + 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 PrivateZonesClient) DeleteThenPoll(ctx context.Context, id PrivateDnsZoneId, options DeleteOperationOptions) error { + result, err := c.Delete(ctx, id, options) + 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 +} diff --git a/resource-manager/privatedns/2020-06-01/privatezones/method_delete_autorest.go b/resource-manager/privatedns/2020-06-01/privatezones/method_delete_autorest.go deleted file mode 100644 index e32f85656f2..00000000000 --- a/resource-manager/privatedns/2020-06-01/privatezones/method_delete_autorest.go +++ /dev/null @@ -1,107 +0,0 @@ -package privatezones - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c PrivateZonesClient) Delete(ctx context.Context, id PrivateDnsZoneId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "privatezones.PrivateZonesClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "privatezones.PrivateZonesClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c PrivateZonesClient) DeleteThenPoll(ctx context.Context, id PrivateDnsZoneId, options DeleteOperationOptions) error { - result, err := c.Delete(ctx, id, options) - if err != nil { - return fmt.Errorf("performing Delete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Delete: %+v", err) - } - - return nil -} - -// preparerForDelete prepares the Delete request. -func (c PrivateZonesClient) preparerForDelete(ctx context.Context, id PrivateDnsZoneId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDelete sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (c PrivateZonesClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/privatedns/2020-06-01/privatezones/method_get.go b/resource-manager/privatedns/2020-06-01/privatezones/method_get.go new file mode 100644 index 00000000000..33622d6f552 --- /dev/null +++ b/resource-manager/privatedns/2020-06-01/privatezones/method_get.go @@ -0,0 +1,51 @@ +package privatezones + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateZone +} + +// Get ... +func (c PrivateZonesClient) Get(ctx context.Context, id PrivateDnsZoneId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/privatedns/2020-06-01/privatezones/method_get_autorest.go b/resource-manager/privatedns/2020-06-01/privatezones/method_get_autorest.go deleted file mode 100644 index 93b3395f967..00000000000 --- a/resource-manager/privatedns/2020-06-01/privatezones/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package privatezones - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *PrivateZone -} - -// Get ... -func (c PrivateZonesClient) Get(ctx context.Context, id PrivateDnsZoneId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privatezones.PrivateZonesClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privatezones.PrivateZonesClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privatezones.PrivateZonesClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c PrivateZonesClient) preparerForGet(ctx context.Context, id PrivateDnsZoneId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c PrivateZonesClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/privatedns/2020-06-01/privatezones/method_list.go b/resource-manager/privatedns/2020-06-01/privatezones/method_list.go new file mode 100644 index 00000000000..314ccaa1d63 --- /dev/null +++ b/resource-manager/privatedns/2020-06-01/privatezones/method_list.go @@ -0,0 +1,118 @@ +package privatezones + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PrivateZone +} + +type ListCompleteResult struct { + Items []PrivateZone +} + +type ListOperationOptions struct { + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// List ... +func (c PrivateZonesClient) List(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/privateDnsZones", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PrivateZone `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c PrivateZonesClient) ListComplete(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, PrivateZoneOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PrivateZonesClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions, predicate PrivateZoneOperationPredicate) (result ListCompleteResult, err error) { + items := make([]PrivateZone, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/privatedns/2020-06-01/privatezones/method_list_autorest.go b/resource-manager/privatedns/2020-06-01/privatezones/method_list_autorest.go deleted file mode 100644 index 2a05c8a2602..00000000000 --- a/resource-manager/privatedns/2020-06-01/privatezones/method_list_autorest.go +++ /dev/null @@ -1,216 +0,0 @@ -package privatezones - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListOperationResponse struct { - HttpResponse *http.Response - Model *[]PrivateZone - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []PrivateZone -} - -func (r ListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListOperationOptions struct { - Top *int64 -} - -func DefaultListOperationOptions() ListOperationOptions { - return ListOperationOptions{} -} - -func (o ListOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// List ... -func (c PrivateZonesClient) List(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "privatezones.PrivateZonesClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privatezones.PrivateZonesClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privatezones.PrivateZonesClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c PrivateZonesClient) preparerForList(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Network/privateDnsZones", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c PrivateZonesClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForList handles the response to the List request. The method always -// closes the http.Response Body. -func (c PrivateZonesClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []PrivateZone `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { - req, err := c.preparerForListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "privatezones.PrivateZonesClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privatezones.PrivateZonesClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privatezones.PrivateZonesClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c PrivateZonesClient) ListComplete(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, options, PrivateZoneOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c PrivateZonesClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions, predicate PrivateZoneOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]PrivateZone, 0) - - page, err := c.List(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/privatedns/2020-06-01/privatezones/method_listbyresourcegroup.go b/resource-manager/privatedns/2020-06-01/privatezones/method_listbyresourcegroup.go new file mode 100644 index 00000000000..ef1c35984e5 --- /dev/null +++ b/resource-manager/privatedns/2020-06-01/privatezones/method_listbyresourcegroup.go @@ -0,0 +1,118 @@ +package privatezones + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PrivateZone +} + +type ListByResourceGroupCompleteResult struct { + Items []PrivateZone +} + +type ListByResourceGroupOperationOptions struct { + Top *int64 +} + +func DefaultListByResourceGroupOperationOptions() ListByResourceGroupOperationOptions { + return ListByResourceGroupOperationOptions{} +} + +func (o ListByResourceGroupOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByResourceGroupOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByResourceGroupOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByResourceGroup ... +func (c PrivateZonesClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/privateDnsZones", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PrivateZone `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c PrivateZonesClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, options, PrivateZoneOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PrivateZonesClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions, predicate PrivateZoneOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]PrivateZone, 0) + + resp, err := c.ListByResourceGroup(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/privatedns/2020-06-01/privatezones/method_listbyresourcegroup_autorest.go b/resource-manager/privatedns/2020-06-01/privatezones/method_listbyresourcegroup_autorest.go deleted file mode 100644 index 21d9bacd8a2..00000000000 --- a/resource-manager/privatedns/2020-06-01/privatezones/method_listbyresourcegroup_autorest.go +++ /dev/null @@ -1,216 +0,0 @@ -package privatezones - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByResourceGroupOperationResponse struct { - HttpResponse *http.Response - Model *[]PrivateZone - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByResourceGroupOperationResponse, error) -} - -type ListByResourceGroupCompleteResult struct { - Items []PrivateZone -} - -func (r ListByResourceGroupOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByResourceGroupOperationResponse) LoadMore(ctx context.Context) (resp ListByResourceGroupOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByResourceGroupOperationOptions struct { - Top *int64 -} - -func DefaultListByResourceGroupOperationOptions() ListByResourceGroupOperationOptions { - return ListByResourceGroupOperationOptions{} -} - -func (o ListByResourceGroupOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByResourceGroupOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByResourceGroup ... -func (c PrivateZonesClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (resp ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroup(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "privatezones.PrivateZonesClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privatezones.PrivateZonesClient", "ListByResourceGroup", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByResourceGroup(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privatezones.PrivateZonesClient", "ListByResourceGroup", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByResourceGroup prepares the ListByResourceGroup request. -func (c PrivateZonesClient) preparerForListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Network/privateDnsZones", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByResourceGroupWithNextLink prepares the ListByResourceGroup request with the given nextLink token. -func (c PrivateZonesClient) preparerForListByResourceGroupWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByResourceGroup handles the response to the ListByResourceGroup request. The method always -// closes the http.Response Body. -func (c PrivateZonesClient) responderForListByResourceGroup(resp *http.Response) (result ListByResourceGroupOperationResponse, err error) { - type page struct { - Values []PrivateZone `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroupWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "privatezones.PrivateZonesClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privatezones.PrivateZonesClient", "ListByResourceGroup", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByResourceGroup(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privatezones.PrivateZonesClient", "ListByResourceGroup", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByResourceGroupComplete retrieves all of the results into a single object -func (c PrivateZonesClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (ListByResourceGroupCompleteResult, error) { - return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, options, PrivateZoneOperationPredicate{}) -} - -// ListByResourceGroupCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c PrivateZonesClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions, predicate PrivateZoneOperationPredicate) (resp ListByResourceGroupCompleteResult, err error) { - items := make([]PrivateZone, 0) - - page, err := c.ListByResourceGroup(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByResourceGroupCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/privatedns/2020-06-01/privatezones/method_update.go b/resource-manager/privatedns/2020-06-01/privatezones/method_update.go new file mode 100644 index 00000000000..3e91c03d386 --- /dev/null +++ b/resource-manager/privatedns/2020-06-01/privatezones/method_update.go @@ -0,0 +1,102 @@ +package privatezones + +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 UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c PrivateZonesClient) Update(ctx context.Context, id PrivateDnsZoneId, input PrivateZone, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + 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 +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c PrivateZonesClient) UpdateThenPoll(ctx context.Context, id PrivateDnsZoneId, input PrivateZone, options UpdateOperationOptions) error { + result, err := c.Update(ctx, id, input, options) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/resource-manager/privatedns/2020-06-01/privatezones/method_update_autorest.go b/resource-manager/privatedns/2020-06-01/privatezones/method_update_autorest.go deleted file mode 100644 index 5a2191f6a54..00000000000 --- a/resource-manager/privatedns/2020-06-01/privatezones/method_update_autorest.go +++ /dev/null @@ -1,108 +0,0 @@ -package privatezones - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c PrivateZonesClient) Update(ctx context.Context, id PrivateDnsZoneId, input PrivateZone, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "privatezones.PrivateZonesClient", "Update", nil, "Failure preparing request") - return - } - - result, err = c.senderForUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "privatezones.PrivateZonesClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// UpdateThenPoll performs Update then polls until it's completed -func (c PrivateZonesClient) UpdateThenPoll(ctx context.Context, id PrivateDnsZoneId, input PrivateZone, options UpdateOperationOptions) error { - result, err := c.Update(ctx, id, input, options) - if err != nil { - return fmt.Errorf("performing Update: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Update: %+v", err) - } - - return nil -} - -// preparerForUpdate prepares the Update request. -func (c PrivateZonesClient) preparerForUpdate(ctx context.Context, id PrivateDnsZoneId, input PrivateZone, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForUpdate sends the Update request. The method will close the -// http.Response Body if it receives an error. -func (c PrivateZonesClient) senderForUpdate(ctx context.Context, req *http.Request) (future UpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/privatedns/2020-06-01/recordsets/client.go b/resource-manager/privatedns/2020-06-01/recordsets/client.go index 64dcacc5984..8b876af8dd1 100644 --- a/resource-manager/privatedns/2020-06-01/recordsets/client.go +++ b/resource-manager/privatedns/2020-06-01/recordsets/client.go @@ -1,18 +1,26 @@ package recordsets -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 RecordSetsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewRecordSetsClientWithBaseURI(endpoint string) RecordSetsClient { - return RecordSetsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewRecordSetsClientWithBaseURI(api environments.Api) (*RecordSetsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "recordsets", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating RecordSetsClient: %+v", err) } + + return &RecordSetsClient{ + Client: client, + }, nil } diff --git a/resource-manager/privatedns/2020-06-01/recordsets/constants.go b/resource-manager/privatedns/2020-06-01/recordsets/constants.go index 32cda74d172..23dfad2ab78 100644 --- a/resource-manager/privatedns/2020-06-01/recordsets/constants.go +++ b/resource-manager/privatedns/2020-06-01/recordsets/constants.go @@ -1,6 +1,10 @@ package recordsets -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. @@ -31,6 +35,19 @@ func PossibleValuesForRecordType() []string { } } +func (s *RecordType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRecordType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseRecordType(input string) (*RecordType, error) { vals := map[string]RecordType{ "a": RecordTypeA, diff --git a/resource-manager/privatedns/2020-06-01/recordsets/method_createorupdate.go b/resource-manager/privatedns/2020-06-01/recordsets/method_createorupdate.go new file mode 100644 index 00000000000..61acb8bc8fc --- /dev/null +++ b/resource-manager/privatedns/2020-06-01/recordsets/method_createorupdate.go @@ -0,0 +1,89 @@ +package recordsets + +import ( + "context" + "fmt" + "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 *RecordSet +} + +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 RecordSetsClient) CreateOrUpdate(ctx context.Context, id RecordTypeId, input RecordSet, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/privatedns/2020-06-01/recordsets/method_createorupdate_autorest.go b/resource-manager/privatedns/2020-06-01/recordsets/method_createorupdate_autorest.go deleted file mode 100644 index 115189971b8..00000000000 --- a/resource-manager/privatedns/2020-06-01/recordsets/method_createorupdate_autorest.go +++ /dev/null @@ -1,103 +0,0 @@ -package recordsets - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// 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 - Model *RecordSet -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string - IfNoneMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - if o.IfNoneMatch != nil { - out["If-None-Match"] = *o.IfNoneMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c RecordSetsClient) CreateOrUpdate(ctx context.Context, id RecordTypeId, input RecordSet, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "recordsets.RecordSetsClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "recordsets.RecordSetsClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "recordsets.RecordSetsClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c RecordSetsClient) preparerForCreateOrUpdate(ctx context.Context, id RecordTypeId, input RecordSet, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateOrUpdate handles the response to the CreateOrUpdate request. The method always -// closes the http.Response Body. -func (c RecordSetsClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/privatedns/2020-06-01/recordsets/method_delete.go b/resource-manager/privatedns/2020-06-01/recordsets/method_delete.go new file mode 100644 index 00000000000..1b3864a2f9e --- /dev/null +++ b/resource-manager/privatedns/2020-06-01/recordsets/method_delete.go @@ -0,0 +1,76 @@ +package recordsets + +import ( + "context" + "fmt" + "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 +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c RecordSetsClient) Delete(ctx context.Context, id RecordTypeId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + 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 + } + + return +} diff --git a/resource-manager/privatedns/2020-06-01/recordsets/method_delete_autorest.go b/resource-manager/privatedns/2020-06-01/recordsets/method_delete_autorest.go deleted file mode 100644 index 705826e0a5e..00000000000 --- a/resource-manager/privatedns/2020-06-01/recordsets/method_delete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package recordsets - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// 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 -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c RecordSetsClient) Delete(ctx context.Context, id RecordTypeId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "recordsets.RecordSetsClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "recordsets.RecordSetsClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "recordsets.RecordSetsClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c RecordSetsClient) preparerForDelete(ctx context.Context, id RecordTypeId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c RecordSetsClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/privatedns/2020-06-01/recordsets/method_get.go b/resource-manager/privatedns/2020-06-01/recordsets/method_get.go new file mode 100644 index 00000000000..45c7bcdfa09 --- /dev/null +++ b/resource-manager/privatedns/2020-06-01/recordsets/method_get.go @@ -0,0 +1,51 @@ +package recordsets + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RecordSet +} + +// Get ... +func (c RecordSetsClient) Get(ctx context.Context, id RecordTypeId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/privatedns/2020-06-01/recordsets/method_get_autorest.go b/resource-manager/privatedns/2020-06-01/recordsets/method_get_autorest.go deleted file mode 100644 index 0a853247729..00000000000 --- a/resource-manager/privatedns/2020-06-01/recordsets/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package recordsets - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *RecordSet -} - -// Get ... -func (c RecordSetsClient) Get(ctx context.Context, id RecordTypeId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "recordsets.RecordSetsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "recordsets.RecordSetsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "recordsets.RecordSetsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c RecordSetsClient) preparerForGet(ctx context.Context, id RecordTypeId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c RecordSetsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/privatedns/2020-06-01/recordsets/method_list.go b/resource-manager/privatedns/2020-06-01/recordsets/method_list.go new file mode 100644 index 00000000000..ad3d557636f --- /dev/null +++ b/resource-manager/privatedns/2020-06-01/recordsets/method_list.go @@ -0,0 +1,121 @@ +package recordsets + +import ( + "context" + "fmt" + "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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RecordSet +} + +type ListCompleteResult struct { + Items []RecordSet +} + +type ListOperationOptions struct { + Recordsetnamesuffix *string + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Recordsetnamesuffix != nil { + out.Append("$recordsetnamesuffix", fmt.Sprintf("%v", *o.Recordsetnamesuffix)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// List ... +func (c RecordSetsClient) List(ctx context.Context, id PrivateDnsZoneId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/aLL", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]RecordSet `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c RecordSetsClient) ListComplete(ctx context.Context, id PrivateDnsZoneId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, RecordSetOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RecordSetsClient) ListCompleteMatchingPredicate(ctx context.Context, id PrivateDnsZoneId, options ListOperationOptions, predicate RecordSetOperationPredicate) (result ListCompleteResult, err error) { + items := make([]RecordSet, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/privatedns/2020-06-01/recordsets/method_list_autorest.go b/resource-manager/privatedns/2020-06-01/recordsets/method_list_autorest.go deleted file mode 100644 index f7b2d7a0839..00000000000 --- a/resource-manager/privatedns/2020-06-01/recordsets/method_list_autorest.go +++ /dev/null @@ -1,220 +0,0 @@ -package recordsets - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListOperationResponse struct { - HttpResponse *http.Response - Model *[]RecordSet - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []RecordSet -} - -func (r ListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListOperationOptions struct { - Recordsetnamesuffix *string - Top *int64 -} - -func DefaultListOperationOptions() ListOperationOptions { - return ListOperationOptions{} -} - -func (o ListOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Recordsetnamesuffix != nil { - out["$recordsetnamesuffix"] = *o.Recordsetnamesuffix - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// List ... -func (c RecordSetsClient) List(ctx context.Context, id PrivateDnsZoneId, options ListOperationOptions) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "recordsets.RecordSetsClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "recordsets.RecordSetsClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "recordsets.RecordSetsClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c RecordSetsClient) preparerForList(ctx context.Context, id PrivateDnsZoneId, options ListOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/aLL", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c RecordSetsClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForList handles the response to the List request. The method always -// closes the http.Response Body. -func (c RecordSetsClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []RecordSet `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { - req, err := c.preparerForListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "recordsets.RecordSetsClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "recordsets.RecordSetsClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "recordsets.RecordSetsClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c RecordSetsClient) ListComplete(ctx context.Context, id PrivateDnsZoneId, options ListOperationOptions) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, options, RecordSetOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c RecordSetsClient) ListCompleteMatchingPredicate(ctx context.Context, id PrivateDnsZoneId, options ListOperationOptions, predicate RecordSetOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]RecordSet, 0) - - page, err := c.List(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/privatedns/2020-06-01/recordsets/method_listbytype.go b/resource-manager/privatedns/2020-06-01/recordsets/method_listbytype.go new file mode 100644 index 00000000000..3ca6d9a045e --- /dev/null +++ b/resource-manager/privatedns/2020-06-01/recordsets/method_listbytype.go @@ -0,0 +1,121 @@ +package recordsets + +import ( + "context" + "fmt" + "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 ListByTypeOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RecordSet +} + +type ListByTypeCompleteResult struct { + Items []RecordSet +} + +type ListByTypeOperationOptions struct { + Recordsetnamesuffix *string + Top *int64 +} + +func DefaultListByTypeOperationOptions() ListByTypeOperationOptions { + return ListByTypeOperationOptions{} +} + +func (o ListByTypeOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByTypeOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByTypeOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Recordsetnamesuffix != nil { + out.Append("$recordsetnamesuffix", fmt.Sprintf("%v", *o.Recordsetnamesuffix)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListByType ... +func (c RecordSetsClient) ListByType(ctx context.Context, id PrivateZoneId, options ListByTypeOperationOptions) (result ListByTypeOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]RecordSet `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByTypeComplete retrieves all the results into a single object +func (c RecordSetsClient) ListByTypeComplete(ctx context.Context, id PrivateZoneId, options ListByTypeOperationOptions) (ListByTypeCompleteResult, error) { + return c.ListByTypeCompleteMatchingPredicate(ctx, id, options, RecordSetOperationPredicate{}) +} + +// ListByTypeCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RecordSetsClient) ListByTypeCompleteMatchingPredicate(ctx context.Context, id PrivateZoneId, options ListByTypeOperationOptions, predicate RecordSetOperationPredicate) (result ListByTypeCompleteResult, err error) { + items := make([]RecordSet, 0) + + resp, err := c.ListByType(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByTypeCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/privatedns/2020-06-01/recordsets/method_listbytype_autorest.go b/resource-manager/privatedns/2020-06-01/recordsets/method_listbytype_autorest.go deleted file mode 100644 index 2d8355e2f2b..00000000000 --- a/resource-manager/privatedns/2020-06-01/recordsets/method_listbytype_autorest.go +++ /dev/null @@ -1,220 +0,0 @@ -package recordsets - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByTypeOperationResponse struct { - HttpResponse *http.Response - Model *[]RecordSet - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByTypeOperationResponse, error) -} - -type ListByTypeCompleteResult struct { - Items []RecordSet -} - -func (r ListByTypeOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByTypeOperationResponse) LoadMore(ctx context.Context) (resp ListByTypeOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByTypeOperationOptions struct { - Recordsetnamesuffix *string - Top *int64 -} - -func DefaultListByTypeOperationOptions() ListByTypeOperationOptions { - return ListByTypeOperationOptions{} -} - -func (o ListByTypeOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByTypeOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Recordsetnamesuffix != nil { - out["$recordsetnamesuffix"] = *o.Recordsetnamesuffix - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListByType ... -func (c RecordSetsClient) ListByType(ctx context.Context, id PrivateZoneId, options ListByTypeOperationOptions) (resp ListByTypeOperationResponse, err error) { - req, err := c.preparerForListByType(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "recordsets.RecordSetsClient", "ListByType", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "recordsets.RecordSetsClient", "ListByType", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByType(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "recordsets.RecordSetsClient", "ListByType", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByType prepares the ListByType request. -func (c RecordSetsClient) preparerForListByType(ctx context.Context, id PrivateZoneId, options ListByTypeOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByTypeWithNextLink prepares the ListByType request with the given nextLink token. -func (c RecordSetsClient) preparerForListByTypeWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByType handles the response to the ListByType request. The method always -// closes the http.Response Body. -func (c RecordSetsClient) responderForListByType(resp *http.Response) (result ListByTypeOperationResponse, err error) { - type page struct { - Values []RecordSet `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByTypeOperationResponse, err error) { - req, err := c.preparerForListByTypeWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "recordsets.RecordSetsClient", "ListByType", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "recordsets.RecordSetsClient", "ListByType", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByType(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "recordsets.RecordSetsClient", "ListByType", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByTypeComplete retrieves all of the results into a single object -func (c RecordSetsClient) ListByTypeComplete(ctx context.Context, id PrivateZoneId, options ListByTypeOperationOptions) (ListByTypeCompleteResult, error) { - return c.ListByTypeCompleteMatchingPredicate(ctx, id, options, RecordSetOperationPredicate{}) -} - -// ListByTypeCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c RecordSetsClient) ListByTypeCompleteMatchingPredicate(ctx context.Context, id PrivateZoneId, options ListByTypeOperationOptions, predicate RecordSetOperationPredicate) (resp ListByTypeCompleteResult, err error) { - items := make([]RecordSet, 0) - - page, err := c.ListByType(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByTypeCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/privatedns/2020-06-01/recordsets/method_update.go b/resource-manager/privatedns/2020-06-01/recordsets/method_update.go new file mode 100644 index 00000000000..716469efff0 --- /dev/null +++ b/resource-manager/privatedns/2020-06-01/recordsets/method_update.go @@ -0,0 +1,84 @@ +package recordsets + +import ( + "context" + "fmt" + "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 UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RecordSet +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c RecordSetsClient) Update(ctx context.Context, id RecordTypeId, input RecordSet, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + 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 + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/privatedns/2020-06-01/recordsets/method_update_autorest.go b/resource-manager/privatedns/2020-06-01/recordsets/method_update_autorest.go deleted file mode 100644 index 2fac5ae4042..00000000000 --- a/resource-manager/privatedns/2020-06-01/recordsets/method_update_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package recordsets - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateOperationResponse struct { - HttpResponse *http.Response - Model *RecordSet -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c RecordSetsClient) Update(ctx context.Context, id RecordTypeId, input RecordSet, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "recordsets.RecordSetsClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "recordsets.RecordSetsClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "recordsets.RecordSetsClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c RecordSetsClient) preparerForUpdate(ctx context.Context, id RecordTypeId, input RecordSet, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdate handles the response to the Update request. The method always -// closes the http.Response Body. -func (c RecordSetsClient) responderForUpdate(resp *http.Response) (result UpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/privatedns/2020-06-01/virtualnetworklinks/client.go b/resource-manager/privatedns/2020-06-01/virtualnetworklinks/client.go index 12c3c753d28..c8954f679ae 100644 --- a/resource-manager/privatedns/2020-06-01/virtualnetworklinks/client.go +++ b/resource-manager/privatedns/2020-06-01/virtualnetworklinks/client.go @@ -1,18 +1,26 @@ package virtualnetworklinks -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 VirtualNetworkLinksClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewVirtualNetworkLinksClientWithBaseURI(endpoint string) VirtualNetworkLinksClient { - return VirtualNetworkLinksClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewVirtualNetworkLinksClientWithBaseURI(api environments.Api) (*VirtualNetworkLinksClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "virtualnetworklinks", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating VirtualNetworkLinksClient: %+v", err) } + + return &VirtualNetworkLinksClient{ + Client: client, + }, nil } diff --git a/resource-manager/privatedns/2020-06-01/virtualnetworklinks/constants.go b/resource-manager/privatedns/2020-06-01/virtualnetworklinks/constants.go index 4717043cb9c..a4dc3ff577e 100644 --- a/resource-manager/privatedns/2020-06-01/virtualnetworklinks/constants.go +++ b/resource-manager/privatedns/2020-06-01/virtualnetworklinks/constants.go @@ -1,6 +1,10 @@ package virtualnetworklinks -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. @@ -27,6 +31,19 @@ func PossibleValuesForProvisioningState() []string { } } +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseProvisioningState(input string) (*ProvisioningState, error) { vals := map[string]ProvisioningState{ "canceled": ProvisioningStateCanceled, @@ -59,6 +76,19 @@ func PossibleValuesForVirtualNetworkLinkState() []string { } } +func (s *VirtualNetworkLinkState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkLinkState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseVirtualNetworkLinkState(input string) (*VirtualNetworkLinkState, error) { vals := map[string]VirtualNetworkLinkState{ "completed": VirtualNetworkLinkStateCompleted, diff --git a/resource-manager/privatedns/2020-06-01/virtualnetworklinks/method_createorupdate.go b/resource-manager/privatedns/2020-06-01/virtualnetworklinks/method_createorupdate.go new file mode 100644 index 00000000000..0219ef4128d --- /dev/null +++ b/resource-manager/privatedns/2020-06-01/virtualnetworklinks/method_createorupdate.go @@ -0,0 +1,107 @@ +package virtualnetworklinks + +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 + 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 VirtualNetworkLinksClient) CreateOrUpdate(ctx context.Context, id VirtualNetworkLinkId, input VirtualNetworkLink, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 VirtualNetworkLinksClient) CreateOrUpdateThenPoll(ctx context.Context, id VirtualNetworkLinkId, input VirtualNetworkLink, 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 +} diff --git a/resource-manager/privatedns/2020-06-01/virtualnetworklinks/method_createorupdate_autorest.go b/resource-manager/privatedns/2020-06-01/virtualnetworklinks/method_createorupdate_autorest.go deleted file mode 100644 index 210f701364c..00000000000 --- a/resource-manager/privatedns/2020-06-01/virtualnetworklinks/method_createorupdate_autorest.go +++ /dev/null @@ -1,113 +0,0 @@ -package virtualnetworklinks - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -type CreateOrUpdateOperationOptions struct { - IfMatch *string - IfNoneMatch *string -} - -func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { - return CreateOrUpdateOperationOptions{} -} - -func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - if o.IfNoneMatch != nil { - out["If-None-Match"] = *o.IfNoneMatch - } - - return out -} - -func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// CreateOrUpdate ... -func (c VirtualNetworkLinksClient) CreateOrUpdate(ctx context.Context, id VirtualNetworkLinkId, input VirtualNetworkLink, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "virtualnetworklinks.VirtualNetworkLinksClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "virtualnetworklinks.VirtualNetworkLinksClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c VirtualNetworkLinksClient) CreateOrUpdateThenPoll(ctx context.Context, id VirtualNetworkLinkId, input VirtualNetworkLink, 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(); err != nil { - return fmt.Errorf("polling after CreateOrUpdate: %+v", err) - } - - return nil -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c VirtualNetworkLinksClient) preparerForCreateOrUpdate(ctx context.Context, id VirtualNetworkLinkId, input VirtualNetworkLink, options CreateOrUpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateOrUpdate sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c VirtualNetworkLinksClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/privatedns/2020-06-01/virtualnetworklinks/method_delete.go b/resource-manager/privatedns/2020-06-01/virtualnetworklinks/method_delete.go new file mode 100644 index 00000000000..54c5d2d0710 --- /dev/null +++ b/resource-manager/privatedns/2020-06-01/virtualnetworklinks/method_delete.go @@ -0,0 +1,99 @@ +package virtualnetworklinks + +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 +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c VirtualNetworkLinksClient) Delete(ctx context.Context, id VirtualNetworkLinkId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + 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 VirtualNetworkLinksClient) DeleteThenPoll(ctx context.Context, id VirtualNetworkLinkId, options DeleteOperationOptions) error { + result, err := c.Delete(ctx, id, options) + 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 +} diff --git a/resource-manager/privatedns/2020-06-01/virtualnetworklinks/method_delete_autorest.go b/resource-manager/privatedns/2020-06-01/virtualnetworklinks/method_delete_autorest.go deleted file mode 100644 index 52398f30a49..00000000000 --- a/resource-manager/privatedns/2020-06-01/virtualnetworklinks/method_delete_autorest.go +++ /dev/null @@ -1,107 +0,0 @@ -package virtualnetworklinks - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - IfMatch *string -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Delete ... -func (c VirtualNetworkLinksClient) Delete(ctx context.Context, id VirtualNetworkLinkId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "virtualnetworklinks.VirtualNetworkLinksClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "virtualnetworklinks.VirtualNetworkLinksClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c VirtualNetworkLinksClient) DeleteThenPoll(ctx context.Context, id VirtualNetworkLinkId, options DeleteOperationOptions) error { - result, err := c.Delete(ctx, id, options) - if err != nil { - return fmt.Errorf("performing Delete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Delete: %+v", err) - } - - return nil -} - -// preparerForDelete prepares the Delete request. -func (c VirtualNetworkLinksClient) preparerForDelete(ctx context.Context, id VirtualNetworkLinkId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDelete sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (c VirtualNetworkLinksClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/privatedns/2020-06-01/virtualnetworklinks/method_get.go b/resource-manager/privatedns/2020-06-01/virtualnetworklinks/method_get.go new file mode 100644 index 00000000000..d732c3da67a --- /dev/null +++ b/resource-manager/privatedns/2020-06-01/virtualnetworklinks/method_get.go @@ -0,0 +1,51 @@ +package virtualnetworklinks + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VirtualNetworkLink +} + +// Get ... +func (c VirtualNetworkLinksClient) Get(ctx context.Context, id VirtualNetworkLinkId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/privatedns/2020-06-01/virtualnetworklinks/method_get_autorest.go b/resource-manager/privatedns/2020-06-01/virtualnetworklinks/method_get_autorest.go deleted file mode 100644 index f8c635914e6..00000000000 --- a/resource-manager/privatedns/2020-06-01/virtualnetworklinks/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package virtualnetworklinks - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *VirtualNetworkLink -} - -// Get ... -func (c VirtualNetworkLinksClient) Get(ctx context.Context, id VirtualNetworkLinkId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "virtualnetworklinks.VirtualNetworkLinksClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "virtualnetworklinks.VirtualNetworkLinksClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "virtualnetworklinks.VirtualNetworkLinksClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c VirtualNetworkLinksClient) preparerForGet(ctx context.Context, id VirtualNetworkLinkId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c VirtualNetworkLinksClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/privatedns/2020-06-01/virtualnetworklinks/method_list.go b/resource-manager/privatedns/2020-06-01/virtualnetworklinks/method_list.go new file mode 100644 index 00000000000..2f606e248ca --- /dev/null +++ b/resource-manager/privatedns/2020-06-01/virtualnetworklinks/method_list.go @@ -0,0 +1,117 @@ +package virtualnetworklinks + +import ( + "context" + "fmt" + "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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VirtualNetworkLink +} + +type ListCompleteResult struct { + Items []VirtualNetworkLink +} + +type ListOperationOptions struct { + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// List ... +func (c VirtualNetworkLinksClient) List(ctx context.Context, id PrivateDnsZoneId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/virtualNetworkLinks", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]VirtualNetworkLink `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c VirtualNetworkLinksClient) ListComplete(ctx context.Context, id PrivateDnsZoneId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, VirtualNetworkLinkOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VirtualNetworkLinksClient) ListCompleteMatchingPredicate(ctx context.Context, id PrivateDnsZoneId, options ListOperationOptions, predicate VirtualNetworkLinkOperationPredicate) (result ListCompleteResult, err error) { + items := make([]VirtualNetworkLink, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/privatedns/2020-06-01/virtualnetworklinks/method_list_autorest.go b/resource-manager/privatedns/2020-06-01/virtualnetworklinks/method_list_autorest.go deleted file mode 100644 index 0855a9fcfc4..00000000000 --- a/resource-manager/privatedns/2020-06-01/virtualnetworklinks/method_list_autorest.go +++ /dev/null @@ -1,215 +0,0 @@ -package virtualnetworklinks - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListOperationResponse struct { - HttpResponse *http.Response - Model *[]VirtualNetworkLink - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []VirtualNetworkLink -} - -func (r ListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListOperationOptions struct { - Top *int64 -} - -func DefaultListOperationOptions() ListOperationOptions { - return ListOperationOptions{} -} - -func (o ListOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// List ... -func (c VirtualNetworkLinksClient) List(ctx context.Context, id PrivateDnsZoneId, options ListOperationOptions) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "virtualnetworklinks.VirtualNetworkLinksClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "virtualnetworklinks.VirtualNetworkLinksClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "virtualnetworklinks.VirtualNetworkLinksClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c VirtualNetworkLinksClient) preparerForList(ctx context.Context, id PrivateDnsZoneId, options ListOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/virtualNetworkLinks", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c VirtualNetworkLinksClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForList handles the response to the List request. The method always -// closes the http.Response Body. -func (c VirtualNetworkLinksClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []VirtualNetworkLink `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { - req, err := c.preparerForListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "virtualnetworklinks.VirtualNetworkLinksClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "virtualnetworklinks.VirtualNetworkLinksClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "virtualnetworklinks.VirtualNetworkLinksClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c VirtualNetworkLinksClient) ListComplete(ctx context.Context, id PrivateDnsZoneId, options ListOperationOptions) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, options, VirtualNetworkLinkOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c VirtualNetworkLinksClient) ListCompleteMatchingPredicate(ctx context.Context, id PrivateDnsZoneId, options ListOperationOptions, predicate VirtualNetworkLinkOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]VirtualNetworkLink, 0) - - page, err := c.List(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/privatedns/2020-06-01/virtualnetworklinks/method_update.go b/resource-manager/privatedns/2020-06-01/virtualnetworklinks/method_update.go new file mode 100644 index 00000000000..c3aba65e6c1 --- /dev/null +++ b/resource-manager/privatedns/2020-06-01/virtualnetworklinks/method_update.go @@ -0,0 +1,102 @@ +package virtualnetworklinks + +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 UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c VirtualNetworkLinksClient) Update(ctx context.Context, id VirtualNetworkLinkId, input VirtualNetworkLink, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + 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 +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c VirtualNetworkLinksClient) UpdateThenPoll(ctx context.Context, id VirtualNetworkLinkId, input VirtualNetworkLink, options UpdateOperationOptions) error { + result, err := c.Update(ctx, id, input, options) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/resource-manager/privatedns/2020-06-01/virtualnetworklinks/method_update_autorest.go b/resource-manager/privatedns/2020-06-01/virtualnetworklinks/method_update_autorest.go deleted file mode 100644 index 3d911db3a67..00000000000 --- a/resource-manager/privatedns/2020-06-01/virtualnetworklinks/method_update_autorest.go +++ /dev/null @@ -1,108 +0,0 @@ -package virtualnetworklinks - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -type UpdateOperationOptions struct { - IfMatch *string -} - -func DefaultUpdateOperationOptions() UpdateOperationOptions { - return UpdateOperationOptions{} -} - -func (o UpdateOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IfMatch != nil { - out["If-Match"] = *o.IfMatch - } - - return out -} - -func (o UpdateOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -// Update ... -func (c VirtualNetworkLinksClient) Update(ctx context.Context, id VirtualNetworkLinkId, input VirtualNetworkLink, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "virtualnetworklinks.VirtualNetworkLinksClient", "Update", nil, "Failure preparing request") - return - } - - result, err = c.senderForUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "virtualnetworklinks.VirtualNetworkLinksClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// UpdateThenPoll performs Update then polls until it's completed -func (c VirtualNetworkLinksClient) UpdateThenPoll(ctx context.Context, id VirtualNetworkLinkId, input VirtualNetworkLink, options UpdateOperationOptions) error { - result, err := c.Update(ctx, id, input, options) - if err != nil { - return fmt.Errorf("performing Update: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Update: %+v", err) - } - - return nil -} - -// preparerForUpdate prepares the Update request. -func (c VirtualNetworkLinksClient) preparerForUpdate(ctx context.Context, id VirtualNetworkLinkId, input VirtualNetworkLink, options UpdateOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForUpdate sends the Update request. The method will close the -// http.Response Body if it receives an error. -func (c VirtualNetworkLinksClient) senderForUpdate(ctx context.Context, req *http.Request) (future UpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/purview/2021-07-01/account/client.go b/resource-manager/purview/2021-07-01/account/client.go index 576c4858107..46dbdb7538b 100644 --- a/resource-manager/purview/2021-07-01/account/client.go +++ b/resource-manager/purview/2021-07-01/account/client.go @@ -1,18 +1,26 @@ package account -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 AccountClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewAccountClientWithBaseURI(endpoint string) AccountClient { - return AccountClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewAccountClientWithBaseURI(api environments.Api) (*AccountClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "account", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AccountClient: %+v", err) } + + return &AccountClient{ + Client: client, + }, nil } diff --git a/resource-manager/purview/2021-07-01/account/constants.go b/resource-manager/purview/2021-07-01/account/constants.go index 31078ba5c74..10fcb6b174b 100644 --- a/resource-manager/purview/2021-07-01/account/constants.go +++ b/resource-manager/purview/2021-07-01/account/constants.go @@ -1,6 +1,10 @@ package account -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. @@ -17,6 +21,19 @@ func PossibleValuesForName() []string { } } +func (s *Name) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseName(input string) (*Name, error) { vals := map[string]Name{ "standard": NameStandard, @@ -58,6 +75,19 @@ func PossibleValuesForProvisioningState() []string { } } +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseProvisioningState(input string) (*ProvisioningState, error) { vals := map[string]ProvisioningState{ "canceled": ProvisioningStateCanceled, @@ -95,6 +125,19 @@ func PossibleValuesForPublicNetworkAccess() []string { } } +func (s *PublicNetworkAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicNetworkAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePublicNetworkAccess(input string) (*PublicNetworkAccess, error) { vals := map[string]PublicNetworkAccess{ "disabled": PublicNetworkAccessDisabled, @@ -130,6 +173,19 @@ func PossibleValuesForStatus() []string { } } +func (s *Status) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseStatus(input string) (*Status, error) { vals := map[string]Status{ "approved": StatusApproved, diff --git a/resource-manager/purview/2021-07-01/account/method_addrootcollectionadmin.go b/resource-manager/purview/2021-07-01/account/method_addrootcollectionadmin.go new file mode 100644 index 00000000000..c91a731faf2 --- /dev/null +++ b/resource-manager/purview/2021-07-01/account/method_addrootcollectionadmin.go @@ -0,0 +1,51 @@ +package account + +import ( + "context" + "fmt" + "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 AddRootCollectionAdminOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// AddRootCollectionAdmin ... +func (c AccountClient) AddRootCollectionAdmin(ctx context.Context, id AccountId, input CollectionAdminUpdate) (result AddRootCollectionAdminOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/addRootCollectionAdmin", 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 + } + + return +} diff --git a/resource-manager/purview/2021-07-01/account/method_addrootcollectionadmin_autorest.go b/resource-manager/purview/2021-07-01/account/method_addrootcollectionadmin_autorest.go deleted file mode 100644 index fc52fbbc201..00000000000 --- a/resource-manager/purview/2021-07-01/account/method_addrootcollectionadmin_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package account - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type AddRootCollectionAdminOperationResponse struct { - HttpResponse *http.Response -} - -// AddRootCollectionAdmin ... -func (c AccountClient) AddRootCollectionAdmin(ctx context.Context, id AccountId, input CollectionAdminUpdate) (result AddRootCollectionAdminOperationResponse, err error) { - req, err := c.preparerForAddRootCollectionAdmin(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "account.AccountClient", "AddRootCollectionAdmin", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "account.AccountClient", "AddRootCollectionAdmin", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForAddRootCollectionAdmin(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "account.AccountClient", "AddRootCollectionAdmin", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForAddRootCollectionAdmin prepares the AddRootCollectionAdmin request. -func (c AccountClient) preparerForAddRootCollectionAdmin(ctx context.Context, id AccountId, input CollectionAdminUpdate) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/addRootCollectionAdmin", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForAddRootCollectionAdmin handles the response to the AddRootCollectionAdmin request. The method always -// closes the http.Response Body. -func (c AccountClient) responderForAddRootCollectionAdmin(resp *http.Response) (result AddRootCollectionAdminOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/purview/2021-07-01/account/method_createorupdate.go b/resource-manager/purview/2021-07-01/account/method_createorupdate.go new file mode 100644 index 00000000000..fc3bd59dd9e --- /dev/null +++ b/resource-manager/purview/2021-07-01/account/method_createorupdate.go @@ -0,0 +1,74 @@ +package account + +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 +} + +// CreateOrUpdate ... +func (c AccountClient) CreateOrUpdate(ctx context.Context, id AccountId, input Account) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 AccountClient) CreateOrUpdateThenPoll(ctx context.Context, id AccountId, input Account) 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 +} diff --git a/resource-manager/purview/2021-07-01/account/method_createorupdate_autorest.go b/resource-manager/purview/2021-07-01/account/method_createorupdate_autorest.go deleted file mode 100644 index 8bfef414e46..00000000000 --- a/resource-manager/purview/2021-07-01/account/method_createorupdate_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package account - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateOrUpdate ... -func (c AccountClient) CreateOrUpdate(ctx context.Context, id AccountId, input Account) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "account.AccountClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "account.AccountClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c AccountClient) CreateOrUpdateThenPoll(ctx context.Context, id AccountId, input Account) error { - result, err := c.CreateOrUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateOrUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateOrUpdate: %+v", err) - } - - return nil -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c AccountClient) preparerForCreateOrUpdate(ctx context.Context, id AccountId, input Account) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateOrUpdate sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c AccountClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/purview/2021-07-01/account/method_delete.go b/resource-manager/purview/2021-07-01/account/method_delete.go new file mode 100644 index 00000000000..596398f5860 --- /dev/null +++ b/resource-manager/purview/2021-07-01/account/method_delete.go @@ -0,0 +1,71 @@ +package account + +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 AccountClient) Delete(ctx context.Context, id AccountId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 AccountClient) DeleteThenPoll(ctx context.Context, id AccountId) 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 +} diff --git a/resource-manager/purview/2021-07-01/account/method_delete_autorest.go b/resource-manager/purview/2021-07-01/account/method_delete_autorest.go deleted file mode 100644 index 43aad84a7cc..00000000000 --- a/resource-manager/purview/2021-07-01/account/method_delete_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package account - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// Delete ... -func (c AccountClient) Delete(ctx context.Context, id AccountId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "account.AccountClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "account.AccountClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c AccountClient) DeleteThenPoll(ctx context.Context, id AccountId) error { - result, err := c.Delete(ctx, id) - if err != nil { - return fmt.Errorf("performing Delete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Delete: %+v", err) - } - - return nil -} - -// preparerForDelete prepares the Delete request. -func (c AccountClient) preparerForDelete(ctx context.Context, id AccountId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDelete sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (c AccountClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/purview/2021-07-01/account/method_get.go b/resource-manager/purview/2021-07-01/account/method_get.go new file mode 100644 index 00000000000..03218aa3a03 --- /dev/null +++ b/resource-manager/purview/2021-07-01/account/method_get.go @@ -0,0 +1,51 @@ +package account + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Account +} + +// Get ... +func (c AccountClient) Get(ctx context.Context, id AccountId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/purview/2021-07-01/account/method_get_autorest.go b/resource-manager/purview/2021-07-01/account/method_get_autorest.go deleted file mode 100644 index 19da9f998f3..00000000000 --- a/resource-manager/purview/2021-07-01/account/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package account - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *Account -} - -// Get ... -func (c AccountClient) Get(ctx context.Context, id AccountId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "account.AccountClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "account.AccountClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "account.AccountClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c AccountClient) preparerForGet(ctx context.Context, id AccountId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c AccountClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/purview/2021-07-01/account/method_listbyresourcegroup.go b/resource-manager/purview/2021-07-01/account/method_listbyresourcegroup.go new file mode 100644 index 00000000000..8f11bca2b5d --- /dev/null +++ b/resource-manager/purview/2021-07-01/account/method_listbyresourcegroup.go @@ -0,0 +1,90 @@ +package account + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Account +} + +type ListByResourceGroupCompleteResult struct { + Items []Account +} + +// ListByResourceGroup ... +func (c AccountClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Purview/accounts", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Account `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c AccountClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, AccountOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AccountClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate AccountOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]Account, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/purview/2021-07-01/account/method_listbyresourcegroup_autorest.go b/resource-manager/purview/2021-07-01/account/method_listbyresourcegroup_autorest.go deleted file mode 100644 index 452d03d3bab..00000000000 --- a/resource-manager/purview/2021-07-01/account/method_listbyresourcegroup_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package account - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByResourceGroupOperationResponse struct { - HttpResponse *http.Response - Model *[]Account - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByResourceGroupOperationResponse, error) -} - -type ListByResourceGroupCompleteResult struct { - Items []Account -} - -func (r ListByResourceGroupOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByResourceGroupOperationResponse) LoadMore(ctx context.Context) (resp ListByResourceGroupOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByResourceGroup ... -func (c AccountClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (resp ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroup(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "account.AccountClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "account.AccountClient", "ListByResourceGroup", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByResourceGroup(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "account.AccountClient", "ListByResourceGroup", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByResourceGroup prepares the ListByResourceGroup request. -func (c AccountClient) preparerForListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Purview/accounts", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByResourceGroupWithNextLink prepares the ListByResourceGroup request with the given nextLink token. -func (c AccountClient) preparerForListByResourceGroupWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByResourceGroup handles the response to the ListByResourceGroup request. The method always -// closes the http.Response Body. -func (c AccountClient) responderForListByResourceGroup(resp *http.Response) (result ListByResourceGroupOperationResponse, err error) { - type page struct { - Values []Account `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroupWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "account.AccountClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "account.AccountClient", "ListByResourceGroup", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByResourceGroup(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "account.AccountClient", "ListByResourceGroup", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByResourceGroupComplete retrieves all of the results into a single object -func (c AccountClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { - return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, AccountOperationPredicate{}) -} - -// ListByResourceGroupCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c AccountClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate AccountOperationPredicate) (resp ListByResourceGroupCompleteResult, err error) { - items := make([]Account, 0) - - page, err := c.ListByResourceGroup(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByResourceGroupCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/purview/2021-07-01/account/method_listbysubscription.go b/resource-manager/purview/2021-07-01/account/method_listbysubscription.go new file mode 100644 index 00000000000..bb4a55e66d5 --- /dev/null +++ b/resource-manager/purview/2021-07-01/account/method_listbysubscription.go @@ -0,0 +1,90 @@ +package account + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Account +} + +type ListBySubscriptionCompleteResult struct { + Items []Account +} + +// ListBySubscription ... +func (c AccountClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Purview/accounts", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Account `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c AccountClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, AccountOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AccountClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate AccountOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]Account, 0) + + resp, err := c.ListBySubscription(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListBySubscriptionCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/purview/2021-07-01/account/method_listbysubscription_autorest.go b/resource-manager/purview/2021-07-01/account/method_listbysubscription_autorest.go deleted file mode 100644 index ae32361d3b2..00000000000 --- a/resource-manager/purview/2021-07-01/account/method_listbysubscription_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package account - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListBySubscriptionOperationResponse struct { - HttpResponse *http.Response - Model *[]Account - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListBySubscriptionOperationResponse, error) -} - -type ListBySubscriptionCompleteResult struct { - Items []Account -} - -func (r ListBySubscriptionOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListBySubscriptionOperationResponse) LoadMore(ctx context.Context) (resp ListBySubscriptionOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListBySubscription ... -func (c AccountClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (resp ListBySubscriptionOperationResponse, err error) { - req, err := c.preparerForListBySubscription(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "account.AccountClient", "ListBySubscription", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "account.AccountClient", "ListBySubscription", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListBySubscription(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "account.AccountClient", "ListBySubscription", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListBySubscription prepares the ListBySubscription request. -func (c AccountClient) preparerForListBySubscription(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Purview/accounts", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListBySubscriptionWithNextLink prepares the ListBySubscription request with the given nextLink token. -func (c AccountClient) preparerForListBySubscriptionWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListBySubscription handles the response to the ListBySubscription request. The method always -// closes the http.Response Body. -func (c AccountClient) responderForListBySubscription(resp *http.Response) (result ListBySubscriptionOperationResponse, err error) { - type page struct { - Values []Account `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListBySubscriptionOperationResponse, err error) { - req, err := c.preparerForListBySubscriptionWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "account.AccountClient", "ListBySubscription", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "account.AccountClient", "ListBySubscription", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListBySubscription(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "account.AccountClient", "ListBySubscription", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListBySubscriptionComplete retrieves all of the results into a single object -func (c AccountClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { - return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, AccountOperationPredicate{}) -} - -// ListBySubscriptionCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c AccountClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate AccountOperationPredicate) (resp ListBySubscriptionCompleteResult, err error) { - items := make([]Account, 0) - - page, err := c.ListBySubscription(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListBySubscriptionCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/purview/2021-07-01/account/method_listkeys.go b/resource-manager/purview/2021-07-01/account/method_listkeys.go new file mode 100644 index 00000000000..af96489a406 --- /dev/null +++ b/resource-manager/purview/2021-07-01/account/method_listkeys.go @@ -0,0 +1,52 @@ +package account + +import ( + "context" + "fmt" + "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 ListKeysOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AccessKeys +} + +// ListKeys ... +func (c AccountClient) ListKeys(ctx context.Context, id AccountId) (result ListKeysOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listkeys", 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 +} diff --git a/resource-manager/purview/2021-07-01/account/method_listkeys_autorest.go b/resource-manager/purview/2021-07-01/account/method_listkeys_autorest.go deleted file mode 100644 index b0896df6cd7..00000000000 --- a/resource-manager/purview/2021-07-01/account/method_listkeys_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package account - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListKeysOperationResponse struct { - HttpResponse *http.Response - Model *AccessKeys -} - -// ListKeys ... -func (c AccountClient) ListKeys(ctx context.Context, id AccountId) (result ListKeysOperationResponse, err error) { - req, err := c.preparerForListKeys(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "account.AccountClient", "ListKeys", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "account.AccountClient", "ListKeys", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListKeys(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "account.AccountClient", "ListKeys", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListKeys prepares the ListKeys request. -func (c AccountClient) preparerForListKeys(ctx context.Context, id AccountId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/listkeys", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListKeys handles the response to the ListKeys request. The method always -// closes the http.Response Body. -func (c AccountClient) responderForListKeys(resp *http.Response) (result ListKeysOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/purview/2021-07-01/account/method_update.go b/resource-manager/purview/2021-07-01/account/method_update.go new file mode 100644 index 00000000000..6027d233907 --- /dev/null +++ b/resource-manager/purview/2021-07-01/account/method_update.go @@ -0,0 +1,74 @@ +package account + +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 UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Update ... +func (c AccountClient) Update(ctx context.Context, id AccountId, input AccountUpdateParameters) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + 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 +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c AccountClient) UpdateThenPoll(ctx context.Context, id AccountId, input AccountUpdateParameters) error { + result, err := c.Update(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/resource-manager/purview/2021-07-01/account/method_update_autorest.go b/resource-manager/purview/2021-07-01/account/method_update_autorest.go deleted file mode 100644 index 97b0b6801dd..00000000000 --- a/resource-manager/purview/2021-07-01/account/method_update_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package account - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Update ... -func (c AccountClient) Update(ctx context.Context, id AccountId, input AccountUpdateParameters) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "account.AccountClient", "Update", nil, "Failure preparing request") - return - } - - result, err = c.senderForUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "account.AccountClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// UpdateThenPoll performs Update then polls until it's completed -func (c AccountClient) UpdateThenPoll(ctx context.Context, id AccountId, input AccountUpdateParameters) error { - result, err := c.Update(ctx, id, input) - if err != nil { - return fmt.Errorf("performing Update: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Update: %+v", err) - } - - return nil -} - -// preparerForUpdate prepares the Update request. -func (c AccountClient) preparerForUpdate(ctx context.Context, id AccountId, input AccountUpdateParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForUpdate sends the Update request. The method will close the -// http.Response Body if it receives an error. -func (c AccountClient) senderForUpdate(ctx context.Context, req *http.Request) (future UpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/purview/2021-07-01/client.go b/resource-manager/purview/2021-07-01/client.go index c5be2083d86..79ed0a09ce9 100644 --- a/resource-manager/purview/2021-07-01/client.go +++ b/resource-manager/purview/2021-07-01/client.go @@ -4,12 +4,15 @@ package v2021_07_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/purview/2021-07-01/account" "github.com/hashicorp/go-azure-sdk/resource-manager/purview/2021-07-01/defaultaccount" "github.com/hashicorp/go-azure-sdk/resource-manager/purview/2021-07-01/privateendpointconnection" "github.com/hashicorp/go-azure-sdk/resource-manager/purview/2021-07-01/privatelinkresource" "github.com/hashicorp/go-azure-sdk/resource-manager/purview/2021-07-01/provider" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/environments" ) type Client struct { @@ -20,28 +23,42 @@ type Client struct { Provider *provider.ProviderClient } -func NewClientWithBaseURI(endpoint string, configureAuthFunc func(c *autorest.Client)) Client { - - accountClient := account.NewAccountClientWithBaseURI(endpoint) - configureAuthFunc(&accountClient.Client) - - defaultAccountClient := defaultaccount.NewDefaultAccountClientWithBaseURI(endpoint) - configureAuthFunc(&defaultAccountClient.Client) +func NewClientWithBaseURI(api environments.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + accountClient, err := account.NewAccountClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Account client: %+v", err) + } + configureFunc(accountClient.Client) - privateEndpointConnectionClient := privateendpointconnection.NewPrivateEndpointConnectionClientWithBaseURI(endpoint) - configureAuthFunc(&privateEndpointConnectionClient.Client) + defaultAccountClient, err := defaultaccount.NewDefaultAccountClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building DefaultAccount client: %+v", err) + } + configureFunc(defaultAccountClient.Client) - privateLinkResourceClient := privatelinkresource.NewPrivateLinkResourceClientWithBaseURI(endpoint) - configureAuthFunc(&privateLinkResourceClient.Client) + privateEndpointConnectionClient, err := privateendpointconnection.NewPrivateEndpointConnectionClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building PrivateEndpointConnection client: %+v", err) + } + configureFunc(privateEndpointConnectionClient.Client) - providerClient := provider.NewProviderClientWithBaseURI(endpoint) - configureAuthFunc(&providerClient.Client) + privateLinkResourceClient, err := privatelinkresource.NewPrivateLinkResourceClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building PrivateLinkResource client: %+v", err) + } + configureFunc(privateLinkResourceClient.Client) - return Client{ - Account: &accountClient, - DefaultAccount: &defaultAccountClient, - PrivateEndpointConnection: &privateEndpointConnectionClient, - PrivateLinkResource: &privateLinkResourceClient, - Provider: &providerClient, + providerClient, err := provider.NewProviderClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Provider client: %+v", err) } + configureFunc(providerClient.Client) + + return &Client{ + Account: accountClient, + DefaultAccount: defaultAccountClient, + PrivateEndpointConnection: privateEndpointConnectionClient, + PrivateLinkResource: privateLinkResourceClient, + Provider: providerClient, + }, nil } diff --git a/resource-manager/purview/2021-07-01/defaultaccount/client.go b/resource-manager/purview/2021-07-01/defaultaccount/client.go index 2c5f4fe4ff3..300c0482164 100644 --- a/resource-manager/purview/2021-07-01/defaultaccount/client.go +++ b/resource-manager/purview/2021-07-01/defaultaccount/client.go @@ -1,18 +1,26 @@ package defaultaccount -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 DefaultAccountClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewDefaultAccountClientWithBaseURI(endpoint string) DefaultAccountClient { - return DefaultAccountClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewDefaultAccountClientWithBaseURI(api environments.Api) (*DefaultAccountClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "defaultaccount", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DefaultAccountClient: %+v", err) } + + return &DefaultAccountClient{ + Client: client, + }, nil } diff --git a/resource-manager/purview/2021-07-01/defaultaccount/constants.go b/resource-manager/purview/2021-07-01/defaultaccount/constants.go index 4770bf67690..dfc7edafa25 100644 --- a/resource-manager/purview/2021-07-01/defaultaccount/constants.go +++ b/resource-manager/purview/2021-07-01/defaultaccount/constants.go @@ -1,6 +1,10 @@ package defaultaccount -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. @@ -19,6 +23,19 @@ func PossibleValuesForScopeType() []string { } } +func (s *ScopeType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseScopeType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseScopeType(input string) (*ScopeType, error) { vals := map[string]ScopeType{ "subscription": ScopeTypeSubscription, diff --git a/resource-manager/purview/2021-07-01/defaultaccount/method_get.go b/resource-manager/purview/2021-07-01/defaultaccount/method_get.go new file mode 100644 index 00000000000..770d7671ee3 --- /dev/null +++ b/resource-manager/purview/2021-07-01/defaultaccount/method_get.go @@ -0,0 +1,88 @@ +package defaultaccount + +import ( + "context" + "fmt" + "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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DefaultAccountPayload +} + +type GetOperationOptions struct { + Scope *string + ScopeTenantId *string + ScopeType *ScopeType +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Scope != nil { + out.Append("scope", fmt.Sprintf("%v", *o.Scope)) + } + if o.ScopeTenantId != nil { + out.Append("scopeTenantId", fmt.Sprintf("%v", *o.ScopeTenantId)) + } + if o.ScopeType != nil { + out.Append("scopeType", fmt.Sprintf("%v", *o.ScopeType)) + } + return &out +} + +// Get ... +func (c DefaultAccountClient) Get(ctx context.Context, options GetOperationOptions) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: "/providers/Microsoft.Purview/getDefaultAccount", + OptionsObject: options, + } + + 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 +} diff --git a/resource-manager/purview/2021-07-01/defaultaccount/method_get_autorest.go b/resource-manager/purview/2021-07-01/defaultaccount/method_get_autorest.go deleted file mode 100644 index 48907862a09..00000000000 --- a/resource-manager/purview/2021-07-01/defaultaccount/method_get_autorest.go +++ /dev/null @@ -1,107 +0,0 @@ -package defaultaccount - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *DefaultAccountPayload -} - -type GetOperationOptions struct { - Scope *string - ScopeTenantId *string - ScopeType *ScopeType -} - -func DefaultGetOperationOptions() GetOperationOptions { - return GetOperationOptions{} -} - -func (o GetOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o GetOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Scope != nil { - out["scope"] = *o.Scope - } - - if o.ScopeTenantId != nil { - out["scopeTenantId"] = *o.ScopeTenantId - } - - if o.ScopeType != nil { - out["scopeType"] = *o.ScopeType - } - - return out -} - -// Get ... -func (c DefaultAccountClient) Get(ctx context.Context, options GetOperationOptions) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, options) - if err != nil { - err = autorest.NewErrorWithError(err, "defaultaccount.DefaultAccountClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "defaultaccount.DefaultAccountClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "defaultaccount.DefaultAccountClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c DefaultAccountClient) preparerForGet(ctx context.Context, options GetOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath("/providers/Microsoft.Purview/getDefaultAccount"), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c DefaultAccountClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/purview/2021-07-01/defaultaccount/method_remove.go b/resource-manager/purview/2021-07-01/defaultaccount/method_remove.go new file mode 100644 index 00000000000..70c644483e1 --- /dev/null +++ b/resource-manager/purview/2021-07-01/defaultaccount/method_remove.go @@ -0,0 +1,84 @@ +package defaultaccount + +import ( + "context" + "fmt" + "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 RemoveOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type RemoveOperationOptions struct { + Scope *string + ScopeTenantId *string + ScopeType *ScopeType +} + +func DefaultRemoveOperationOptions() RemoveOperationOptions { + return RemoveOperationOptions{} +} + +func (o RemoveOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o RemoveOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o RemoveOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Scope != nil { + out.Append("scope", fmt.Sprintf("%v", *o.Scope)) + } + if o.ScopeTenantId != nil { + out.Append("scopeTenantId", fmt.Sprintf("%v", *o.ScopeTenantId)) + } + if o.ScopeType != nil { + out.Append("scopeType", fmt.Sprintf("%v", *o.ScopeType)) + } + return &out +} + +// Remove ... +func (c DefaultAccountClient) Remove(ctx context.Context, options RemoveOperationOptions) (result RemoveOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: "/providers/Microsoft.Purview/removeDefaultAccount", + OptionsObject: options, + } + + 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 + } + + return +} diff --git a/resource-manager/purview/2021-07-01/defaultaccount/method_remove_autorest.go b/resource-manager/purview/2021-07-01/defaultaccount/method_remove_autorest.go deleted file mode 100644 index 7b576dbaff3..00000000000 --- a/resource-manager/purview/2021-07-01/defaultaccount/method_remove_autorest.go +++ /dev/null @@ -1,105 +0,0 @@ -package defaultaccount - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type RemoveOperationResponse struct { - HttpResponse *http.Response -} - -type RemoveOperationOptions struct { - Scope *string - ScopeTenantId *string - ScopeType *ScopeType -} - -func DefaultRemoveOperationOptions() RemoveOperationOptions { - return RemoveOperationOptions{} -} - -func (o RemoveOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o RemoveOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Scope != nil { - out["scope"] = *o.Scope - } - - if o.ScopeTenantId != nil { - out["scopeTenantId"] = *o.ScopeTenantId - } - - if o.ScopeType != nil { - out["scopeType"] = *o.ScopeType - } - - return out -} - -// Remove ... -func (c DefaultAccountClient) Remove(ctx context.Context, options RemoveOperationOptions) (result RemoveOperationResponse, err error) { - req, err := c.preparerForRemove(ctx, options) - if err != nil { - err = autorest.NewErrorWithError(err, "defaultaccount.DefaultAccountClient", "Remove", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "defaultaccount.DefaultAccountClient", "Remove", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForRemove(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "defaultaccount.DefaultAccountClient", "Remove", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForRemove prepares the Remove request. -func (c DefaultAccountClient) preparerForRemove(ctx context.Context, options RemoveOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath("/providers/Microsoft.Purview/removeDefaultAccount"), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForRemove handles the response to the Remove request. The method always -// closes the http.Response Body. -func (c DefaultAccountClient) responderForRemove(resp *http.Response) (result RemoveOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/purview/2021-07-01/defaultaccount/method_set.go b/resource-manager/purview/2021-07-01/defaultaccount/method_set.go new file mode 100644 index 00000000000..2b59ecf925f --- /dev/null +++ b/resource-manager/purview/2021-07-01/defaultaccount/method_set.go @@ -0,0 +1,55 @@ +package defaultaccount + +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 SetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DefaultAccountPayload +} + +// Set ... +func (c DefaultAccountClient) Set(ctx context.Context, input DefaultAccountPayload) (result SetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: "/providers/Microsoft.Purview/setDefaultAccount", + } + + 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 +} diff --git a/resource-manager/purview/2021-07-01/defaultaccount/method_set_autorest.go b/resource-manager/purview/2021-07-01/defaultaccount/method_set_autorest.go deleted file mode 100644 index 0f9d49510b8..00000000000 --- a/resource-manager/purview/2021-07-01/defaultaccount/method_set_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package defaultaccount - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type SetOperationResponse struct { - HttpResponse *http.Response - Model *DefaultAccountPayload -} - -// Set ... -func (c DefaultAccountClient) Set(ctx context.Context, input DefaultAccountPayload) (result SetOperationResponse, err error) { - req, err := c.preparerForSet(ctx, input) - if err != nil { - err = autorest.NewErrorWithError(err, "defaultaccount.DefaultAccountClient", "Set", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "defaultaccount.DefaultAccountClient", "Set", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForSet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "defaultaccount.DefaultAccountClient", "Set", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForSet prepares the Set request. -func (c DefaultAccountClient) preparerForSet(ctx context.Context, input DefaultAccountPayload) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath("/providers/Microsoft.Purview/setDefaultAccount"), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForSet handles the response to the Set request. The method always -// closes the http.Response Body. -func (c DefaultAccountClient) responderForSet(resp *http.Response) (result SetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/purview/2021-07-01/privateendpointconnection/client.go b/resource-manager/purview/2021-07-01/privateendpointconnection/client.go index 6acd77b913c..35dcdf8567e 100644 --- a/resource-manager/purview/2021-07-01/privateendpointconnection/client.go +++ b/resource-manager/purview/2021-07-01/privateendpointconnection/client.go @@ -1,18 +1,26 @@ package privateendpointconnection -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 PrivateEndpointConnectionClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewPrivateEndpointConnectionClientWithBaseURI(endpoint string) PrivateEndpointConnectionClient { - return PrivateEndpointConnectionClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewPrivateEndpointConnectionClientWithBaseURI(api environments.Api) (*PrivateEndpointConnectionClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "privateendpointconnection", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PrivateEndpointConnectionClient: %+v", err) } + + return &PrivateEndpointConnectionClient{ + Client: client, + }, nil } diff --git a/resource-manager/purview/2021-07-01/privateendpointconnection/constants.go b/resource-manager/purview/2021-07-01/privateendpointconnection/constants.go index 8770979fb06..f8607655548 100644 --- a/resource-manager/purview/2021-07-01/privateendpointconnection/constants.go +++ b/resource-manager/purview/2021-07-01/privateendpointconnection/constants.go @@ -1,6 +1,10 @@ package privateendpointconnection -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. @@ -25,6 +29,19 @@ func PossibleValuesForStatus() []string { } } +func (s *Status) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseStatus(input string) (*Status, error) { vals := map[string]Status{ "approved": StatusApproved, diff --git a/resource-manager/purview/2021-07-01/privateendpointconnection/method_createorupdate.go b/resource-manager/purview/2021-07-01/privateendpointconnection/method_createorupdate.go new file mode 100644 index 00000000000..7150d8817e5 --- /dev/null +++ b/resource-manager/purview/2021-07-01/privateendpointconnection/method_createorupdate.go @@ -0,0 +1,74 @@ +package privateendpointconnection + +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 +} + +// CreateOrUpdate ... +func (c PrivateEndpointConnectionClient) CreateOrUpdate(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 PrivateEndpointConnectionClient) CreateOrUpdateThenPoll(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) 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 +} diff --git a/resource-manager/purview/2021-07-01/privateendpointconnection/method_createorupdate_autorest.go b/resource-manager/purview/2021-07-01/privateendpointconnection/method_createorupdate_autorest.go deleted file mode 100644 index abf3a7f285d..00000000000 --- a/resource-manager/purview/2021-07-01/privateendpointconnection/method_createorupdate_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package privateendpointconnection - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateOrUpdate ... -func (c PrivateEndpointConnectionClient) CreateOrUpdate(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnection.PrivateEndpointConnectionClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnection.PrivateEndpointConnectionClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c PrivateEndpointConnectionClient) CreateOrUpdateThenPoll(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) error { - result, err := c.CreateOrUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateOrUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateOrUpdate: %+v", err) - } - - return nil -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c PrivateEndpointConnectionClient) preparerForCreateOrUpdate(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateOrUpdate sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c PrivateEndpointConnectionClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/purview/2021-07-01/privateendpointconnection/method_delete.go b/resource-manager/purview/2021-07-01/privateendpointconnection/method_delete.go new file mode 100644 index 00000000000..5d6e8694951 --- /dev/null +++ b/resource-manager/purview/2021-07-01/privateendpointconnection/method_delete.go @@ -0,0 +1,71 @@ +package privateendpointconnection + +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 PrivateEndpointConnectionClient) Delete(ctx context.Context, id PrivateEndpointConnectionId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 PrivateEndpointConnectionClient) DeleteThenPoll(ctx context.Context, id PrivateEndpointConnectionId) 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 +} diff --git a/resource-manager/purview/2021-07-01/privateendpointconnection/method_delete_autorest.go b/resource-manager/purview/2021-07-01/privateendpointconnection/method_delete_autorest.go deleted file mode 100644 index 7e8532d71b7..00000000000 --- a/resource-manager/purview/2021-07-01/privateendpointconnection/method_delete_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package privateendpointconnection - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// Delete ... -func (c PrivateEndpointConnectionClient) Delete(ctx context.Context, id PrivateEndpointConnectionId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnection.PrivateEndpointConnectionClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnection.PrivateEndpointConnectionClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c PrivateEndpointConnectionClient) DeleteThenPoll(ctx context.Context, id PrivateEndpointConnectionId) error { - result, err := c.Delete(ctx, id) - if err != nil { - return fmt.Errorf("performing Delete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Delete: %+v", err) - } - - return nil -} - -// preparerForDelete prepares the Delete request. -func (c PrivateEndpointConnectionClient) preparerForDelete(ctx context.Context, id PrivateEndpointConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDelete sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (c PrivateEndpointConnectionClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/purview/2021-07-01/privateendpointconnection/method_get.go b/resource-manager/purview/2021-07-01/privateendpointconnection/method_get.go new file mode 100644 index 00000000000..d6ba3b220ac --- /dev/null +++ b/resource-manager/purview/2021-07-01/privateendpointconnection/method_get.go @@ -0,0 +1,51 @@ +package privateendpointconnection + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateEndpointConnection +} + +// Get ... +func (c PrivateEndpointConnectionClient) Get(ctx context.Context, id PrivateEndpointConnectionId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/purview/2021-07-01/privateendpointconnection/method_get_autorest.go b/resource-manager/purview/2021-07-01/privateendpointconnection/method_get_autorest.go deleted file mode 100644 index 51fcf2168f7..00000000000 --- a/resource-manager/purview/2021-07-01/privateendpointconnection/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package privateendpointconnection - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *PrivateEndpointConnection -} - -// Get ... -func (c PrivateEndpointConnectionClient) Get(ctx context.Context, id PrivateEndpointConnectionId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnection.PrivateEndpointConnectionClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnection.PrivateEndpointConnectionClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnection.PrivateEndpointConnectionClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c PrivateEndpointConnectionClient) preparerForGet(ctx context.Context, id PrivateEndpointConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c PrivateEndpointConnectionClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/purview/2021-07-01/privateendpointconnection/method_listbyaccount.go b/resource-manager/purview/2021-07-01/privateendpointconnection/method_listbyaccount.go new file mode 100644 index 00000000000..060b85abb2b --- /dev/null +++ b/resource-manager/purview/2021-07-01/privateendpointconnection/method_listbyaccount.go @@ -0,0 +1,89 @@ +package privateendpointconnection + +import ( + "context" + "fmt" + "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 ListByAccountOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PrivateEndpointConnection +} + +type ListByAccountCompleteResult struct { + Items []PrivateEndpointConnection +} + +// ListByAccount ... +func (c PrivateEndpointConnectionClient) ListByAccount(ctx context.Context, id AccountId) (result ListByAccountOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateEndpointConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PrivateEndpointConnection `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByAccountComplete retrieves all the results into a single object +func (c PrivateEndpointConnectionClient) ListByAccountComplete(ctx context.Context, id AccountId) (ListByAccountCompleteResult, error) { + return c.ListByAccountCompleteMatchingPredicate(ctx, id, PrivateEndpointConnectionOperationPredicate{}) +} + +// ListByAccountCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PrivateEndpointConnectionClient) ListByAccountCompleteMatchingPredicate(ctx context.Context, id AccountId, predicate PrivateEndpointConnectionOperationPredicate) (result ListByAccountCompleteResult, err error) { + items := make([]PrivateEndpointConnection, 0) + + resp, err := c.ListByAccount(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByAccountCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/purview/2021-07-01/privateendpointconnection/method_listbyaccount_autorest.go b/resource-manager/purview/2021-07-01/privateendpointconnection/method_listbyaccount_autorest.go deleted file mode 100644 index b92bf6f6478..00000000000 --- a/resource-manager/purview/2021-07-01/privateendpointconnection/method_listbyaccount_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package privateendpointconnection - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByAccountOperationResponse struct { - HttpResponse *http.Response - Model *[]PrivateEndpointConnection - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByAccountOperationResponse, error) -} - -type ListByAccountCompleteResult struct { - Items []PrivateEndpointConnection -} - -func (r ListByAccountOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByAccountOperationResponse) LoadMore(ctx context.Context) (resp ListByAccountOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByAccount ... -func (c PrivateEndpointConnectionClient) ListByAccount(ctx context.Context, id AccountId) (resp ListByAccountOperationResponse, err error) { - req, err := c.preparerForListByAccount(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnection.PrivateEndpointConnectionClient", "ListByAccount", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnection.PrivateEndpointConnectionClient", "ListByAccount", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByAccount(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnection.PrivateEndpointConnectionClient", "ListByAccount", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByAccount prepares the ListByAccount request. -func (c PrivateEndpointConnectionClient) preparerForListByAccount(ctx context.Context, id AccountId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/privateEndpointConnections", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByAccountWithNextLink prepares the ListByAccount request with the given nextLink token. -func (c PrivateEndpointConnectionClient) preparerForListByAccountWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByAccount handles the response to the ListByAccount request. The method always -// closes the http.Response Body. -func (c PrivateEndpointConnectionClient) responderForListByAccount(resp *http.Response) (result ListByAccountOperationResponse, err error) { - type page struct { - Values []PrivateEndpointConnection `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByAccountOperationResponse, err error) { - req, err := c.preparerForListByAccountWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnection.PrivateEndpointConnectionClient", "ListByAccount", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnection.PrivateEndpointConnectionClient", "ListByAccount", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByAccount(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnection.PrivateEndpointConnectionClient", "ListByAccount", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByAccountComplete retrieves all of the results into a single object -func (c PrivateEndpointConnectionClient) ListByAccountComplete(ctx context.Context, id AccountId) (ListByAccountCompleteResult, error) { - return c.ListByAccountCompleteMatchingPredicate(ctx, id, PrivateEndpointConnectionOperationPredicate{}) -} - -// ListByAccountCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c PrivateEndpointConnectionClient) ListByAccountCompleteMatchingPredicate(ctx context.Context, id AccountId, predicate PrivateEndpointConnectionOperationPredicate) (resp ListByAccountCompleteResult, err error) { - items := make([]PrivateEndpointConnection, 0) - - page, err := c.ListByAccount(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByAccountCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/purview/2021-07-01/privatelinkresource/client.go b/resource-manager/purview/2021-07-01/privatelinkresource/client.go index 439ab784f90..1caf7195e24 100644 --- a/resource-manager/purview/2021-07-01/privatelinkresource/client.go +++ b/resource-manager/purview/2021-07-01/privatelinkresource/client.go @@ -1,18 +1,26 @@ package privatelinkresource -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 PrivateLinkResourceClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewPrivateLinkResourceClientWithBaseURI(endpoint string) PrivateLinkResourceClient { - return PrivateLinkResourceClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewPrivateLinkResourceClientWithBaseURI(api environments.Api) (*PrivateLinkResourceClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "privatelinkresource", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PrivateLinkResourceClient: %+v", err) } + + return &PrivateLinkResourceClient{ + Client: client, + }, nil } diff --git a/resource-manager/purview/2021-07-01/privatelinkresource/method_getbygroupid.go b/resource-manager/purview/2021-07-01/privatelinkresource/method_getbygroupid.go new file mode 100644 index 00000000000..8aa0a1060a4 --- /dev/null +++ b/resource-manager/purview/2021-07-01/privatelinkresource/method_getbygroupid.go @@ -0,0 +1,51 @@ +package privatelinkresource + +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 GetByGroupIdOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateLinkResource +} + +// GetByGroupId ... +func (c PrivateLinkResourceClient) GetByGroupId(ctx context.Context, id PrivateLinkResourceId) (result GetByGroupIdOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/purview/2021-07-01/privatelinkresource/method_getbygroupid_autorest.go b/resource-manager/purview/2021-07-01/privatelinkresource/method_getbygroupid_autorest.go deleted file mode 100644 index f5239a4fa3c..00000000000 --- a/resource-manager/purview/2021-07-01/privatelinkresource/method_getbygroupid_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package privatelinkresource - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetByGroupIdOperationResponse struct { - HttpResponse *http.Response - Model *PrivateLinkResource -} - -// GetByGroupId ... -func (c PrivateLinkResourceClient) GetByGroupId(ctx context.Context, id PrivateLinkResourceId) (result GetByGroupIdOperationResponse, err error) { - req, err := c.preparerForGetByGroupId(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresource.PrivateLinkResourceClient", "GetByGroupId", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresource.PrivateLinkResourceClient", "GetByGroupId", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetByGroupId(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresource.PrivateLinkResourceClient", "GetByGroupId", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetByGroupId prepares the GetByGroupId request. -func (c PrivateLinkResourceClient) preparerForGetByGroupId(ctx context.Context, id PrivateLinkResourceId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetByGroupId handles the response to the GetByGroupId request. The method always -// closes the http.Response Body. -func (c PrivateLinkResourceClient) responderForGetByGroupId(resp *http.Response) (result GetByGroupIdOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/purview/2021-07-01/privatelinkresource/method_listbyaccount.go b/resource-manager/purview/2021-07-01/privatelinkresource/method_listbyaccount.go new file mode 100644 index 00000000000..0a9a11b82bb --- /dev/null +++ b/resource-manager/purview/2021-07-01/privatelinkresource/method_listbyaccount.go @@ -0,0 +1,89 @@ +package privatelinkresource + +import ( + "context" + "fmt" + "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 ListByAccountOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PrivateLinkResource +} + +type ListByAccountCompleteResult struct { + Items []PrivateLinkResource +} + +// ListByAccount ... +func (c PrivateLinkResourceClient) ListByAccount(ctx context.Context, id AccountId) (result ListByAccountOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateLinkResources", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PrivateLinkResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByAccountComplete retrieves all the results into a single object +func (c PrivateLinkResourceClient) ListByAccountComplete(ctx context.Context, id AccountId) (ListByAccountCompleteResult, error) { + return c.ListByAccountCompleteMatchingPredicate(ctx, id, PrivateLinkResourceOperationPredicate{}) +} + +// ListByAccountCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PrivateLinkResourceClient) ListByAccountCompleteMatchingPredicate(ctx context.Context, id AccountId, predicate PrivateLinkResourceOperationPredicate) (result ListByAccountCompleteResult, err error) { + items := make([]PrivateLinkResource, 0) + + resp, err := c.ListByAccount(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByAccountCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/purview/2021-07-01/privatelinkresource/method_listbyaccount_autorest.go b/resource-manager/purview/2021-07-01/privatelinkresource/method_listbyaccount_autorest.go deleted file mode 100644 index 3babe69ad81..00000000000 --- a/resource-manager/purview/2021-07-01/privatelinkresource/method_listbyaccount_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package privatelinkresource - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByAccountOperationResponse struct { - HttpResponse *http.Response - Model *[]PrivateLinkResource - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByAccountOperationResponse, error) -} - -type ListByAccountCompleteResult struct { - Items []PrivateLinkResource -} - -func (r ListByAccountOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByAccountOperationResponse) LoadMore(ctx context.Context) (resp ListByAccountOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByAccount ... -func (c PrivateLinkResourceClient) ListByAccount(ctx context.Context, id AccountId) (resp ListByAccountOperationResponse, err error) { - req, err := c.preparerForListByAccount(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresource.PrivateLinkResourceClient", "ListByAccount", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresource.PrivateLinkResourceClient", "ListByAccount", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByAccount(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresource.PrivateLinkResourceClient", "ListByAccount", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByAccount prepares the ListByAccount request. -func (c PrivateLinkResourceClient) preparerForListByAccount(ctx context.Context, id AccountId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/privateLinkResources", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByAccountWithNextLink prepares the ListByAccount request with the given nextLink token. -func (c PrivateLinkResourceClient) preparerForListByAccountWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByAccount handles the response to the ListByAccount request. The method always -// closes the http.Response Body. -func (c PrivateLinkResourceClient) responderForListByAccount(resp *http.Response) (result ListByAccountOperationResponse, err error) { - type page struct { - Values []PrivateLinkResource `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByAccountOperationResponse, err error) { - req, err := c.preparerForListByAccountWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresource.PrivateLinkResourceClient", "ListByAccount", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresource.PrivateLinkResourceClient", "ListByAccount", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByAccount(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresource.PrivateLinkResourceClient", "ListByAccount", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByAccountComplete retrieves all of the results into a single object -func (c PrivateLinkResourceClient) ListByAccountComplete(ctx context.Context, id AccountId) (ListByAccountCompleteResult, error) { - return c.ListByAccountCompleteMatchingPredicate(ctx, id, PrivateLinkResourceOperationPredicate{}) -} - -// ListByAccountCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c PrivateLinkResourceClient) ListByAccountCompleteMatchingPredicate(ctx context.Context, id AccountId, predicate PrivateLinkResourceOperationPredicate) (resp ListByAccountCompleteResult, err error) { - items := make([]PrivateLinkResource, 0) - - page, err := c.ListByAccount(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByAccountCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/purview/2021-07-01/provider/client.go b/resource-manager/purview/2021-07-01/provider/client.go index bb6bd224461..d4c5b5c24aa 100644 --- a/resource-manager/purview/2021-07-01/provider/client.go +++ b/resource-manager/purview/2021-07-01/provider/client.go @@ -1,18 +1,26 @@ package provider -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 ProviderClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewProviderClientWithBaseURI(endpoint string) ProviderClient { - return ProviderClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewProviderClientWithBaseURI(api environments.Api) (*ProviderClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "provider", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ProviderClient: %+v", err) } + + return &ProviderClient{ + Client: client, + }, nil } diff --git a/resource-manager/purview/2021-07-01/provider/constants.go b/resource-manager/purview/2021-07-01/provider/constants.go index e5b1c1cbb53..f513d82cb19 100644 --- a/resource-manager/purview/2021-07-01/provider/constants.go +++ b/resource-manager/purview/2021-07-01/provider/constants.go @@ -1,6 +1,10 @@ package provider -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. @@ -19,6 +23,19 @@ func PossibleValuesForReason() []string { } } +func (s *Reason) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseReason(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseReason(input string) (*Reason, error) { vals := map[string]Reason{ "alreadyexists": ReasonAlreadyExists, diff --git a/resource-manager/purview/2021-07-01/provider/method_accountschecknameavailability.go b/resource-manager/purview/2021-07-01/provider/method_accountschecknameavailability.go new file mode 100644 index 00000000000..ae947923fa6 --- /dev/null +++ b/resource-manager/purview/2021-07-01/provider/method_accountschecknameavailability.go @@ -0,0 +1,57 @@ +package provider + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 AccountsCheckNameAvailabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CheckNameAvailabilityResult +} + +// AccountsCheckNameAvailability ... +func (c ProviderClient) AccountsCheckNameAvailability(ctx context.Context, id commonids.SubscriptionId, input CheckNameAvailabilityRequest) (result AccountsCheckNameAvailabilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.Purview/checkNameAvailability", 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 +} diff --git a/resource-manager/purview/2021-07-01/provider/method_accountschecknameavailability_autorest.go b/resource-manager/purview/2021-07-01/provider/method_accountschecknameavailability_autorest.go deleted file mode 100644 index 176fbed450a..00000000000 --- a/resource-manager/purview/2021-07-01/provider/method_accountschecknameavailability_autorest.go +++ /dev/null @@ -1,71 +0,0 @@ -package provider - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type AccountsCheckNameAvailabilityOperationResponse struct { - HttpResponse *http.Response - Model *CheckNameAvailabilityResult -} - -// AccountsCheckNameAvailability ... -func (c ProviderClient) AccountsCheckNameAvailability(ctx context.Context, id commonids.SubscriptionId, input CheckNameAvailabilityRequest) (result AccountsCheckNameAvailabilityOperationResponse, err error) { - req, err := c.preparerForAccountsCheckNameAvailability(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "provider.ProviderClient", "AccountsCheckNameAvailability", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "provider.ProviderClient", "AccountsCheckNameAvailability", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForAccountsCheckNameAvailability(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "provider.ProviderClient", "AccountsCheckNameAvailability", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForAccountsCheckNameAvailability prepares the AccountsCheckNameAvailability request. -func (c ProviderClient) preparerForAccountsCheckNameAvailability(ctx context.Context, id commonids.SubscriptionId, input CheckNameAvailabilityRequest) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Purview/checkNameAvailability", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForAccountsCheckNameAvailability handles the response to the AccountsCheckNameAvailability request. The method always -// closes the http.Response Body. -func (c ProviderClient) responderForAccountsCheckNameAvailability(resp *http.Response) (result AccountsCheckNameAvailabilityOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/purview/2021-12-01/account/client.go b/resource-manager/purview/2021-12-01/account/client.go index 576c4858107..46dbdb7538b 100644 --- a/resource-manager/purview/2021-12-01/account/client.go +++ b/resource-manager/purview/2021-12-01/account/client.go @@ -1,18 +1,26 @@ package account -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 AccountClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewAccountClientWithBaseURI(endpoint string) AccountClient { - return AccountClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewAccountClientWithBaseURI(api environments.Api) (*AccountClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "account", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AccountClient: %+v", err) } + + return &AccountClient{ + Client: client, + }, nil } diff --git a/resource-manager/purview/2021-12-01/account/constants.go b/resource-manager/purview/2021-12-01/account/constants.go index e222b51ee07..173ed887f1e 100644 --- a/resource-manager/purview/2021-12-01/account/constants.go +++ b/resource-manager/purview/2021-12-01/account/constants.go @@ -1,6 +1,10 @@ package account -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. @@ -35,6 +39,19 @@ func PossibleValuesForAccountProvisioningState() []string { } } +func (s *AccountProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAccountProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAccountProvisioningState(input string) (*AccountProvisioningState, error) { vals := map[string]AccountProvisioningState{ "canceled": AccountProvisioningStateCanceled, @@ -73,6 +90,19 @@ func PossibleValuesForManagedEventHubState() []string { } } +func (s *ManagedEventHubState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedEventHubState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseManagedEventHubState(input string) (*ManagedEventHubState, error) { vals := map[string]ManagedEventHubState{ "disabled": ManagedEventHubStateDisabled, @@ -104,6 +134,19 @@ func PossibleValuesForManagedResourcesPublicNetworkAccess() []string { } } +func (s *ManagedResourcesPublicNetworkAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedResourcesPublicNetworkAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseManagedResourcesPublicNetworkAccess(input string) (*ManagedResourcesPublicNetworkAccess, error) { vals := map[string]ManagedResourcesPublicNetworkAccess{ "disabled": ManagedResourcesPublicNetworkAccessDisabled, @@ -131,6 +174,19 @@ func PossibleValuesForName() []string { } } +func (s *Name) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseName(input string) (*Name, error) { vals := map[string]Name{ "standard": NameStandard, @@ -172,6 +228,19 @@ func PossibleValuesForProvisioningState() []string { } } +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseProvisioningState(input string) (*ProvisioningState, error) { vals := map[string]ProvisioningState{ "canceled": ProvisioningStateCanceled, @@ -209,6 +278,19 @@ func PossibleValuesForPublicNetworkAccess() []string { } } +func (s *PublicNetworkAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicNetworkAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePublicNetworkAccess(input string) (*PublicNetworkAccess, error) { vals := map[string]PublicNetworkAccess{ "disabled": PublicNetworkAccessDisabled, @@ -244,6 +326,19 @@ func PossibleValuesForStatus() []string { } } +func (s *Status) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseStatus(input string) (*Status, error) { vals := map[string]Status{ "approved": StatusApproved, diff --git a/resource-manager/purview/2021-12-01/account/method_addrootcollectionadmin.go b/resource-manager/purview/2021-12-01/account/method_addrootcollectionadmin.go new file mode 100644 index 00000000000..c91a731faf2 --- /dev/null +++ b/resource-manager/purview/2021-12-01/account/method_addrootcollectionadmin.go @@ -0,0 +1,51 @@ +package account + +import ( + "context" + "fmt" + "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 AddRootCollectionAdminOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// AddRootCollectionAdmin ... +func (c AccountClient) AddRootCollectionAdmin(ctx context.Context, id AccountId, input CollectionAdminUpdate) (result AddRootCollectionAdminOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/addRootCollectionAdmin", 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 + } + + return +} diff --git a/resource-manager/purview/2021-12-01/account/method_addrootcollectionadmin_autorest.go b/resource-manager/purview/2021-12-01/account/method_addrootcollectionadmin_autorest.go deleted file mode 100644 index fc52fbbc201..00000000000 --- a/resource-manager/purview/2021-12-01/account/method_addrootcollectionadmin_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package account - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type AddRootCollectionAdminOperationResponse struct { - HttpResponse *http.Response -} - -// AddRootCollectionAdmin ... -func (c AccountClient) AddRootCollectionAdmin(ctx context.Context, id AccountId, input CollectionAdminUpdate) (result AddRootCollectionAdminOperationResponse, err error) { - req, err := c.preparerForAddRootCollectionAdmin(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "account.AccountClient", "AddRootCollectionAdmin", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "account.AccountClient", "AddRootCollectionAdmin", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForAddRootCollectionAdmin(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "account.AccountClient", "AddRootCollectionAdmin", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForAddRootCollectionAdmin prepares the AddRootCollectionAdmin request. -func (c AccountClient) preparerForAddRootCollectionAdmin(ctx context.Context, id AccountId, input CollectionAdminUpdate) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/addRootCollectionAdmin", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForAddRootCollectionAdmin handles the response to the AddRootCollectionAdmin request. The method always -// closes the http.Response Body. -func (c AccountClient) responderForAddRootCollectionAdmin(resp *http.Response) (result AddRootCollectionAdminOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/purview/2021-12-01/account/method_createorupdate.go b/resource-manager/purview/2021-12-01/account/method_createorupdate.go new file mode 100644 index 00000000000..fc3bd59dd9e --- /dev/null +++ b/resource-manager/purview/2021-12-01/account/method_createorupdate.go @@ -0,0 +1,74 @@ +package account + +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 +} + +// CreateOrUpdate ... +func (c AccountClient) CreateOrUpdate(ctx context.Context, id AccountId, input Account) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 AccountClient) CreateOrUpdateThenPoll(ctx context.Context, id AccountId, input Account) 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 +} diff --git a/resource-manager/purview/2021-12-01/account/method_createorupdate_autorest.go b/resource-manager/purview/2021-12-01/account/method_createorupdate_autorest.go deleted file mode 100644 index 8bfef414e46..00000000000 --- a/resource-manager/purview/2021-12-01/account/method_createorupdate_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package account - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateOrUpdate ... -func (c AccountClient) CreateOrUpdate(ctx context.Context, id AccountId, input Account) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "account.AccountClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "account.AccountClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c AccountClient) CreateOrUpdateThenPoll(ctx context.Context, id AccountId, input Account) error { - result, err := c.CreateOrUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateOrUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateOrUpdate: %+v", err) - } - - return nil -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c AccountClient) preparerForCreateOrUpdate(ctx context.Context, id AccountId, input Account) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateOrUpdate sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c AccountClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/purview/2021-12-01/account/method_delete.go b/resource-manager/purview/2021-12-01/account/method_delete.go new file mode 100644 index 00000000000..596398f5860 --- /dev/null +++ b/resource-manager/purview/2021-12-01/account/method_delete.go @@ -0,0 +1,71 @@ +package account + +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 AccountClient) Delete(ctx context.Context, id AccountId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 AccountClient) DeleteThenPoll(ctx context.Context, id AccountId) 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 +} diff --git a/resource-manager/purview/2021-12-01/account/method_delete_autorest.go b/resource-manager/purview/2021-12-01/account/method_delete_autorest.go deleted file mode 100644 index 43aad84a7cc..00000000000 --- a/resource-manager/purview/2021-12-01/account/method_delete_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package account - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// Delete ... -func (c AccountClient) Delete(ctx context.Context, id AccountId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "account.AccountClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "account.AccountClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c AccountClient) DeleteThenPoll(ctx context.Context, id AccountId) error { - result, err := c.Delete(ctx, id) - if err != nil { - return fmt.Errorf("performing Delete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Delete: %+v", err) - } - - return nil -} - -// preparerForDelete prepares the Delete request. -func (c AccountClient) preparerForDelete(ctx context.Context, id AccountId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDelete sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (c AccountClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/purview/2021-12-01/account/method_get.go b/resource-manager/purview/2021-12-01/account/method_get.go new file mode 100644 index 00000000000..03218aa3a03 --- /dev/null +++ b/resource-manager/purview/2021-12-01/account/method_get.go @@ -0,0 +1,51 @@ +package account + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Account +} + +// Get ... +func (c AccountClient) Get(ctx context.Context, id AccountId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/purview/2021-12-01/account/method_get_autorest.go b/resource-manager/purview/2021-12-01/account/method_get_autorest.go deleted file mode 100644 index 19da9f998f3..00000000000 --- a/resource-manager/purview/2021-12-01/account/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package account - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *Account -} - -// Get ... -func (c AccountClient) Get(ctx context.Context, id AccountId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "account.AccountClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "account.AccountClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "account.AccountClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c AccountClient) preparerForGet(ctx context.Context, id AccountId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c AccountClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/purview/2021-12-01/account/method_listbyresourcegroup.go b/resource-manager/purview/2021-12-01/account/method_listbyresourcegroup.go new file mode 100644 index 00000000000..8f11bca2b5d --- /dev/null +++ b/resource-manager/purview/2021-12-01/account/method_listbyresourcegroup.go @@ -0,0 +1,90 @@ +package account + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Account +} + +type ListByResourceGroupCompleteResult struct { + Items []Account +} + +// ListByResourceGroup ... +func (c AccountClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Purview/accounts", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Account `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c AccountClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, AccountOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AccountClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate AccountOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]Account, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/purview/2021-12-01/account/method_listbyresourcegroup_autorest.go b/resource-manager/purview/2021-12-01/account/method_listbyresourcegroup_autorest.go deleted file mode 100644 index 452d03d3bab..00000000000 --- a/resource-manager/purview/2021-12-01/account/method_listbyresourcegroup_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package account - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByResourceGroupOperationResponse struct { - HttpResponse *http.Response - Model *[]Account - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByResourceGroupOperationResponse, error) -} - -type ListByResourceGroupCompleteResult struct { - Items []Account -} - -func (r ListByResourceGroupOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByResourceGroupOperationResponse) LoadMore(ctx context.Context) (resp ListByResourceGroupOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByResourceGroup ... -func (c AccountClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (resp ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroup(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "account.AccountClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "account.AccountClient", "ListByResourceGroup", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByResourceGroup(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "account.AccountClient", "ListByResourceGroup", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByResourceGroup prepares the ListByResourceGroup request. -func (c AccountClient) preparerForListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Purview/accounts", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByResourceGroupWithNextLink prepares the ListByResourceGroup request with the given nextLink token. -func (c AccountClient) preparerForListByResourceGroupWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByResourceGroup handles the response to the ListByResourceGroup request. The method always -// closes the http.Response Body. -func (c AccountClient) responderForListByResourceGroup(resp *http.Response) (result ListByResourceGroupOperationResponse, err error) { - type page struct { - Values []Account `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroupWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "account.AccountClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "account.AccountClient", "ListByResourceGroup", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByResourceGroup(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "account.AccountClient", "ListByResourceGroup", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByResourceGroupComplete retrieves all of the results into a single object -func (c AccountClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { - return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, AccountOperationPredicate{}) -} - -// ListByResourceGroupCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c AccountClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate AccountOperationPredicate) (resp ListByResourceGroupCompleteResult, err error) { - items := make([]Account, 0) - - page, err := c.ListByResourceGroup(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByResourceGroupCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/purview/2021-12-01/account/method_listbysubscription.go b/resource-manager/purview/2021-12-01/account/method_listbysubscription.go new file mode 100644 index 00000000000..bb4a55e66d5 --- /dev/null +++ b/resource-manager/purview/2021-12-01/account/method_listbysubscription.go @@ -0,0 +1,90 @@ +package account + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Account +} + +type ListBySubscriptionCompleteResult struct { + Items []Account +} + +// ListBySubscription ... +func (c AccountClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Purview/accounts", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Account `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c AccountClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, AccountOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AccountClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate AccountOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]Account, 0) + + resp, err := c.ListBySubscription(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListBySubscriptionCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/purview/2021-12-01/account/method_listbysubscription_autorest.go b/resource-manager/purview/2021-12-01/account/method_listbysubscription_autorest.go deleted file mode 100644 index ae32361d3b2..00000000000 --- a/resource-manager/purview/2021-12-01/account/method_listbysubscription_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package account - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListBySubscriptionOperationResponse struct { - HttpResponse *http.Response - Model *[]Account - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListBySubscriptionOperationResponse, error) -} - -type ListBySubscriptionCompleteResult struct { - Items []Account -} - -func (r ListBySubscriptionOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListBySubscriptionOperationResponse) LoadMore(ctx context.Context) (resp ListBySubscriptionOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListBySubscription ... -func (c AccountClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (resp ListBySubscriptionOperationResponse, err error) { - req, err := c.preparerForListBySubscription(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "account.AccountClient", "ListBySubscription", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "account.AccountClient", "ListBySubscription", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListBySubscription(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "account.AccountClient", "ListBySubscription", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListBySubscription prepares the ListBySubscription request. -func (c AccountClient) preparerForListBySubscription(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Purview/accounts", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListBySubscriptionWithNextLink prepares the ListBySubscription request with the given nextLink token. -func (c AccountClient) preparerForListBySubscriptionWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListBySubscription handles the response to the ListBySubscription request. The method always -// closes the http.Response Body. -func (c AccountClient) responderForListBySubscription(resp *http.Response) (result ListBySubscriptionOperationResponse, err error) { - type page struct { - Values []Account `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListBySubscriptionOperationResponse, err error) { - req, err := c.preparerForListBySubscriptionWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "account.AccountClient", "ListBySubscription", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "account.AccountClient", "ListBySubscription", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListBySubscription(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "account.AccountClient", "ListBySubscription", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListBySubscriptionComplete retrieves all of the results into a single object -func (c AccountClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { - return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, AccountOperationPredicate{}) -} - -// ListBySubscriptionCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c AccountClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate AccountOperationPredicate) (resp ListBySubscriptionCompleteResult, err error) { - items := make([]Account, 0) - - page, err := c.ListBySubscription(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListBySubscriptionCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/purview/2021-12-01/account/method_listkeys.go b/resource-manager/purview/2021-12-01/account/method_listkeys.go new file mode 100644 index 00000000000..af96489a406 --- /dev/null +++ b/resource-manager/purview/2021-12-01/account/method_listkeys.go @@ -0,0 +1,52 @@ +package account + +import ( + "context" + "fmt" + "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 ListKeysOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AccessKeys +} + +// ListKeys ... +func (c AccountClient) ListKeys(ctx context.Context, id AccountId) (result ListKeysOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listkeys", 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 +} diff --git a/resource-manager/purview/2021-12-01/account/method_listkeys_autorest.go b/resource-manager/purview/2021-12-01/account/method_listkeys_autorest.go deleted file mode 100644 index b0896df6cd7..00000000000 --- a/resource-manager/purview/2021-12-01/account/method_listkeys_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package account - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListKeysOperationResponse struct { - HttpResponse *http.Response - Model *AccessKeys -} - -// ListKeys ... -func (c AccountClient) ListKeys(ctx context.Context, id AccountId) (result ListKeysOperationResponse, err error) { - req, err := c.preparerForListKeys(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "account.AccountClient", "ListKeys", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "account.AccountClient", "ListKeys", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListKeys(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "account.AccountClient", "ListKeys", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListKeys prepares the ListKeys request. -func (c AccountClient) preparerForListKeys(ctx context.Context, id AccountId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/listkeys", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListKeys handles the response to the ListKeys request. The method always -// closes the http.Response Body. -func (c AccountClient) responderForListKeys(resp *http.Response) (result ListKeysOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/purview/2021-12-01/account/method_update.go b/resource-manager/purview/2021-12-01/account/method_update.go new file mode 100644 index 00000000000..6027d233907 --- /dev/null +++ b/resource-manager/purview/2021-12-01/account/method_update.go @@ -0,0 +1,74 @@ +package account + +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 UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Update ... +func (c AccountClient) Update(ctx context.Context, id AccountId, input AccountUpdateParameters) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + 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 +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c AccountClient) UpdateThenPoll(ctx context.Context, id AccountId, input AccountUpdateParameters) error { + result, err := c.Update(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/resource-manager/purview/2021-12-01/account/method_update_autorest.go b/resource-manager/purview/2021-12-01/account/method_update_autorest.go deleted file mode 100644 index 97b0b6801dd..00000000000 --- a/resource-manager/purview/2021-12-01/account/method_update_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package account - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Update ... -func (c AccountClient) Update(ctx context.Context, id AccountId, input AccountUpdateParameters) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "account.AccountClient", "Update", nil, "Failure preparing request") - return - } - - result, err = c.senderForUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "account.AccountClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// UpdateThenPoll performs Update then polls until it's completed -func (c AccountClient) UpdateThenPoll(ctx context.Context, id AccountId, input AccountUpdateParameters) error { - result, err := c.Update(ctx, id, input) - if err != nil { - return fmt.Errorf("performing Update: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Update: %+v", err) - } - - return nil -} - -// preparerForUpdate prepares the Update request. -func (c AccountClient) preparerForUpdate(ctx context.Context, id AccountId, input AccountUpdateParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForUpdate sends the Update request. The method will close the -// http.Response Body if it receives an error. -func (c AccountClient) senderForUpdate(ctx context.Context, req *http.Request) (future UpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/purview/2021-12-01/client.go b/resource-manager/purview/2021-12-01/client.go index 01be63e9260..0319844a9b5 100644 --- a/resource-manager/purview/2021-12-01/client.go +++ b/resource-manager/purview/2021-12-01/client.go @@ -4,7 +4,8 @@ package v2021_12_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/purview/2021-12-01/account" "github.com/hashicorp/go-azure-sdk/resource-manager/purview/2021-12-01/defaultaccount" "github.com/hashicorp/go-azure-sdk/resource-manager/purview/2021-12-01/feature" @@ -13,6 +14,8 @@ import ( "github.com/hashicorp/go-azure-sdk/resource-manager/purview/2021-12-01/privatelinkresource" "github.com/hashicorp/go-azure-sdk/resource-manager/purview/2021-12-01/provider" "github.com/hashicorp/go-azure-sdk/resource-manager/purview/2021-12-01/usages" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/environments" ) type Client struct { @@ -26,40 +29,63 @@ type Client struct { Usages *usages.UsagesClient } -func NewClientWithBaseURI(endpoint string, configureAuthFunc func(c *autorest.Client)) Client { - - accountClient := account.NewAccountClientWithBaseURI(endpoint) - configureAuthFunc(&accountClient.Client) - - defaultAccountClient := defaultaccount.NewDefaultAccountClientWithBaseURI(endpoint) - configureAuthFunc(&defaultAccountClient.Client) +func NewClientWithBaseURI(api environments.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + accountClient, err := account.NewAccountClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Account client: %+v", err) + } + configureFunc(accountClient.Client) - featureClient := feature.NewFeatureClientWithBaseURI(endpoint) - configureAuthFunc(&featureClient.Client) + defaultAccountClient, err := defaultaccount.NewDefaultAccountClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building DefaultAccount client: %+v", err) + } + configureFunc(defaultAccountClient.Client) - kafkaConfigurationClient := kafkaconfiguration.NewKafkaConfigurationClientWithBaseURI(endpoint) - configureAuthFunc(&kafkaConfigurationClient.Client) + featureClient, err := feature.NewFeatureClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Feature client: %+v", err) + } + configureFunc(featureClient.Client) - privateEndpointConnectionClient := privateendpointconnection.NewPrivateEndpointConnectionClientWithBaseURI(endpoint) - configureAuthFunc(&privateEndpointConnectionClient.Client) + kafkaConfigurationClient, err := kafkaconfiguration.NewKafkaConfigurationClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building KafkaConfiguration client: %+v", err) + } + configureFunc(kafkaConfigurationClient.Client) - privateLinkResourceClient := privatelinkresource.NewPrivateLinkResourceClientWithBaseURI(endpoint) - configureAuthFunc(&privateLinkResourceClient.Client) + privateEndpointConnectionClient, err := privateendpointconnection.NewPrivateEndpointConnectionClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building PrivateEndpointConnection client: %+v", err) + } + configureFunc(privateEndpointConnectionClient.Client) - providerClient := provider.NewProviderClientWithBaseURI(endpoint) - configureAuthFunc(&providerClient.Client) + privateLinkResourceClient, err := privatelinkresource.NewPrivateLinkResourceClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building PrivateLinkResource client: %+v", err) + } + configureFunc(privateLinkResourceClient.Client) - usagesClient := usages.NewUsagesClientWithBaseURI(endpoint) - configureAuthFunc(&usagesClient.Client) + providerClient, err := provider.NewProviderClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Provider client: %+v", err) + } + configureFunc(providerClient.Client) - return Client{ - Account: &accountClient, - DefaultAccount: &defaultAccountClient, - Feature: &featureClient, - KafkaConfiguration: &kafkaConfigurationClient, - PrivateEndpointConnection: &privateEndpointConnectionClient, - PrivateLinkResource: &privateLinkResourceClient, - Provider: &providerClient, - Usages: &usagesClient, + usagesClient, err := usages.NewUsagesClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Usages client: %+v", err) } + configureFunc(usagesClient.Client) + + return &Client{ + Account: accountClient, + DefaultAccount: defaultAccountClient, + Feature: featureClient, + KafkaConfiguration: kafkaConfigurationClient, + PrivateEndpointConnection: privateEndpointConnectionClient, + PrivateLinkResource: privateLinkResourceClient, + Provider: providerClient, + Usages: usagesClient, + }, nil } diff --git a/resource-manager/purview/2021-12-01/defaultaccount/client.go b/resource-manager/purview/2021-12-01/defaultaccount/client.go index 2c5f4fe4ff3..300c0482164 100644 --- a/resource-manager/purview/2021-12-01/defaultaccount/client.go +++ b/resource-manager/purview/2021-12-01/defaultaccount/client.go @@ -1,18 +1,26 @@ package defaultaccount -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 DefaultAccountClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewDefaultAccountClientWithBaseURI(endpoint string) DefaultAccountClient { - return DefaultAccountClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewDefaultAccountClientWithBaseURI(api environments.Api) (*DefaultAccountClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "defaultaccount", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DefaultAccountClient: %+v", err) } + + return &DefaultAccountClient{ + Client: client, + }, nil } diff --git a/resource-manager/purview/2021-12-01/defaultaccount/constants.go b/resource-manager/purview/2021-12-01/defaultaccount/constants.go index 4770bf67690..dfc7edafa25 100644 --- a/resource-manager/purview/2021-12-01/defaultaccount/constants.go +++ b/resource-manager/purview/2021-12-01/defaultaccount/constants.go @@ -1,6 +1,10 @@ package defaultaccount -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. @@ -19,6 +23,19 @@ func PossibleValuesForScopeType() []string { } } +func (s *ScopeType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseScopeType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseScopeType(input string) (*ScopeType, error) { vals := map[string]ScopeType{ "subscription": ScopeTypeSubscription, diff --git a/resource-manager/purview/2021-12-01/defaultaccount/method_get.go b/resource-manager/purview/2021-12-01/defaultaccount/method_get.go new file mode 100644 index 00000000000..770d7671ee3 --- /dev/null +++ b/resource-manager/purview/2021-12-01/defaultaccount/method_get.go @@ -0,0 +1,88 @@ +package defaultaccount + +import ( + "context" + "fmt" + "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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DefaultAccountPayload +} + +type GetOperationOptions struct { + Scope *string + ScopeTenantId *string + ScopeType *ScopeType +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Scope != nil { + out.Append("scope", fmt.Sprintf("%v", *o.Scope)) + } + if o.ScopeTenantId != nil { + out.Append("scopeTenantId", fmt.Sprintf("%v", *o.ScopeTenantId)) + } + if o.ScopeType != nil { + out.Append("scopeType", fmt.Sprintf("%v", *o.ScopeType)) + } + return &out +} + +// Get ... +func (c DefaultAccountClient) Get(ctx context.Context, options GetOperationOptions) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: "/providers/Microsoft.Purview/getDefaultAccount", + OptionsObject: options, + } + + 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 +} diff --git a/resource-manager/purview/2021-12-01/defaultaccount/method_get_autorest.go b/resource-manager/purview/2021-12-01/defaultaccount/method_get_autorest.go deleted file mode 100644 index 48907862a09..00000000000 --- a/resource-manager/purview/2021-12-01/defaultaccount/method_get_autorest.go +++ /dev/null @@ -1,107 +0,0 @@ -package defaultaccount - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *DefaultAccountPayload -} - -type GetOperationOptions struct { - Scope *string - ScopeTenantId *string - ScopeType *ScopeType -} - -func DefaultGetOperationOptions() GetOperationOptions { - return GetOperationOptions{} -} - -func (o GetOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o GetOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Scope != nil { - out["scope"] = *o.Scope - } - - if o.ScopeTenantId != nil { - out["scopeTenantId"] = *o.ScopeTenantId - } - - if o.ScopeType != nil { - out["scopeType"] = *o.ScopeType - } - - return out -} - -// Get ... -func (c DefaultAccountClient) Get(ctx context.Context, options GetOperationOptions) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, options) - if err != nil { - err = autorest.NewErrorWithError(err, "defaultaccount.DefaultAccountClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "defaultaccount.DefaultAccountClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "defaultaccount.DefaultAccountClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c DefaultAccountClient) preparerForGet(ctx context.Context, options GetOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath("/providers/Microsoft.Purview/getDefaultAccount"), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c DefaultAccountClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/purview/2021-12-01/defaultaccount/method_remove.go b/resource-manager/purview/2021-12-01/defaultaccount/method_remove.go new file mode 100644 index 00000000000..70c644483e1 --- /dev/null +++ b/resource-manager/purview/2021-12-01/defaultaccount/method_remove.go @@ -0,0 +1,84 @@ +package defaultaccount + +import ( + "context" + "fmt" + "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 RemoveOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type RemoveOperationOptions struct { + Scope *string + ScopeTenantId *string + ScopeType *ScopeType +} + +func DefaultRemoveOperationOptions() RemoveOperationOptions { + return RemoveOperationOptions{} +} + +func (o RemoveOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o RemoveOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o RemoveOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Scope != nil { + out.Append("scope", fmt.Sprintf("%v", *o.Scope)) + } + if o.ScopeTenantId != nil { + out.Append("scopeTenantId", fmt.Sprintf("%v", *o.ScopeTenantId)) + } + if o.ScopeType != nil { + out.Append("scopeType", fmt.Sprintf("%v", *o.ScopeType)) + } + return &out +} + +// Remove ... +func (c DefaultAccountClient) Remove(ctx context.Context, options RemoveOperationOptions) (result RemoveOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: "/providers/Microsoft.Purview/removeDefaultAccount", + OptionsObject: options, + } + + 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 + } + + return +} diff --git a/resource-manager/purview/2021-12-01/defaultaccount/method_remove_autorest.go b/resource-manager/purview/2021-12-01/defaultaccount/method_remove_autorest.go deleted file mode 100644 index 7b576dbaff3..00000000000 --- a/resource-manager/purview/2021-12-01/defaultaccount/method_remove_autorest.go +++ /dev/null @@ -1,105 +0,0 @@ -package defaultaccount - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type RemoveOperationResponse struct { - HttpResponse *http.Response -} - -type RemoveOperationOptions struct { - Scope *string - ScopeTenantId *string - ScopeType *ScopeType -} - -func DefaultRemoveOperationOptions() RemoveOperationOptions { - return RemoveOperationOptions{} -} - -func (o RemoveOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o RemoveOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Scope != nil { - out["scope"] = *o.Scope - } - - if o.ScopeTenantId != nil { - out["scopeTenantId"] = *o.ScopeTenantId - } - - if o.ScopeType != nil { - out["scopeType"] = *o.ScopeType - } - - return out -} - -// Remove ... -func (c DefaultAccountClient) Remove(ctx context.Context, options RemoveOperationOptions) (result RemoveOperationResponse, err error) { - req, err := c.preparerForRemove(ctx, options) - if err != nil { - err = autorest.NewErrorWithError(err, "defaultaccount.DefaultAccountClient", "Remove", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "defaultaccount.DefaultAccountClient", "Remove", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForRemove(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "defaultaccount.DefaultAccountClient", "Remove", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForRemove prepares the Remove request. -func (c DefaultAccountClient) preparerForRemove(ctx context.Context, options RemoveOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath("/providers/Microsoft.Purview/removeDefaultAccount"), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForRemove handles the response to the Remove request. The method always -// closes the http.Response Body. -func (c DefaultAccountClient) responderForRemove(resp *http.Response) (result RemoveOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/purview/2021-12-01/defaultaccount/method_set.go b/resource-manager/purview/2021-12-01/defaultaccount/method_set.go new file mode 100644 index 00000000000..2b59ecf925f --- /dev/null +++ b/resource-manager/purview/2021-12-01/defaultaccount/method_set.go @@ -0,0 +1,55 @@ +package defaultaccount + +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 SetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DefaultAccountPayload +} + +// Set ... +func (c DefaultAccountClient) Set(ctx context.Context, input DefaultAccountPayload) (result SetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: "/providers/Microsoft.Purview/setDefaultAccount", + } + + 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 +} diff --git a/resource-manager/purview/2021-12-01/defaultaccount/method_set_autorest.go b/resource-manager/purview/2021-12-01/defaultaccount/method_set_autorest.go deleted file mode 100644 index 0f9d49510b8..00000000000 --- a/resource-manager/purview/2021-12-01/defaultaccount/method_set_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package defaultaccount - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type SetOperationResponse struct { - HttpResponse *http.Response - Model *DefaultAccountPayload -} - -// Set ... -func (c DefaultAccountClient) Set(ctx context.Context, input DefaultAccountPayload) (result SetOperationResponse, err error) { - req, err := c.preparerForSet(ctx, input) - if err != nil { - err = autorest.NewErrorWithError(err, "defaultaccount.DefaultAccountClient", "Set", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "defaultaccount.DefaultAccountClient", "Set", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForSet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "defaultaccount.DefaultAccountClient", "Set", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForSet prepares the Set request. -func (c DefaultAccountClient) preparerForSet(ctx context.Context, input DefaultAccountPayload) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath("/providers/Microsoft.Purview/setDefaultAccount"), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForSet handles the response to the Set request. The method always -// closes the http.Response Body. -func (c DefaultAccountClient) responderForSet(resp *http.Response) (result SetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/purview/2021-12-01/feature/client.go b/resource-manager/purview/2021-12-01/feature/client.go index 4c3e4802044..7626a9f7d85 100644 --- a/resource-manager/purview/2021-12-01/feature/client.go +++ b/resource-manager/purview/2021-12-01/feature/client.go @@ -1,18 +1,26 @@ package feature -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 FeatureClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewFeatureClientWithBaseURI(endpoint string) FeatureClient { - return FeatureClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewFeatureClientWithBaseURI(api environments.Api) (*FeatureClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "feature", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating FeatureClient: %+v", err) } + + return &FeatureClient{ + Client: client, + }, nil } diff --git a/resource-manager/purview/2021-12-01/feature/method_accountget.go b/resource-manager/purview/2021-12-01/feature/method_accountget.go new file mode 100644 index 00000000000..c67d89a3468 --- /dev/null +++ b/resource-manager/purview/2021-12-01/feature/method_accountget.go @@ -0,0 +1,56 @@ +package feature + +import ( + "context" + "fmt" + "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 AccountGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BatchFeatureStatus +} + +// AccountGet ... +func (c FeatureClient) AccountGet(ctx context.Context, id AccountId, input BatchFeatureRequest) (result AccountGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listFeatures", 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 +} diff --git a/resource-manager/purview/2021-12-01/feature/method_accountget_autorest.go b/resource-manager/purview/2021-12-01/feature/method_accountget_autorest.go deleted file mode 100644 index 7b1d2d931e3..00000000000 --- a/resource-manager/purview/2021-12-01/feature/method_accountget_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package feature - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type AccountGetOperationResponse struct { - HttpResponse *http.Response - Model *BatchFeatureStatus -} - -// AccountGet ... -func (c FeatureClient) AccountGet(ctx context.Context, id AccountId, input BatchFeatureRequest) (result AccountGetOperationResponse, err error) { - req, err := c.preparerForAccountGet(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "feature.FeatureClient", "AccountGet", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "feature.FeatureClient", "AccountGet", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForAccountGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "feature.FeatureClient", "AccountGet", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForAccountGet prepares the AccountGet request. -func (c FeatureClient) preparerForAccountGet(ctx context.Context, id AccountId, input BatchFeatureRequest) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/listFeatures", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForAccountGet handles the response to the AccountGet request. The method always -// closes the http.Response Body. -func (c FeatureClient) responderForAccountGet(resp *http.Response) (result AccountGetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/purview/2021-12-01/feature/method_subscriptionget.go b/resource-manager/purview/2021-12-01/feature/method_subscriptionget.go new file mode 100644 index 00000000000..18dfe4c11bb --- /dev/null +++ b/resource-manager/purview/2021-12-01/feature/method_subscriptionget.go @@ -0,0 +1,56 @@ +package feature + +import ( + "context" + "fmt" + "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 SubscriptionGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BatchFeatureStatus +} + +// SubscriptionGet ... +func (c FeatureClient) SubscriptionGet(ctx context.Context, id LocationId, input BatchFeatureRequest) (result SubscriptionGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listFeatures", 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 +} diff --git a/resource-manager/purview/2021-12-01/feature/method_subscriptionget_autorest.go b/resource-manager/purview/2021-12-01/feature/method_subscriptionget_autorest.go deleted file mode 100644 index 676db699c80..00000000000 --- a/resource-manager/purview/2021-12-01/feature/method_subscriptionget_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package feature - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type SubscriptionGetOperationResponse struct { - HttpResponse *http.Response - Model *BatchFeatureStatus -} - -// SubscriptionGet ... -func (c FeatureClient) SubscriptionGet(ctx context.Context, id LocationId, input BatchFeatureRequest) (result SubscriptionGetOperationResponse, err error) { - req, err := c.preparerForSubscriptionGet(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "feature.FeatureClient", "SubscriptionGet", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "feature.FeatureClient", "SubscriptionGet", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForSubscriptionGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "feature.FeatureClient", "SubscriptionGet", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForSubscriptionGet prepares the SubscriptionGet request. -func (c FeatureClient) preparerForSubscriptionGet(ctx context.Context, id LocationId, input BatchFeatureRequest) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/listFeatures", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForSubscriptionGet handles the response to the SubscriptionGet request. The method always -// closes the http.Response Body. -func (c FeatureClient) responderForSubscriptionGet(resp *http.Response) (result SubscriptionGetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/purview/2021-12-01/kafkaconfiguration/client.go b/resource-manager/purview/2021-12-01/kafkaconfiguration/client.go index e0e1241f417..40d1b958a90 100644 --- a/resource-manager/purview/2021-12-01/kafkaconfiguration/client.go +++ b/resource-manager/purview/2021-12-01/kafkaconfiguration/client.go @@ -1,18 +1,26 @@ package kafkaconfiguration -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 KafkaConfigurationClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewKafkaConfigurationClientWithBaseURI(endpoint string) KafkaConfigurationClient { - return KafkaConfigurationClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewKafkaConfigurationClientWithBaseURI(api environments.Api) (*KafkaConfigurationClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "kafkaconfiguration", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating KafkaConfigurationClient: %+v", err) } + + return &KafkaConfigurationClient{ + Client: client, + }, nil } diff --git a/resource-manager/purview/2021-12-01/kafkaconfiguration/constants.go b/resource-manager/purview/2021-12-01/kafkaconfiguration/constants.go index b8c08663f49..6b20e432f89 100644 --- a/resource-manager/purview/2021-12-01/kafkaconfiguration/constants.go +++ b/resource-manager/purview/2021-12-01/kafkaconfiguration/constants.go @@ -1,6 +1,10 @@ package kafkaconfiguration -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. @@ -21,6 +25,19 @@ func PossibleValuesForCredentialsType() []string { } } +func (s *CredentialsType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCredentialsType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseCredentialsType(input string) (*CredentialsType, error) { vals := map[string]CredentialsType{ "none": CredentialsTypeNone, @@ -50,6 +67,19 @@ func PossibleValuesForEventHubType() []string { } } +func (s *EventHubType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEventHubType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseEventHubType(input string) (*EventHubType, error) { vals := map[string]EventHubType{ "hook": EventHubTypeHook, @@ -78,6 +108,19 @@ func PossibleValuesForEventStreamingState() []string { } } +func (s *EventStreamingState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEventStreamingState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseEventStreamingState(input string) (*EventStreamingState, error) { vals := map[string]EventStreamingState{ "disabled": EventStreamingStateDisabled, @@ -108,6 +151,19 @@ func PossibleValuesForEventStreamingType() []string { } } +func (s *EventStreamingType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEventStreamingType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseEventStreamingType(input string) (*EventStreamingType, error) { vals := map[string]EventStreamingType{ "azure": EventStreamingTypeAzure, diff --git a/resource-manager/purview/2021-12-01/kafkaconfiguration/method_createorupdate.go b/resource-manager/purview/2021-12-01/kafkaconfiguration/method_createorupdate.go new file mode 100644 index 00000000000..c406e9fb945 --- /dev/null +++ b/resource-manager/purview/2021-12-01/kafkaconfiguration/method_createorupdate.go @@ -0,0 +1,56 @@ +package kafkaconfiguration + +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 *KafkaConfiguration +} + +// CreateOrUpdate ... +func (c KafkaConfigurationClient) CreateOrUpdate(ctx context.Context, id KafkaConfigurationId, input KafkaConfiguration) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 +} diff --git a/resource-manager/purview/2021-12-01/kafkaconfiguration/method_createorupdate_autorest.go b/resource-manager/purview/2021-12-01/kafkaconfiguration/method_createorupdate_autorest.go deleted file mode 100644 index 6914cb712a9..00000000000 --- a/resource-manager/purview/2021-12-01/kafkaconfiguration/method_createorupdate_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package kafkaconfiguration - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// 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 - Model *KafkaConfiguration -} - -// CreateOrUpdate ... -func (c KafkaConfigurationClient) CreateOrUpdate(ctx context.Context, id KafkaConfigurationId, input KafkaConfiguration) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "kafkaconfiguration.KafkaConfigurationClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "kafkaconfiguration.KafkaConfigurationClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "kafkaconfiguration.KafkaConfigurationClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c KafkaConfigurationClient) preparerForCreateOrUpdate(ctx context.Context, id KafkaConfigurationId, input KafkaConfiguration) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateOrUpdate handles the response to the CreateOrUpdate request. The method always -// closes the http.Response Body. -func (c KafkaConfigurationClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/purview/2021-12-01/kafkaconfiguration/method_delete.go b/resource-manager/purview/2021-12-01/kafkaconfiguration/method_delete.go new file mode 100644 index 00000000000..d268bd35880 --- /dev/null +++ b/resource-manager/purview/2021-12-01/kafkaconfiguration/method_delete.go @@ -0,0 +1,47 @@ +package kafkaconfiguration + +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 +} + +// Delete ... +func (c KafkaConfigurationClient) Delete(ctx context.Context, id KafkaConfigurationId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 + } + + return +} diff --git a/resource-manager/purview/2021-12-01/kafkaconfiguration/method_delete_autorest.go b/resource-manager/purview/2021-12-01/kafkaconfiguration/method_delete_autorest.go deleted file mode 100644 index 4a3927bbd78..00000000000 --- a/resource-manager/purview/2021-12-01/kafkaconfiguration/method_delete_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package kafkaconfiguration - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// 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 -} - -// Delete ... -func (c KafkaConfigurationClient) Delete(ctx context.Context, id KafkaConfigurationId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "kafkaconfiguration.KafkaConfigurationClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "kafkaconfiguration.KafkaConfigurationClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "kafkaconfiguration.KafkaConfigurationClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c KafkaConfigurationClient) preparerForDelete(ctx context.Context, id KafkaConfigurationId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c KafkaConfigurationClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/purview/2021-12-01/kafkaconfiguration/method_get.go b/resource-manager/purview/2021-12-01/kafkaconfiguration/method_get.go new file mode 100644 index 00000000000..21934676b0b --- /dev/null +++ b/resource-manager/purview/2021-12-01/kafkaconfiguration/method_get.go @@ -0,0 +1,51 @@ +package kafkaconfiguration + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *KafkaConfiguration +} + +// Get ... +func (c KafkaConfigurationClient) Get(ctx context.Context, id KafkaConfigurationId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/purview/2021-12-01/kafkaconfiguration/method_get_autorest.go b/resource-manager/purview/2021-12-01/kafkaconfiguration/method_get_autorest.go deleted file mode 100644 index 7117df4fd84..00000000000 --- a/resource-manager/purview/2021-12-01/kafkaconfiguration/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package kafkaconfiguration - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *KafkaConfiguration -} - -// Get ... -func (c KafkaConfigurationClient) Get(ctx context.Context, id KafkaConfigurationId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "kafkaconfiguration.KafkaConfigurationClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "kafkaconfiguration.KafkaConfigurationClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "kafkaconfiguration.KafkaConfigurationClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c KafkaConfigurationClient) preparerForGet(ctx context.Context, id KafkaConfigurationId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c KafkaConfigurationClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/purview/2021-12-01/kafkaconfiguration/method_listbyaccount.go b/resource-manager/purview/2021-12-01/kafkaconfiguration/method_listbyaccount.go new file mode 100644 index 00000000000..e2fa6021c81 --- /dev/null +++ b/resource-manager/purview/2021-12-01/kafkaconfiguration/method_listbyaccount.go @@ -0,0 +1,89 @@ +package kafkaconfiguration + +import ( + "context" + "fmt" + "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 ListByAccountOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]KafkaConfiguration +} + +type ListByAccountCompleteResult struct { + Items []KafkaConfiguration +} + +// ListByAccount ... +func (c KafkaConfigurationClient) ListByAccount(ctx context.Context, id AccountId) (result ListByAccountOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/kafkaConfigurations", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]KafkaConfiguration `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByAccountComplete retrieves all the results into a single object +func (c KafkaConfigurationClient) ListByAccountComplete(ctx context.Context, id AccountId) (ListByAccountCompleteResult, error) { + return c.ListByAccountCompleteMatchingPredicate(ctx, id, KafkaConfigurationOperationPredicate{}) +} + +// ListByAccountCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c KafkaConfigurationClient) ListByAccountCompleteMatchingPredicate(ctx context.Context, id AccountId, predicate KafkaConfigurationOperationPredicate) (result ListByAccountCompleteResult, err error) { + items := make([]KafkaConfiguration, 0) + + resp, err := c.ListByAccount(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByAccountCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/purview/2021-12-01/kafkaconfiguration/method_listbyaccount_autorest.go b/resource-manager/purview/2021-12-01/kafkaconfiguration/method_listbyaccount_autorest.go deleted file mode 100644 index 2925473d0f7..00000000000 --- a/resource-manager/purview/2021-12-01/kafkaconfiguration/method_listbyaccount_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package kafkaconfiguration - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByAccountOperationResponse struct { - HttpResponse *http.Response - Model *[]KafkaConfiguration - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByAccountOperationResponse, error) -} - -type ListByAccountCompleteResult struct { - Items []KafkaConfiguration -} - -func (r ListByAccountOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByAccountOperationResponse) LoadMore(ctx context.Context) (resp ListByAccountOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByAccount ... -func (c KafkaConfigurationClient) ListByAccount(ctx context.Context, id AccountId) (resp ListByAccountOperationResponse, err error) { - req, err := c.preparerForListByAccount(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "kafkaconfiguration.KafkaConfigurationClient", "ListByAccount", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "kafkaconfiguration.KafkaConfigurationClient", "ListByAccount", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByAccount(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "kafkaconfiguration.KafkaConfigurationClient", "ListByAccount", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByAccount prepares the ListByAccount request. -func (c KafkaConfigurationClient) preparerForListByAccount(ctx context.Context, id AccountId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/kafkaConfigurations", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByAccountWithNextLink prepares the ListByAccount request with the given nextLink token. -func (c KafkaConfigurationClient) preparerForListByAccountWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByAccount handles the response to the ListByAccount request. The method always -// closes the http.Response Body. -func (c KafkaConfigurationClient) responderForListByAccount(resp *http.Response) (result ListByAccountOperationResponse, err error) { - type page struct { - Values []KafkaConfiguration `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByAccountOperationResponse, err error) { - req, err := c.preparerForListByAccountWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "kafkaconfiguration.KafkaConfigurationClient", "ListByAccount", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "kafkaconfiguration.KafkaConfigurationClient", "ListByAccount", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByAccount(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "kafkaconfiguration.KafkaConfigurationClient", "ListByAccount", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByAccountComplete retrieves all of the results into a single object -func (c KafkaConfigurationClient) ListByAccountComplete(ctx context.Context, id AccountId) (ListByAccountCompleteResult, error) { - return c.ListByAccountCompleteMatchingPredicate(ctx, id, KafkaConfigurationOperationPredicate{}) -} - -// ListByAccountCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c KafkaConfigurationClient) ListByAccountCompleteMatchingPredicate(ctx context.Context, id AccountId, predicate KafkaConfigurationOperationPredicate) (resp ListByAccountCompleteResult, err error) { - items := make([]KafkaConfiguration, 0) - - page, err := c.ListByAccount(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByAccountCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/purview/2021-12-01/privateendpointconnection/client.go b/resource-manager/purview/2021-12-01/privateendpointconnection/client.go index 6acd77b913c..35dcdf8567e 100644 --- a/resource-manager/purview/2021-12-01/privateendpointconnection/client.go +++ b/resource-manager/purview/2021-12-01/privateendpointconnection/client.go @@ -1,18 +1,26 @@ package privateendpointconnection -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 PrivateEndpointConnectionClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewPrivateEndpointConnectionClientWithBaseURI(endpoint string) PrivateEndpointConnectionClient { - return PrivateEndpointConnectionClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewPrivateEndpointConnectionClientWithBaseURI(api environments.Api) (*PrivateEndpointConnectionClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "privateendpointconnection", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PrivateEndpointConnectionClient: %+v", err) } + + return &PrivateEndpointConnectionClient{ + Client: client, + }, nil } diff --git a/resource-manager/purview/2021-12-01/privateendpointconnection/constants.go b/resource-manager/purview/2021-12-01/privateendpointconnection/constants.go index 8770979fb06..f8607655548 100644 --- a/resource-manager/purview/2021-12-01/privateendpointconnection/constants.go +++ b/resource-manager/purview/2021-12-01/privateendpointconnection/constants.go @@ -1,6 +1,10 @@ package privateendpointconnection -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. @@ -25,6 +29,19 @@ func PossibleValuesForStatus() []string { } } +func (s *Status) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseStatus(input string) (*Status, error) { vals := map[string]Status{ "approved": StatusApproved, diff --git a/resource-manager/purview/2021-12-01/privateendpointconnection/method_createorupdate.go b/resource-manager/purview/2021-12-01/privateendpointconnection/method_createorupdate.go new file mode 100644 index 00000000000..7150d8817e5 --- /dev/null +++ b/resource-manager/purview/2021-12-01/privateendpointconnection/method_createorupdate.go @@ -0,0 +1,74 @@ +package privateendpointconnection + +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 +} + +// CreateOrUpdate ... +func (c PrivateEndpointConnectionClient) CreateOrUpdate(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 PrivateEndpointConnectionClient) CreateOrUpdateThenPoll(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) 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 +} diff --git a/resource-manager/purview/2021-12-01/privateendpointconnection/method_createorupdate_autorest.go b/resource-manager/purview/2021-12-01/privateendpointconnection/method_createorupdate_autorest.go deleted file mode 100644 index abf3a7f285d..00000000000 --- a/resource-manager/purview/2021-12-01/privateendpointconnection/method_createorupdate_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package privateendpointconnection - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateOrUpdate ... -func (c PrivateEndpointConnectionClient) CreateOrUpdate(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnection.PrivateEndpointConnectionClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnection.PrivateEndpointConnectionClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c PrivateEndpointConnectionClient) CreateOrUpdateThenPoll(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) error { - result, err := c.CreateOrUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateOrUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateOrUpdate: %+v", err) - } - - return nil -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c PrivateEndpointConnectionClient) preparerForCreateOrUpdate(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateOrUpdate sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c PrivateEndpointConnectionClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/purview/2021-12-01/privateendpointconnection/method_delete.go b/resource-manager/purview/2021-12-01/privateendpointconnection/method_delete.go new file mode 100644 index 00000000000..5d6e8694951 --- /dev/null +++ b/resource-manager/purview/2021-12-01/privateendpointconnection/method_delete.go @@ -0,0 +1,71 @@ +package privateendpointconnection + +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 PrivateEndpointConnectionClient) Delete(ctx context.Context, id PrivateEndpointConnectionId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 PrivateEndpointConnectionClient) DeleteThenPoll(ctx context.Context, id PrivateEndpointConnectionId) 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 +} diff --git a/resource-manager/purview/2021-12-01/privateendpointconnection/method_delete_autorest.go b/resource-manager/purview/2021-12-01/privateendpointconnection/method_delete_autorest.go deleted file mode 100644 index 7e8532d71b7..00000000000 --- a/resource-manager/purview/2021-12-01/privateendpointconnection/method_delete_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package privateendpointconnection - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// Delete ... -func (c PrivateEndpointConnectionClient) Delete(ctx context.Context, id PrivateEndpointConnectionId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnection.PrivateEndpointConnectionClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnection.PrivateEndpointConnectionClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c PrivateEndpointConnectionClient) DeleteThenPoll(ctx context.Context, id PrivateEndpointConnectionId) error { - result, err := c.Delete(ctx, id) - if err != nil { - return fmt.Errorf("performing Delete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Delete: %+v", err) - } - - return nil -} - -// preparerForDelete prepares the Delete request. -func (c PrivateEndpointConnectionClient) preparerForDelete(ctx context.Context, id PrivateEndpointConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDelete sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (c PrivateEndpointConnectionClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/purview/2021-12-01/privateendpointconnection/method_get.go b/resource-manager/purview/2021-12-01/privateendpointconnection/method_get.go new file mode 100644 index 00000000000..d6ba3b220ac --- /dev/null +++ b/resource-manager/purview/2021-12-01/privateendpointconnection/method_get.go @@ -0,0 +1,51 @@ +package privateendpointconnection + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateEndpointConnection +} + +// Get ... +func (c PrivateEndpointConnectionClient) Get(ctx context.Context, id PrivateEndpointConnectionId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/purview/2021-12-01/privateendpointconnection/method_get_autorest.go b/resource-manager/purview/2021-12-01/privateendpointconnection/method_get_autorest.go deleted file mode 100644 index 51fcf2168f7..00000000000 --- a/resource-manager/purview/2021-12-01/privateendpointconnection/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package privateendpointconnection - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *PrivateEndpointConnection -} - -// Get ... -func (c PrivateEndpointConnectionClient) Get(ctx context.Context, id PrivateEndpointConnectionId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnection.PrivateEndpointConnectionClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnection.PrivateEndpointConnectionClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnection.PrivateEndpointConnectionClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c PrivateEndpointConnectionClient) preparerForGet(ctx context.Context, id PrivateEndpointConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c PrivateEndpointConnectionClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/purview/2021-12-01/privateendpointconnection/method_listbyaccount.go b/resource-manager/purview/2021-12-01/privateendpointconnection/method_listbyaccount.go new file mode 100644 index 00000000000..060b85abb2b --- /dev/null +++ b/resource-manager/purview/2021-12-01/privateendpointconnection/method_listbyaccount.go @@ -0,0 +1,89 @@ +package privateendpointconnection + +import ( + "context" + "fmt" + "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 ListByAccountOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PrivateEndpointConnection +} + +type ListByAccountCompleteResult struct { + Items []PrivateEndpointConnection +} + +// ListByAccount ... +func (c PrivateEndpointConnectionClient) ListByAccount(ctx context.Context, id AccountId) (result ListByAccountOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateEndpointConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PrivateEndpointConnection `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByAccountComplete retrieves all the results into a single object +func (c PrivateEndpointConnectionClient) ListByAccountComplete(ctx context.Context, id AccountId) (ListByAccountCompleteResult, error) { + return c.ListByAccountCompleteMatchingPredicate(ctx, id, PrivateEndpointConnectionOperationPredicate{}) +} + +// ListByAccountCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PrivateEndpointConnectionClient) ListByAccountCompleteMatchingPredicate(ctx context.Context, id AccountId, predicate PrivateEndpointConnectionOperationPredicate) (result ListByAccountCompleteResult, err error) { + items := make([]PrivateEndpointConnection, 0) + + resp, err := c.ListByAccount(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByAccountCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/purview/2021-12-01/privateendpointconnection/method_listbyaccount_autorest.go b/resource-manager/purview/2021-12-01/privateendpointconnection/method_listbyaccount_autorest.go deleted file mode 100644 index b92bf6f6478..00000000000 --- a/resource-manager/purview/2021-12-01/privateendpointconnection/method_listbyaccount_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package privateendpointconnection - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByAccountOperationResponse struct { - HttpResponse *http.Response - Model *[]PrivateEndpointConnection - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByAccountOperationResponse, error) -} - -type ListByAccountCompleteResult struct { - Items []PrivateEndpointConnection -} - -func (r ListByAccountOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByAccountOperationResponse) LoadMore(ctx context.Context) (resp ListByAccountOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByAccount ... -func (c PrivateEndpointConnectionClient) ListByAccount(ctx context.Context, id AccountId) (resp ListByAccountOperationResponse, err error) { - req, err := c.preparerForListByAccount(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnection.PrivateEndpointConnectionClient", "ListByAccount", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnection.PrivateEndpointConnectionClient", "ListByAccount", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByAccount(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnection.PrivateEndpointConnectionClient", "ListByAccount", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByAccount prepares the ListByAccount request. -func (c PrivateEndpointConnectionClient) preparerForListByAccount(ctx context.Context, id AccountId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/privateEndpointConnections", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByAccountWithNextLink prepares the ListByAccount request with the given nextLink token. -func (c PrivateEndpointConnectionClient) preparerForListByAccountWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByAccount handles the response to the ListByAccount request. The method always -// closes the http.Response Body. -func (c PrivateEndpointConnectionClient) responderForListByAccount(resp *http.Response) (result ListByAccountOperationResponse, err error) { - type page struct { - Values []PrivateEndpointConnection `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByAccountOperationResponse, err error) { - req, err := c.preparerForListByAccountWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnection.PrivateEndpointConnectionClient", "ListByAccount", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnection.PrivateEndpointConnectionClient", "ListByAccount", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByAccount(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privateendpointconnection.PrivateEndpointConnectionClient", "ListByAccount", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByAccountComplete retrieves all of the results into a single object -func (c PrivateEndpointConnectionClient) ListByAccountComplete(ctx context.Context, id AccountId) (ListByAccountCompleteResult, error) { - return c.ListByAccountCompleteMatchingPredicate(ctx, id, PrivateEndpointConnectionOperationPredicate{}) -} - -// ListByAccountCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c PrivateEndpointConnectionClient) ListByAccountCompleteMatchingPredicate(ctx context.Context, id AccountId, predicate PrivateEndpointConnectionOperationPredicate) (resp ListByAccountCompleteResult, err error) { - items := make([]PrivateEndpointConnection, 0) - - page, err := c.ListByAccount(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByAccountCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/purview/2021-12-01/privatelinkresource/client.go b/resource-manager/purview/2021-12-01/privatelinkresource/client.go index 439ab784f90..1caf7195e24 100644 --- a/resource-manager/purview/2021-12-01/privatelinkresource/client.go +++ b/resource-manager/purview/2021-12-01/privatelinkresource/client.go @@ -1,18 +1,26 @@ package privatelinkresource -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 PrivateLinkResourceClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewPrivateLinkResourceClientWithBaseURI(endpoint string) PrivateLinkResourceClient { - return PrivateLinkResourceClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewPrivateLinkResourceClientWithBaseURI(api environments.Api) (*PrivateLinkResourceClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "privatelinkresource", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PrivateLinkResourceClient: %+v", err) } + + return &PrivateLinkResourceClient{ + Client: client, + }, nil } diff --git a/resource-manager/purview/2021-12-01/privatelinkresource/method_getbygroupid.go b/resource-manager/purview/2021-12-01/privatelinkresource/method_getbygroupid.go new file mode 100644 index 00000000000..8aa0a1060a4 --- /dev/null +++ b/resource-manager/purview/2021-12-01/privatelinkresource/method_getbygroupid.go @@ -0,0 +1,51 @@ +package privatelinkresource + +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 GetByGroupIdOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateLinkResource +} + +// GetByGroupId ... +func (c PrivateLinkResourceClient) GetByGroupId(ctx context.Context, id PrivateLinkResourceId) (result GetByGroupIdOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/purview/2021-12-01/privatelinkresource/method_getbygroupid_autorest.go b/resource-manager/purview/2021-12-01/privatelinkresource/method_getbygroupid_autorest.go deleted file mode 100644 index f5239a4fa3c..00000000000 --- a/resource-manager/purview/2021-12-01/privatelinkresource/method_getbygroupid_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package privatelinkresource - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetByGroupIdOperationResponse struct { - HttpResponse *http.Response - Model *PrivateLinkResource -} - -// GetByGroupId ... -func (c PrivateLinkResourceClient) GetByGroupId(ctx context.Context, id PrivateLinkResourceId) (result GetByGroupIdOperationResponse, err error) { - req, err := c.preparerForGetByGroupId(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresource.PrivateLinkResourceClient", "GetByGroupId", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresource.PrivateLinkResourceClient", "GetByGroupId", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetByGroupId(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresource.PrivateLinkResourceClient", "GetByGroupId", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetByGroupId prepares the GetByGroupId request. -func (c PrivateLinkResourceClient) preparerForGetByGroupId(ctx context.Context, id PrivateLinkResourceId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetByGroupId handles the response to the GetByGroupId request. The method always -// closes the http.Response Body. -func (c PrivateLinkResourceClient) responderForGetByGroupId(resp *http.Response) (result GetByGroupIdOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/purview/2021-12-01/privatelinkresource/method_listbyaccount.go b/resource-manager/purview/2021-12-01/privatelinkresource/method_listbyaccount.go new file mode 100644 index 00000000000..0a9a11b82bb --- /dev/null +++ b/resource-manager/purview/2021-12-01/privatelinkresource/method_listbyaccount.go @@ -0,0 +1,89 @@ +package privatelinkresource + +import ( + "context" + "fmt" + "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 ListByAccountOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PrivateLinkResource +} + +type ListByAccountCompleteResult struct { + Items []PrivateLinkResource +} + +// ListByAccount ... +func (c PrivateLinkResourceClient) ListByAccount(ctx context.Context, id AccountId) (result ListByAccountOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateLinkResources", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PrivateLinkResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByAccountComplete retrieves all the results into a single object +func (c PrivateLinkResourceClient) ListByAccountComplete(ctx context.Context, id AccountId) (ListByAccountCompleteResult, error) { + return c.ListByAccountCompleteMatchingPredicate(ctx, id, PrivateLinkResourceOperationPredicate{}) +} + +// ListByAccountCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PrivateLinkResourceClient) ListByAccountCompleteMatchingPredicate(ctx context.Context, id AccountId, predicate PrivateLinkResourceOperationPredicate) (result ListByAccountCompleteResult, err error) { + items := make([]PrivateLinkResource, 0) + + resp, err := c.ListByAccount(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByAccountCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/purview/2021-12-01/privatelinkresource/method_listbyaccount_autorest.go b/resource-manager/purview/2021-12-01/privatelinkresource/method_listbyaccount_autorest.go deleted file mode 100644 index 3babe69ad81..00000000000 --- a/resource-manager/purview/2021-12-01/privatelinkresource/method_listbyaccount_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package privatelinkresource - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByAccountOperationResponse struct { - HttpResponse *http.Response - Model *[]PrivateLinkResource - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByAccountOperationResponse, error) -} - -type ListByAccountCompleteResult struct { - Items []PrivateLinkResource -} - -func (r ListByAccountOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByAccountOperationResponse) LoadMore(ctx context.Context) (resp ListByAccountOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByAccount ... -func (c PrivateLinkResourceClient) ListByAccount(ctx context.Context, id AccountId) (resp ListByAccountOperationResponse, err error) { - req, err := c.preparerForListByAccount(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresource.PrivateLinkResourceClient", "ListByAccount", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresource.PrivateLinkResourceClient", "ListByAccount", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByAccount(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresource.PrivateLinkResourceClient", "ListByAccount", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByAccount prepares the ListByAccount request. -func (c PrivateLinkResourceClient) preparerForListByAccount(ctx context.Context, id AccountId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/privateLinkResources", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByAccountWithNextLink prepares the ListByAccount request with the given nextLink token. -func (c PrivateLinkResourceClient) preparerForListByAccountWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByAccount handles the response to the ListByAccount request. The method always -// closes the http.Response Body. -func (c PrivateLinkResourceClient) responderForListByAccount(resp *http.Response) (result ListByAccountOperationResponse, err error) { - type page struct { - Values []PrivateLinkResource `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByAccountOperationResponse, err error) { - req, err := c.preparerForListByAccountWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresource.PrivateLinkResourceClient", "ListByAccount", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresource.PrivateLinkResourceClient", "ListByAccount", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByAccount(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "privatelinkresource.PrivateLinkResourceClient", "ListByAccount", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByAccountComplete retrieves all of the results into a single object -func (c PrivateLinkResourceClient) ListByAccountComplete(ctx context.Context, id AccountId) (ListByAccountCompleteResult, error) { - return c.ListByAccountCompleteMatchingPredicate(ctx, id, PrivateLinkResourceOperationPredicate{}) -} - -// ListByAccountCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c PrivateLinkResourceClient) ListByAccountCompleteMatchingPredicate(ctx context.Context, id AccountId, predicate PrivateLinkResourceOperationPredicate) (resp ListByAccountCompleteResult, err error) { - items := make([]PrivateLinkResource, 0) - - page, err := c.ListByAccount(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByAccountCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/purview/2021-12-01/provider/client.go b/resource-manager/purview/2021-12-01/provider/client.go index bb6bd224461..d4c5b5c24aa 100644 --- a/resource-manager/purview/2021-12-01/provider/client.go +++ b/resource-manager/purview/2021-12-01/provider/client.go @@ -1,18 +1,26 @@ package provider -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 ProviderClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewProviderClientWithBaseURI(endpoint string) ProviderClient { - return ProviderClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewProviderClientWithBaseURI(api environments.Api) (*ProviderClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "provider", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ProviderClient: %+v", err) } + + return &ProviderClient{ + Client: client, + }, nil } diff --git a/resource-manager/purview/2021-12-01/provider/constants.go b/resource-manager/purview/2021-12-01/provider/constants.go index e5b1c1cbb53..f513d82cb19 100644 --- a/resource-manager/purview/2021-12-01/provider/constants.go +++ b/resource-manager/purview/2021-12-01/provider/constants.go @@ -1,6 +1,10 @@ package provider -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. @@ -19,6 +23,19 @@ func PossibleValuesForReason() []string { } } +func (s *Reason) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseReason(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseReason(input string) (*Reason, error) { vals := map[string]Reason{ "alreadyexists": ReasonAlreadyExists, diff --git a/resource-manager/purview/2021-12-01/provider/method_accountschecknameavailability.go b/resource-manager/purview/2021-12-01/provider/method_accountschecknameavailability.go new file mode 100644 index 00000000000..ae947923fa6 --- /dev/null +++ b/resource-manager/purview/2021-12-01/provider/method_accountschecknameavailability.go @@ -0,0 +1,57 @@ +package provider + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 AccountsCheckNameAvailabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CheckNameAvailabilityResult +} + +// AccountsCheckNameAvailability ... +func (c ProviderClient) AccountsCheckNameAvailability(ctx context.Context, id commonids.SubscriptionId, input CheckNameAvailabilityRequest) (result AccountsCheckNameAvailabilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.Purview/checkNameAvailability", 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 +} diff --git a/resource-manager/purview/2021-12-01/provider/method_accountschecknameavailability_autorest.go b/resource-manager/purview/2021-12-01/provider/method_accountschecknameavailability_autorest.go deleted file mode 100644 index 176fbed450a..00000000000 --- a/resource-manager/purview/2021-12-01/provider/method_accountschecknameavailability_autorest.go +++ /dev/null @@ -1,71 +0,0 @@ -package provider - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type AccountsCheckNameAvailabilityOperationResponse struct { - HttpResponse *http.Response - Model *CheckNameAvailabilityResult -} - -// AccountsCheckNameAvailability ... -func (c ProviderClient) AccountsCheckNameAvailability(ctx context.Context, id commonids.SubscriptionId, input CheckNameAvailabilityRequest) (result AccountsCheckNameAvailabilityOperationResponse, err error) { - req, err := c.preparerForAccountsCheckNameAvailability(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "provider.ProviderClient", "AccountsCheckNameAvailability", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "provider.ProviderClient", "AccountsCheckNameAvailability", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForAccountsCheckNameAvailability(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "provider.ProviderClient", "AccountsCheckNameAvailability", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForAccountsCheckNameAvailability prepares the AccountsCheckNameAvailability request. -func (c ProviderClient) preparerForAccountsCheckNameAvailability(ctx context.Context, id commonids.SubscriptionId, input CheckNameAvailabilityRequest) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Purview/checkNameAvailability", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForAccountsCheckNameAvailability handles the response to the AccountsCheckNameAvailability request. The method always -// closes the http.Response Body. -func (c ProviderClient) responderForAccountsCheckNameAvailability(resp *http.Response) (result AccountsCheckNameAvailabilityOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/purview/2021-12-01/usages/client.go b/resource-manager/purview/2021-12-01/usages/client.go index 1609a46eca9..99b2625224d 100644 --- a/resource-manager/purview/2021-12-01/usages/client.go +++ b/resource-manager/purview/2021-12-01/usages/client.go @@ -1,18 +1,26 @@ package usages -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 UsagesClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewUsagesClientWithBaseURI(endpoint string) UsagesClient { - return UsagesClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewUsagesClientWithBaseURI(api environments.Api) (*UsagesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "usages", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating UsagesClient: %+v", err) } + + return &UsagesClient{ + Client: client, + }, nil } diff --git a/resource-manager/purview/2021-12-01/usages/method_get.go b/resource-manager/purview/2021-12-01/usages/method_get.go new file mode 100644 index 00000000000..04471c991b0 --- /dev/null +++ b/resource-manager/purview/2021-12-01/usages/method_get.go @@ -0,0 +1,80 @@ +package usages + +import ( + "context" + "fmt" + "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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *UsageList +} + +type GetOperationOptions struct { + Filter *string +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +// Get ... +func (c UsagesClient) Get(ctx context.Context, id LocationId, options GetOperationOptions) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/usages", id.ID()), + OptionsObject: options, + } + + 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 +} diff --git a/resource-manager/purview/2021-12-01/usages/method_get_autorest.go b/resource-manager/purview/2021-12-01/usages/method_get_autorest.go deleted file mode 100644 index 9892fe02821..00000000000 --- a/resource-manager/purview/2021-12-01/usages/method_get_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package usages - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *UsageList -} - -type GetOperationOptions struct { - Filter *string -} - -func DefaultGetOperationOptions() GetOperationOptions { - return GetOperationOptions{} -} - -func (o GetOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o GetOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - return out -} - -// Get ... -func (c UsagesClient) Get(ctx context.Context, id LocationId, options GetOperationOptions) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "usages.UsagesClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "usages.UsagesClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "usages.UsagesClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c UsagesClient) preparerForGet(ctx context.Context, id LocationId, options GetOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/usages", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c UsagesClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/relay/2017-04-01/client.go b/resource-manager/relay/2017-04-01/client.go index 3ed8bcad10a..05b3b802e85 100644 --- a/resource-manager/relay/2017-04-01/client.go +++ b/resource-manager/relay/2017-04-01/client.go @@ -4,10 +4,13 @@ package v2017_04_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/relay/2017-04-01/hybridconnections" "github.com/hashicorp/go-azure-sdk/resource-manager/relay/2017-04-01/namespaces" "github.com/hashicorp/go-azure-sdk/resource-manager/relay/2017-04-01/wcfrelays" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/environments" ) type Client struct { @@ -16,20 +19,28 @@ type Client struct { WCFRelays *wcfrelays.WCFRelaysClient } -func NewClientWithBaseURI(endpoint string, configureAuthFunc func(c *autorest.Client)) Client { - - hybridConnectionsClient := hybridconnections.NewHybridConnectionsClientWithBaseURI(endpoint) - configureAuthFunc(&hybridConnectionsClient.Client) - - namespacesClient := namespaces.NewNamespacesClientWithBaseURI(endpoint) - configureAuthFunc(&namespacesClient.Client) +func NewClientWithBaseURI(api environments.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + hybridConnectionsClient, err := hybridconnections.NewHybridConnectionsClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building HybridConnections client: %+v", err) + } + configureFunc(hybridConnectionsClient.Client) - wCFRelaysClient := wcfrelays.NewWCFRelaysClientWithBaseURI(endpoint) - configureAuthFunc(&wCFRelaysClient.Client) + namespacesClient, err := namespaces.NewNamespacesClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Namespaces client: %+v", err) + } + configureFunc(namespacesClient.Client) - return Client{ - HybridConnections: &hybridConnectionsClient, - Namespaces: &namespacesClient, - WCFRelays: &wCFRelaysClient, + wCFRelaysClient, err := wcfrelays.NewWCFRelaysClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building WCFRelays client: %+v", err) } + configureFunc(wCFRelaysClient.Client) + + return &Client{ + HybridConnections: hybridConnectionsClient, + Namespaces: namespacesClient, + WCFRelays: wCFRelaysClient, + }, nil } diff --git a/resource-manager/relay/2017-04-01/hybridconnections/client.go b/resource-manager/relay/2017-04-01/hybridconnections/client.go index b2529360ef3..03aa13b066b 100644 --- a/resource-manager/relay/2017-04-01/hybridconnections/client.go +++ b/resource-manager/relay/2017-04-01/hybridconnections/client.go @@ -1,18 +1,26 @@ package hybridconnections -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 HybridConnectionsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewHybridConnectionsClientWithBaseURI(endpoint string) HybridConnectionsClient { - return HybridConnectionsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewHybridConnectionsClientWithBaseURI(api environments.Api) (*HybridConnectionsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "hybridconnections", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating HybridConnectionsClient: %+v", err) } + + return &HybridConnectionsClient{ + Client: client, + }, nil } diff --git a/resource-manager/relay/2017-04-01/hybridconnections/constants.go b/resource-manager/relay/2017-04-01/hybridconnections/constants.go index 356096a5c0c..e6f718014ba 100644 --- a/resource-manager/relay/2017-04-01/hybridconnections/constants.go +++ b/resource-manager/relay/2017-04-01/hybridconnections/constants.go @@ -1,6 +1,10 @@ package hybridconnections -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. @@ -21,6 +25,19 @@ func PossibleValuesForAccessRights() []string { } } +func (s *AccessRights) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAccessRights(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAccessRights(input string) (*AccessRights, error) { vals := map[string]AccessRights{ "listen": AccessRightsListen, @@ -50,6 +67,19 @@ func PossibleValuesForKeyType() []string { } } +func (s *KeyType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKeyType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseKeyType(input string) (*KeyType, error) { vals := map[string]KeyType{ "primarykey": KeyTypePrimaryKey, diff --git a/resource-manager/relay/2017-04-01/hybridconnections/method_createorupdate.go b/resource-manager/relay/2017-04-01/hybridconnections/method_createorupdate.go new file mode 100644 index 00000000000..7b429d3db2b --- /dev/null +++ b/resource-manager/relay/2017-04-01/hybridconnections/method_createorupdate.go @@ -0,0 +1,55 @@ +package hybridconnections + +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 *HybridConnection +} + +// CreateOrUpdate ... +func (c HybridConnectionsClient) CreateOrUpdate(ctx context.Context, id HybridConnectionId, input HybridConnection) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 +} diff --git a/resource-manager/relay/2017-04-01/hybridconnections/method_createorupdate_autorest.go b/resource-manager/relay/2017-04-01/hybridconnections/method_createorupdate_autorest.go deleted file mode 100644 index dfe8081b9f0..00000000000 --- a/resource-manager/relay/2017-04-01/hybridconnections/method_createorupdate_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package hybridconnections - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// 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 - Model *HybridConnection -} - -// CreateOrUpdate ... -func (c HybridConnectionsClient) CreateOrUpdate(ctx context.Context, id HybridConnectionId, input HybridConnection) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c HybridConnectionsClient) preparerForCreateOrUpdate(ctx context.Context, id HybridConnectionId, input HybridConnection) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateOrUpdate handles the response to the CreateOrUpdate request. The method always -// closes the http.Response Body. -func (c HybridConnectionsClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/relay/2017-04-01/hybridconnections/method_createorupdateauthorizationrule.go b/resource-manager/relay/2017-04-01/hybridconnections/method_createorupdateauthorizationrule.go new file mode 100644 index 00000000000..abdea041980 --- /dev/null +++ b/resource-manager/relay/2017-04-01/hybridconnections/method_createorupdateauthorizationrule.go @@ -0,0 +1,55 @@ +package hybridconnections + +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 CreateOrUpdateAuthorizationRuleOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AuthorizationRule +} + +// CreateOrUpdateAuthorizationRule ... +func (c HybridConnectionsClient) CreateOrUpdateAuthorizationRule(ctx context.Context, id HybridConnectionAuthorizationRuleId, input AuthorizationRule) (result CreateOrUpdateAuthorizationRuleOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 +} diff --git a/resource-manager/relay/2017-04-01/hybridconnections/method_createorupdateauthorizationrule_autorest.go b/resource-manager/relay/2017-04-01/hybridconnections/method_createorupdateauthorizationrule_autorest.go deleted file mode 100644 index 2eacea331e4..00000000000 --- a/resource-manager/relay/2017-04-01/hybridconnections/method_createorupdateauthorizationrule_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package hybridconnections - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateAuthorizationRuleOperationResponse struct { - HttpResponse *http.Response - Model *AuthorizationRule -} - -// CreateOrUpdateAuthorizationRule ... -func (c HybridConnectionsClient) CreateOrUpdateAuthorizationRule(ctx context.Context, id HybridConnectionAuthorizationRuleId, input AuthorizationRule) (result CreateOrUpdateAuthorizationRuleOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdateAuthorizationRule(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "CreateOrUpdateAuthorizationRule", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "CreateOrUpdateAuthorizationRule", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdateAuthorizationRule(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "CreateOrUpdateAuthorizationRule", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdateAuthorizationRule prepares the CreateOrUpdateAuthorizationRule request. -func (c HybridConnectionsClient) preparerForCreateOrUpdateAuthorizationRule(ctx context.Context, id HybridConnectionAuthorizationRuleId, input AuthorizationRule) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateOrUpdateAuthorizationRule handles the response to the CreateOrUpdateAuthorizationRule request. The method always -// closes the http.Response Body. -func (c HybridConnectionsClient) responderForCreateOrUpdateAuthorizationRule(resp *http.Response) (result CreateOrUpdateAuthorizationRuleOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/relay/2017-04-01/hybridconnections/method_delete.go b/resource-manager/relay/2017-04-01/hybridconnections/method_delete.go new file mode 100644 index 00000000000..530690502d9 --- /dev/null +++ b/resource-manager/relay/2017-04-01/hybridconnections/method_delete.go @@ -0,0 +1,47 @@ +package hybridconnections + +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 +} + +// Delete ... +func (c HybridConnectionsClient) Delete(ctx context.Context, id HybridConnectionId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 + } + + return +} diff --git a/resource-manager/relay/2017-04-01/hybridconnections/method_delete_autorest.go b/resource-manager/relay/2017-04-01/hybridconnections/method_delete_autorest.go deleted file mode 100644 index fed5efbc8c2..00000000000 --- a/resource-manager/relay/2017-04-01/hybridconnections/method_delete_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package hybridconnections - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// 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 -} - -// Delete ... -func (c HybridConnectionsClient) Delete(ctx context.Context, id HybridConnectionId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c HybridConnectionsClient) preparerForDelete(ctx context.Context, id HybridConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c HybridConnectionsClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/relay/2017-04-01/hybridconnections/method_deleteauthorizationrule.go b/resource-manager/relay/2017-04-01/hybridconnections/method_deleteauthorizationrule.go new file mode 100644 index 00000000000..0b011b062e9 --- /dev/null +++ b/resource-manager/relay/2017-04-01/hybridconnections/method_deleteauthorizationrule.go @@ -0,0 +1,47 @@ +package hybridconnections + +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 DeleteAuthorizationRuleOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteAuthorizationRule ... +func (c HybridConnectionsClient) DeleteAuthorizationRule(ctx context.Context, id HybridConnectionAuthorizationRuleId) (result DeleteAuthorizationRuleOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 + } + + return +} diff --git a/resource-manager/relay/2017-04-01/hybridconnections/method_deleteauthorizationrule_autorest.go b/resource-manager/relay/2017-04-01/hybridconnections/method_deleteauthorizationrule_autorest.go deleted file mode 100644 index d68bada1bd9..00000000000 --- a/resource-manager/relay/2017-04-01/hybridconnections/method_deleteauthorizationrule_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package hybridconnections - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteAuthorizationRuleOperationResponse struct { - HttpResponse *http.Response -} - -// DeleteAuthorizationRule ... -func (c HybridConnectionsClient) DeleteAuthorizationRule(ctx context.Context, id HybridConnectionAuthorizationRuleId) (result DeleteAuthorizationRuleOperationResponse, err error) { - req, err := c.preparerForDeleteAuthorizationRule(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "DeleteAuthorizationRule", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "DeleteAuthorizationRule", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeleteAuthorizationRule(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "DeleteAuthorizationRule", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeleteAuthorizationRule prepares the DeleteAuthorizationRule request. -func (c HybridConnectionsClient) preparerForDeleteAuthorizationRule(ctx context.Context, id HybridConnectionAuthorizationRuleId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeleteAuthorizationRule handles the response to the DeleteAuthorizationRule request. The method always -// closes the http.Response Body. -func (c HybridConnectionsClient) responderForDeleteAuthorizationRule(resp *http.Response) (result DeleteAuthorizationRuleOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/relay/2017-04-01/hybridconnections/method_get.go b/resource-manager/relay/2017-04-01/hybridconnections/method_get.go new file mode 100644 index 00000000000..5d7cf30b876 --- /dev/null +++ b/resource-manager/relay/2017-04-01/hybridconnections/method_get.go @@ -0,0 +1,51 @@ +package hybridconnections + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HybridConnection +} + +// Get ... +func (c HybridConnectionsClient) Get(ctx context.Context, id HybridConnectionId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/relay/2017-04-01/hybridconnections/method_get_autorest.go b/resource-manager/relay/2017-04-01/hybridconnections/method_get_autorest.go deleted file mode 100644 index e74e23ef7e3..00000000000 --- a/resource-manager/relay/2017-04-01/hybridconnections/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package hybridconnections - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *HybridConnection -} - -// Get ... -func (c HybridConnectionsClient) Get(ctx context.Context, id HybridConnectionId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c HybridConnectionsClient) preparerForGet(ctx context.Context, id HybridConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c HybridConnectionsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/relay/2017-04-01/hybridconnections/method_getauthorizationrule.go b/resource-manager/relay/2017-04-01/hybridconnections/method_getauthorizationrule.go new file mode 100644 index 00000000000..4990dc2a4c5 --- /dev/null +++ b/resource-manager/relay/2017-04-01/hybridconnections/method_getauthorizationrule.go @@ -0,0 +1,51 @@ +package hybridconnections + +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 GetAuthorizationRuleOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AuthorizationRule +} + +// GetAuthorizationRule ... +func (c HybridConnectionsClient) GetAuthorizationRule(ctx context.Context, id HybridConnectionAuthorizationRuleId) (result GetAuthorizationRuleOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/relay/2017-04-01/hybridconnections/method_getauthorizationrule_autorest.go b/resource-manager/relay/2017-04-01/hybridconnections/method_getauthorizationrule_autorest.go deleted file mode 100644 index 66dfe02f779..00000000000 --- a/resource-manager/relay/2017-04-01/hybridconnections/method_getauthorizationrule_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package hybridconnections - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetAuthorizationRuleOperationResponse struct { - HttpResponse *http.Response - Model *AuthorizationRule -} - -// GetAuthorizationRule ... -func (c HybridConnectionsClient) GetAuthorizationRule(ctx context.Context, id HybridConnectionAuthorizationRuleId) (result GetAuthorizationRuleOperationResponse, err error) { - req, err := c.preparerForGetAuthorizationRule(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "GetAuthorizationRule", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "GetAuthorizationRule", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetAuthorizationRule(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "GetAuthorizationRule", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetAuthorizationRule prepares the GetAuthorizationRule request. -func (c HybridConnectionsClient) preparerForGetAuthorizationRule(ctx context.Context, id HybridConnectionAuthorizationRuleId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetAuthorizationRule handles the response to the GetAuthorizationRule request. The method always -// closes the http.Response Body. -func (c HybridConnectionsClient) responderForGetAuthorizationRule(resp *http.Response) (result GetAuthorizationRuleOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/relay/2017-04-01/hybridconnections/method_listauthorizationrules.go b/resource-manager/relay/2017-04-01/hybridconnections/method_listauthorizationrules.go new file mode 100644 index 00000000000..935ea4bd140 --- /dev/null +++ b/resource-manager/relay/2017-04-01/hybridconnections/method_listauthorizationrules.go @@ -0,0 +1,89 @@ +package hybridconnections + +import ( + "context" + "fmt" + "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 ListAuthorizationRulesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AuthorizationRule +} + +type ListAuthorizationRulesCompleteResult struct { + Items []AuthorizationRule +} + +// ListAuthorizationRules ... +func (c HybridConnectionsClient) ListAuthorizationRules(ctx context.Context, id HybridConnectionId) (result ListAuthorizationRulesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/authorizationRules", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AuthorizationRule `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAuthorizationRulesComplete retrieves all the results into a single object +func (c HybridConnectionsClient) ListAuthorizationRulesComplete(ctx context.Context, id HybridConnectionId) (ListAuthorizationRulesCompleteResult, error) { + return c.ListAuthorizationRulesCompleteMatchingPredicate(ctx, id, AuthorizationRuleOperationPredicate{}) +} + +// ListAuthorizationRulesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c HybridConnectionsClient) ListAuthorizationRulesCompleteMatchingPredicate(ctx context.Context, id HybridConnectionId, predicate AuthorizationRuleOperationPredicate) (result ListAuthorizationRulesCompleteResult, err error) { + items := make([]AuthorizationRule, 0) + + resp, err := c.ListAuthorizationRules(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListAuthorizationRulesCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/relay/2017-04-01/hybridconnections/method_listauthorizationrules_autorest.go b/resource-manager/relay/2017-04-01/hybridconnections/method_listauthorizationrules_autorest.go deleted file mode 100644 index 23c40087266..00000000000 --- a/resource-manager/relay/2017-04-01/hybridconnections/method_listauthorizationrules_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package hybridconnections - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListAuthorizationRulesOperationResponse struct { - HttpResponse *http.Response - Model *[]AuthorizationRule - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListAuthorizationRulesOperationResponse, error) -} - -type ListAuthorizationRulesCompleteResult struct { - Items []AuthorizationRule -} - -func (r ListAuthorizationRulesOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListAuthorizationRulesOperationResponse) LoadMore(ctx context.Context) (resp ListAuthorizationRulesOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListAuthorizationRules ... -func (c HybridConnectionsClient) ListAuthorizationRules(ctx context.Context, id HybridConnectionId) (resp ListAuthorizationRulesOperationResponse, err error) { - req, err := c.preparerForListAuthorizationRules(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "ListAuthorizationRules", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "ListAuthorizationRules", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListAuthorizationRules(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "ListAuthorizationRules", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListAuthorizationRules prepares the ListAuthorizationRules request. -func (c HybridConnectionsClient) preparerForListAuthorizationRules(ctx context.Context, id HybridConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/authorizationRules", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListAuthorizationRulesWithNextLink prepares the ListAuthorizationRules request with the given nextLink token. -func (c HybridConnectionsClient) preparerForListAuthorizationRulesWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListAuthorizationRules handles the response to the ListAuthorizationRules request. The method always -// closes the http.Response Body. -func (c HybridConnectionsClient) responderForListAuthorizationRules(resp *http.Response) (result ListAuthorizationRulesOperationResponse, err error) { - type page struct { - Values []AuthorizationRule `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListAuthorizationRulesOperationResponse, err error) { - req, err := c.preparerForListAuthorizationRulesWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "ListAuthorizationRules", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "ListAuthorizationRules", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListAuthorizationRules(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "ListAuthorizationRules", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListAuthorizationRulesComplete retrieves all of the results into a single object -func (c HybridConnectionsClient) ListAuthorizationRulesComplete(ctx context.Context, id HybridConnectionId) (ListAuthorizationRulesCompleteResult, error) { - return c.ListAuthorizationRulesCompleteMatchingPredicate(ctx, id, AuthorizationRuleOperationPredicate{}) -} - -// ListAuthorizationRulesCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c HybridConnectionsClient) ListAuthorizationRulesCompleteMatchingPredicate(ctx context.Context, id HybridConnectionId, predicate AuthorizationRuleOperationPredicate) (resp ListAuthorizationRulesCompleteResult, err error) { - items := make([]AuthorizationRule, 0) - - page, err := c.ListAuthorizationRules(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListAuthorizationRulesCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/relay/2017-04-01/hybridconnections/method_listbynamespace.go b/resource-manager/relay/2017-04-01/hybridconnections/method_listbynamespace.go new file mode 100644 index 00000000000..93bf80ee2c0 --- /dev/null +++ b/resource-manager/relay/2017-04-01/hybridconnections/method_listbynamespace.go @@ -0,0 +1,89 @@ +package hybridconnections + +import ( + "context" + "fmt" + "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 ListByNamespaceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]HybridConnection +} + +type ListByNamespaceCompleteResult struct { + Items []HybridConnection +} + +// ListByNamespace ... +func (c HybridConnectionsClient) ListByNamespace(ctx context.Context, id NamespaceId) (result ListByNamespaceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/hybridConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]HybridConnection `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByNamespaceComplete retrieves all the results into a single object +func (c HybridConnectionsClient) ListByNamespaceComplete(ctx context.Context, id NamespaceId) (ListByNamespaceCompleteResult, error) { + return c.ListByNamespaceCompleteMatchingPredicate(ctx, id, HybridConnectionOperationPredicate{}) +} + +// ListByNamespaceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c HybridConnectionsClient) ListByNamespaceCompleteMatchingPredicate(ctx context.Context, id NamespaceId, predicate HybridConnectionOperationPredicate) (result ListByNamespaceCompleteResult, err error) { + items := make([]HybridConnection, 0) + + resp, err := c.ListByNamespace(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByNamespaceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/relay/2017-04-01/hybridconnections/method_listbynamespace_autorest.go b/resource-manager/relay/2017-04-01/hybridconnections/method_listbynamespace_autorest.go deleted file mode 100644 index 1062f8d85d5..00000000000 --- a/resource-manager/relay/2017-04-01/hybridconnections/method_listbynamespace_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package hybridconnections - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByNamespaceOperationResponse struct { - HttpResponse *http.Response - Model *[]HybridConnection - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByNamespaceOperationResponse, error) -} - -type ListByNamespaceCompleteResult struct { - Items []HybridConnection -} - -func (r ListByNamespaceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByNamespaceOperationResponse) LoadMore(ctx context.Context) (resp ListByNamespaceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByNamespace ... -func (c HybridConnectionsClient) ListByNamespace(ctx context.Context, id NamespaceId) (resp ListByNamespaceOperationResponse, err error) { - req, err := c.preparerForListByNamespace(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "ListByNamespace", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "ListByNamespace", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByNamespace(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "ListByNamespace", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByNamespace prepares the ListByNamespace request. -func (c HybridConnectionsClient) preparerForListByNamespace(ctx context.Context, id NamespaceId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/hybridConnections", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByNamespaceWithNextLink prepares the ListByNamespace request with the given nextLink token. -func (c HybridConnectionsClient) preparerForListByNamespaceWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByNamespace handles the response to the ListByNamespace request. The method always -// closes the http.Response Body. -func (c HybridConnectionsClient) responderForListByNamespace(resp *http.Response) (result ListByNamespaceOperationResponse, err error) { - type page struct { - Values []HybridConnection `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByNamespaceOperationResponse, err error) { - req, err := c.preparerForListByNamespaceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "ListByNamespace", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "ListByNamespace", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByNamespace(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "ListByNamespace", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByNamespaceComplete retrieves all of the results into a single object -func (c HybridConnectionsClient) ListByNamespaceComplete(ctx context.Context, id NamespaceId) (ListByNamespaceCompleteResult, error) { - return c.ListByNamespaceCompleteMatchingPredicate(ctx, id, HybridConnectionOperationPredicate{}) -} - -// ListByNamespaceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c HybridConnectionsClient) ListByNamespaceCompleteMatchingPredicate(ctx context.Context, id NamespaceId, predicate HybridConnectionOperationPredicate) (resp ListByNamespaceCompleteResult, err error) { - items := make([]HybridConnection, 0) - - page, err := c.ListByNamespace(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByNamespaceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/relay/2017-04-01/hybridconnections/method_listkeys.go b/resource-manager/relay/2017-04-01/hybridconnections/method_listkeys.go new file mode 100644 index 00000000000..2ac6bc956d8 --- /dev/null +++ b/resource-manager/relay/2017-04-01/hybridconnections/method_listkeys.go @@ -0,0 +1,52 @@ +package hybridconnections + +import ( + "context" + "fmt" + "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 ListKeysOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AccessKeys +} + +// ListKeys ... +func (c HybridConnectionsClient) ListKeys(ctx context.Context, id HybridConnectionAuthorizationRuleId) (result ListKeysOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listKeys", 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 +} diff --git a/resource-manager/relay/2017-04-01/hybridconnections/method_listkeys_autorest.go b/resource-manager/relay/2017-04-01/hybridconnections/method_listkeys_autorest.go deleted file mode 100644 index 2156a9c6838..00000000000 --- a/resource-manager/relay/2017-04-01/hybridconnections/method_listkeys_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package hybridconnections - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListKeysOperationResponse struct { - HttpResponse *http.Response - Model *AccessKeys -} - -// ListKeys ... -func (c HybridConnectionsClient) ListKeys(ctx context.Context, id HybridConnectionAuthorizationRuleId) (result ListKeysOperationResponse, err error) { - req, err := c.preparerForListKeys(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "ListKeys", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "ListKeys", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListKeys(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "ListKeys", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListKeys prepares the ListKeys request. -func (c HybridConnectionsClient) preparerForListKeys(ctx context.Context, id HybridConnectionAuthorizationRuleId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/listKeys", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListKeys handles the response to the ListKeys request. The method always -// closes the http.Response Body. -func (c HybridConnectionsClient) responderForListKeys(resp *http.Response) (result ListKeysOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/relay/2017-04-01/hybridconnections/method_regeneratekeys.go b/resource-manager/relay/2017-04-01/hybridconnections/method_regeneratekeys.go new file mode 100644 index 00000000000..942fa8b66d4 --- /dev/null +++ b/resource-manager/relay/2017-04-01/hybridconnections/method_regeneratekeys.go @@ -0,0 +1,56 @@ +package hybridconnections + +import ( + "context" + "fmt" + "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 RegenerateKeysOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AccessKeys +} + +// RegenerateKeys ... +func (c HybridConnectionsClient) RegenerateKeys(ctx context.Context, id HybridConnectionAuthorizationRuleId, input RegenerateAccessKeyParameters) (result RegenerateKeysOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/regenerateKeys", 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 +} diff --git a/resource-manager/relay/2017-04-01/hybridconnections/method_regeneratekeys_autorest.go b/resource-manager/relay/2017-04-01/hybridconnections/method_regeneratekeys_autorest.go deleted file mode 100644 index f036fe194c4..00000000000 --- a/resource-manager/relay/2017-04-01/hybridconnections/method_regeneratekeys_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package hybridconnections - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type RegenerateKeysOperationResponse struct { - HttpResponse *http.Response - Model *AccessKeys -} - -// RegenerateKeys ... -func (c HybridConnectionsClient) RegenerateKeys(ctx context.Context, id HybridConnectionAuthorizationRuleId, input RegenerateAccessKeyParameters) (result RegenerateKeysOperationResponse, err error) { - req, err := c.preparerForRegenerateKeys(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "RegenerateKeys", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "RegenerateKeys", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForRegenerateKeys(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "RegenerateKeys", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForRegenerateKeys prepares the RegenerateKeys request. -func (c HybridConnectionsClient) preparerForRegenerateKeys(ctx context.Context, id HybridConnectionAuthorizationRuleId, input RegenerateAccessKeyParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/regenerateKeys", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForRegenerateKeys handles the response to the RegenerateKeys request. The method always -// closes the http.Response Body. -func (c HybridConnectionsClient) responderForRegenerateKeys(resp *http.Response) (result RegenerateKeysOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/relay/2017-04-01/namespaces/client.go b/resource-manager/relay/2017-04-01/namespaces/client.go index bf25155c419..6b0ae358115 100644 --- a/resource-manager/relay/2017-04-01/namespaces/client.go +++ b/resource-manager/relay/2017-04-01/namespaces/client.go @@ -1,18 +1,26 @@ package namespaces -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 NamespacesClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewNamespacesClientWithBaseURI(endpoint string) NamespacesClient { - return NamespacesClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewNamespacesClientWithBaseURI(api environments.Api) (*NamespacesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "namespaces", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating NamespacesClient: %+v", err) } + + return &NamespacesClient{ + Client: client, + }, nil } diff --git a/resource-manager/relay/2017-04-01/namespaces/constants.go b/resource-manager/relay/2017-04-01/namespaces/constants.go index 4987e03c5d8..ca521a7d50c 100644 --- a/resource-manager/relay/2017-04-01/namespaces/constants.go +++ b/resource-manager/relay/2017-04-01/namespaces/constants.go @@ -1,6 +1,10 @@ package namespaces -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. @@ -21,6 +25,19 @@ func PossibleValuesForAccessRights() []string { } } +func (s *AccessRights) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAccessRights(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAccessRights(input string) (*AccessRights, error) { vals := map[string]AccessRights{ "listen": AccessRightsListen, @@ -50,6 +67,19 @@ func PossibleValuesForKeyType() []string { } } +func (s *KeyType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKeyType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseKeyType(input string) (*KeyType, error) { vals := map[string]KeyType{ "primarykey": KeyTypePrimaryKey, @@ -86,6 +116,19 @@ func PossibleValuesForProvisioningStateEnum() []string { } } +func (s *ProvisioningStateEnum) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningStateEnum(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseProvisioningStateEnum(input string) (*ProvisioningStateEnum, error) { vals := map[string]ProvisioningStateEnum{ "created": ProvisioningStateEnumCreated, @@ -116,6 +159,19 @@ func PossibleValuesForSkuName() []string { } } +func (s *SkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseSkuName(input string) (*SkuName, error) { vals := map[string]SkuName{ "standard": SkuNameStandard, @@ -141,6 +197,19 @@ func PossibleValuesForSkuTier() []string { } } +func (s *SkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseSkuTier(input string) (*SkuTier, error) { vals := map[string]SkuTier{ "standard": SkuTierStandard, @@ -176,6 +245,19 @@ func PossibleValuesForUnavailableReason() []string { } } +func (s *UnavailableReason) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUnavailableReason(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseUnavailableReason(input string) (*UnavailableReason, error) { vals := map[string]UnavailableReason{ "invalidname": UnavailableReasonInvalidName, diff --git a/resource-manager/relay/2017-04-01/namespaces/method_checknameavailability.go b/resource-manager/relay/2017-04-01/namespaces/method_checknameavailability.go new file mode 100644 index 00000000000..c59f7d2954e --- /dev/null +++ b/resource-manager/relay/2017-04-01/namespaces/method_checknameavailability.go @@ -0,0 +1,57 @@ +package namespaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 CheckNameAvailabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CheckNameAvailabilityResult +} + +// CheckNameAvailability ... +func (c NamespacesClient) CheckNameAvailability(ctx context.Context, id commonids.SubscriptionId, input CheckNameAvailability) (result CheckNameAvailabilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.Relay/checkNameAvailability", 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 +} diff --git a/resource-manager/relay/2017-04-01/namespaces/method_checknameavailability_autorest.go b/resource-manager/relay/2017-04-01/namespaces/method_checknameavailability_autorest.go deleted file mode 100644 index 67ba0ea69f0..00000000000 --- a/resource-manager/relay/2017-04-01/namespaces/method_checknameavailability_autorest.go +++ /dev/null @@ -1,71 +0,0 @@ -package namespaces - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CheckNameAvailabilityOperationResponse struct { - HttpResponse *http.Response - Model *CheckNameAvailabilityResult -} - -// CheckNameAvailability ... -func (c NamespacesClient) CheckNameAvailability(ctx context.Context, id commonids.SubscriptionId, input CheckNameAvailability) (result CheckNameAvailabilityOperationResponse, err error) { - req, err := c.preparerForCheckNameAvailability(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "CheckNameAvailability", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "CheckNameAvailability", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCheckNameAvailability(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "CheckNameAvailability", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCheckNameAvailability prepares the CheckNameAvailability request. -func (c NamespacesClient) preparerForCheckNameAvailability(ctx context.Context, id commonids.SubscriptionId, input CheckNameAvailability) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Relay/checkNameAvailability", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCheckNameAvailability handles the response to the CheckNameAvailability request. The method always -// closes the http.Response Body. -func (c NamespacesClient) responderForCheckNameAvailability(resp *http.Response) (result CheckNameAvailabilityOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/relay/2017-04-01/namespaces/method_createorupdate.go b/resource-manager/relay/2017-04-01/namespaces/method_createorupdate.go new file mode 100644 index 00000000000..7c31eb5e47f --- /dev/null +++ b/resource-manager/relay/2017-04-01/namespaces/method_createorupdate.go @@ -0,0 +1,74 @@ +package namespaces + +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 +} + +// CreateOrUpdate ... +func (c NamespacesClient) CreateOrUpdate(ctx context.Context, id NamespaceId, input RelayNamespace) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 NamespacesClient) CreateOrUpdateThenPoll(ctx context.Context, id NamespaceId, input RelayNamespace) 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 +} diff --git a/resource-manager/relay/2017-04-01/namespaces/method_createorupdate_autorest.go b/resource-manager/relay/2017-04-01/namespaces/method_createorupdate_autorest.go deleted file mode 100644 index 09581fdbbbf..00000000000 --- a/resource-manager/relay/2017-04-01/namespaces/method_createorupdate_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package namespaces - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateOrUpdate ... -func (c NamespacesClient) CreateOrUpdate(ctx context.Context, id NamespaceId, input RelayNamespace) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c NamespacesClient) CreateOrUpdateThenPoll(ctx context.Context, id NamespaceId, input RelayNamespace) error { - result, err := c.CreateOrUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateOrUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateOrUpdate: %+v", err) - } - - return nil -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c NamespacesClient) preparerForCreateOrUpdate(ctx context.Context, id NamespaceId, input RelayNamespace) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateOrUpdate sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c NamespacesClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/relay/2017-04-01/namespaces/method_createorupdateauthorizationrule.go b/resource-manager/relay/2017-04-01/namespaces/method_createorupdateauthorizationrule.go new file mode 100644 index 00000000000..d5427180484 --- /dev/null +++ b/resource-manager/relay/2017-04-01/namespaces/method_createorupdateauthorizationrule.go @@ -0,0 +1,55 @@ +package namespaces + +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 CreateOrUpdateAuthorizationRuleOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AuthorizationRule +} + +// CreateOrUpdateAuthorizationRule ... +func (c NamespacesClient) CreateOrUpdateAuthorizationRule(ctx context.Context, id AuthorizationRuleId, input AuthorizationRule) (result CreateOrUpdateAuthorizationRuleOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 +} diff --git a/resource-manager/relay/2017-04-01/namespaces/method_createorupdateauthorizationrule_autorest.go b/resource-manager/relay/2017-04-01/namespaces/method_createorupdateauthorizationrule_autorest.go deleted file mode 100644 index 427b471540d..00000000000 --- a/resource-manager/relay/2017-04-01/namespaces/method_createorupdateauthorizationrule_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package namespaces - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateAuthorizationRuleOperationResponse struct { - HttpResponse *http.Response - Model *AuthorizationRule -} - -// CreateOrUpdateAuthorizationRule ... -func (c NamespacesClient) CreateOrUpdateAuthorizationRule(ctx context.Context, id AuthorizationRuleId, input AuthorizationRule) (result CreateOrUpdateAuthorizationRuleOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdateAuthorizationRule(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "CreateOrUpdateAuthorizationRule", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "CreateOrUpdateAuthorizationRule", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdateAuthorizationRule(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "CreateOrUpdateAuthorizationRule", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdateAuthorizationRule prepares the CreateOrUpdateAuthorizationRule request. -func (c NamespacesClient) preparerForCreateOrUpdateAuthorizationRule(ctx context.Context, id AuthorizationRuleId, input AuthorizationRule) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateOrUpdateAuthorizationRule handles the response to the CreateOrUpdateAuthorizationRule request. The method always -// closes the http.Response Body. -func (c NamespacesClient) responderForCreateOrUpdateAuthorizationRule(resp *http.Response) (result CreateOrUpdateAuthorizationRuleOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/relay/2017-04-01/namespaces/method_delete.go b/resource-manager/relay/2017-04-01/namespaces/method_delete.go new file mode 100644 index 00000000000..e4aa04bb843 --- /dev/null +++ b/resource-manager/relay/2017-04-01/namespaces/method_delete.go @@ -0,0 +1,71 @@ +package namespaces + +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 NamespacesClient) Delete(ctx context.Context, id NamespaceId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 NamespacesClient) DeleteThenPoll(ctx context.Context, id NamespaceId) 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 +} diff --git a/resource-manager/relay/2017-04-01/namespaces/method_delete_autorest.go b/resource-manager/relay/2017-04-01/namespaces/method_delete_autorest.go deleted file mode 100644 index 968dfe754f2..00000000000 --- a/resource-manager/relay/2017-04-01/namespaces/method_delete_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package namespaces - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// Delete ... -func (c NamespacesClient) Delete(ctx context.Context, id NamespaceId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c NamespacesClient) DeleteThenPoll(ctx context.Context, id NamespaceId) error { - result, err := c.Delete(ctx, id) - if err != nil { - return fmt.Errorf("performing Delete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Delete: %+v", err) - } - - return nil -} - -// preparerForDelete prepares the Delete request. -func (c NamespacesClient) preparerForDelete(ctx context.Context, id NamespaceId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDelete sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (c NamespacesClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/relay/2017-04-01/namespaces/method_deleteauthorizationrule.go b/resource-manager/relay/2017-04-01/namespaces/method_deleteauthorizationrule.go new file mode 100644 index 00000000000..222c32eb344 --- /dev/null +++ b/resource-manager/relay/2017-04-01/namespaces/method_deleteauthorizationrule.go @@ -0,0 +1,47 @@ +package namespaces + +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 DeleteAuthorizationRuleOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteAuthorizationRule ... +func (c NamespacesClient) DeleteAuthorizationRule(ctx context.Context, id AuthorizationRuleId) (result DeleteAuthorizationRuleOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 + } + + return +} diff --git a/resource-manager/relay/2017-04-01/namespaces/method_deleteauthorizationrule_autorest.go b/resource-manager/relay/2017-04-01/namespaces/method_deleteauthorizationrule_autorest.go deleted file mode 100644 index 92336c4b4a0..00000000000 --- a/resource-manager/relay/2017-04-01/namespaces/method_deleteauthorizationrule_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package namespaces - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteAuthorizationRuleOperationResponse struct { - HttpResponse *http.Response -} - -// DeleteAuthorizationRule ... -func (c NamespacesClient) DeleteAuthorizationRule(ctx context.Context, id AuthorizationRuleId) (result DeleteAuthorizationRuleOperationResponse, err error) { - req, err := c.preparerForDeleteAuthorizationRule(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "DeleteAuthorizationRule", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "DeleteAuthorizationRule", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeleteAuthorizationRule(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "DeleteAuthorizationRule", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeleteAuthorizationRule prepares the DeleteAuthorizationRule request. -func (c NamespacesClient) preparerForDeleteAuthorizationRule(ctx context.Context, id AuthorizationRuleId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeleteAuthorizationRule handles the response to the DeleteAuthorizationRule request. The method always -// closes the http.Response Body. -func (c NamespacesClient) responderForDeleteAuthorizationRule(resp *http.Response) (result DeleteAuthorizationRuleOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/relay/2017-04-01/namespaces/method_get.go b/resource-manager/relay/2017-04-01/namespaces/method_get.go new file mode 100644 index 00000000000..df0c5cc36c6 --- /dev/null +++ b/resource-manager/relay/2017-04-01/namespaces/method_get.go @@ -0,0 +1,51 @@ +package namespaces + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RelayNamespace +} + +// Get ... +func (c NamespacesClient) Get(ctx context.Context, id NamespaceId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/relay/2017-04-01/namespaces/method_get_autorest.go b/resource-manager/relay/2017-04-01/namespaces/method_get_autorest.go deleted file mode 100644 index 1ab016389fc..00000000000 --- a/resource-manager/relay/2017-04-01/namespaces/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package namespaces - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *RelayNamespace -} - -// Get ... -func (c NamespacesClient) Get(ctx context.Context, id NamespaceId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c NamespacesClient) preparerForGet(ctx context.Context, id NamespaceId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c NamespacesClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/relay/2017-04-01/namespaces/method_getauthorizationrule.go b/resource-manager/relay/2017-04-01/namespaces/method_getauthorizationrule.go new file mode 100644 index 00000000000..ba8fbc1a27a --- /dev/null +++ b/resource-manager/relay/2017-04-01/namespaces/method_getauthorizationrule.go @@ -0,0 +1,51 @@ +package namespaces + +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 GetAuthorizationRuleOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AuthorizationRule +} + +// GetAuthorizationRule ... +func (c NamespacesClient) GetAuthorizationRule(ctx context.Context, id AuthorizationRuleId) (result GetAuthorizationRuleOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/relay/2017-04-01/namespaces/method_getauthorizationrule_autorest.go b/resource-manager/relay/2017-04-01/namespaces/method_getauthorizationrule_autorest.go deleted file mode 100644 index 24a7f00cb69..00000000000 --- a/resource-manager/relay/2017-04-01/namespaces/method_getauthorizationrule_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package namespaces - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetAuthorizationRuleOperationResponse struct { - HttpResponse *http.Response - Model *AuthorizationRule -} - -// GetAuthorizationRule ... -func (c NamespacesClient) GetAuthorizationRule(ctx context.Context, id AuthorizationRuleId) (result GetAuthorizationRuleOperationResponse, err error) { - req, err := c.preparerForGetAuthorizationRule(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "GetAuthorizationRule", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "GetAuthorizationRule", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetAuthorizationRule(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "GetAuthorizationRule", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetAuthorizationRule prepares the GetAuthorizationRule request. -func (c NamespacesClient) preparerForGetAuthorizationRule(ctx context.Context, id AuthorizationRuleId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetAuthorizationRule handles the response to the GetAuthorizationRule request. The method always -// closes the http.Response Body. -func (c NamespacesClient) responderForGetAuthorizationRule(resp *http.Response) (result GetAuthorizationRuleOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/relay/2017-04-01/namespaces/method_list.go b/resource-manager/relay/2017-04-01/namespaces/method_list.go new file mode 100644 index 00000000000..59b1a72af9c --- /dev/null +++ b/resource-manager/relay/2017-04-01/namespaces/method_list.go @@ -0,0 +1,90 @@ +package namespaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RelayNamespace +} + +type ListCompleteResult struct { + Items []RelayNamespace +} + +// List ... +func (c NamespacesClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Relay/namespaces", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]RelayNamespace `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c NamespacesClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, RelayNamespaceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NamespacesClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate RelayNamespaceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]RelayNamespace, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/relay/2017-04-01/namespaces/method_list_autorest.go b/resource-manager/relay/2017-04-01/namespaces/method_list_autorest.go deleted file mode 100644 index f5067719cee..00000000000 --- a/resource-manager/relay/2017-04-01/namespaces/method_list_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package namespaces - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListOperationResponse struct { - HttpResponse *http.Response - Model *[]RelayNamespace - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []RelayNamespace -} - -func (r ListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// List ... -func (c NamespacesClient) List(ctx context.Context, id commonids.SubscriptionId) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c NamespacesClient) preparerForList(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Relay/namespaces", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c NamespacesClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForList handles the response to the List request. The method always -// closes the http.Response Body. -func (c NamespacesClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []RelayNamespace `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { - req, err := c.preparerForListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c NamespacesClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, RelayNamespaceOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c NamespacesClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate RelayNamespaceOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]RelayNamespace, 0) - - page, err := c.List(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/relay/2017-04-01/namespaces/method_listauthorizationrules.go b/resource-manager/relay/2017-04-01/namespaces/method_listauthorizationrules.go new file mode 100644 index 00000000000..f040c69ed45 --- /dev/null +++ b/resource-manager/relay/2017-04-01/namespaces/method_listauthorizationrules.go @@ -0,0 +1,89 @@ +package namespaces + +import ( + "context" + "fmt" + "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 ListAuthorizationRulesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AuthorizationRule +} + +type ListAuthorizationRulesCompleteResult struct { + Items []AuthorizationRule +} + +// ListAuthorizationRules ... +func (c NamespacesClient) ListAuthorizationRules(ctx context.Context, id NamespaceId) (result ListAuthorizationRulesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/authorizationRules", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AuthorizationRule `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAuthorizationRulesComplete retrieves all the results into a single object +func (c NamespacesClient) ListAuthorizationRulesComplete(ctx context.Context, id NamespaceId) (ListAuthorizationRulesCompleteResult, error) { + return c.ListAuthorizationRulesCompleteMatchingPredicate(ctx, id, AuthorizationRuleOperationPredicate{}) +} + +// ListAuthorizationRulesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NamespacesClient) ListAuthorizationRulesCompleteMatchingPredicate(ctx context.Context, id NamespaceId, predicate AuthorizationRuleOperationPredicate) (result ListAuthorizationRulesCompleteResult, err error) { + items := make([]AuthorizationRule, 0) + + resp, err := c.ListAuthorizationRules(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListAuthorizationRulesCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/relay/2017-04-01/namespaces/method_listauthorizationrules_autorest.go b/resource-manager/relay/2017-04-01/namespaces/method_listauthorizationrules_autorest.go deleted file mode 100644 index 39e6b9d4eca..00000000000 --- a/resource-manager/relay/2017-04-01/namespaces/method_listauthorizationrules_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package namespaces - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListAuthorizationRulesOperationResponse struct { - HttpResponse *http.Response - Model *[]AuthorizationRule - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListAuthorizationRulesOperationResponse, error) -} - -type ListAuthorizationRulesCompleteResult struct { - Items []AuthorizationRule -} - -func (r ListAuthorizationRulesOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListAuthorizationRulesOperationResponse) LoadMore(ctx context.Context) (resp ListAuthorizationRulesOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListAuthorizationRules ... -func (c NamespacesClient) ListAuthorizationRules(ctx context.Context, id NamespaceId) (resp ListAuthorizationRulesOperationResponse, err error) { - req, err := c.preparerForListAuthorizationRules(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "ListAuthorizationRules", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "ListAuthorizationRules", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListAuthorizationRules(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "ListAuthorizationRules", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListAuthorizationRules prepares the ListAuthorizationRules request. -func (c NamespacesClient) preparerForListAuthorizationRules(ctx context.Context, id NamespaceId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/authorizationRules", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListAuthorizationRulesWithNextLink prepares the ListAuthorizationRules request with the given nextLink token. -func (c NamespacesClient) preparerForListAuthorizationRulesWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListAuthorizationRules handles the response to the ListAuthorizationRules request. The method always -// closes the http.Response Body. -func (c NamespacesClient) responderForListAuthorizationRules(resp *http.Response) (result ListAuthorizationRulesOperationResponse, err error) { - type page struct { - Values []AuthorizationRule `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListAuthorizationRulesOperationResponse, err error) { - req, err := c.preparerForListAuthorizationRulesWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "ListAuthorizationRules", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "ListAuthorizationRules", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListAuthorizationRules(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "ListAuthorizationRules", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListAuthorizationRulesComplete retrieves all of the results into a single object -func (c NamespacesClient) ListAuthorizationRulesComplete(ctx context.Context, id NamespaceId) (ListAuthorizationRulesCompleteResult, error) { - return c.ListAuthorizationRulesCompleteMatchingPredicate(ctx, id, AuthorizationRuleOperationPredicate{}) -} - -// ListAuthorizationRulesCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c NamespacesClient) ListAuthorizationRulesCompleteMatchingPredicate(ctx context.Context, id NamespaceId, predicate AuthorizationRuleOperationPredicate) (resp ListAuthorizationRulesCompleteResult, err error) { - items := make([]AuthorizationRule, 0) - - page, err := c.ListAuthorizationRules(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListAuthorizationRulesCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/relay/2017-04-01/namespaces/method_listbyresourcegroup.go b/resource-manager/relay/2017-04-01/namespaces/method_listbyresourcegroup.go new file mode 100644 index 00000000000..90ed4ad4844 --- /dev/null +++ b/resource-manager/relay/2017-04-01/namespaces/method_listbyresourcegroup.go @@ -0,0 +1,90 @@ +package namespaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RelayNamespace +} + +type ListByResourceGroupCompleteResult struct { + Items []RelayNamespace +} + +// ListByResourceGroup ... +func (c NamespacesClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Relay/namespaces", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]RelayNamespace `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c NamespacesClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, RelayNamespaceOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NamespacesClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate RelayNamespaceOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]RelayNamespace, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/relay/2017-04-01/namespaces/method_listbyresourcegroup_autorest.go b/resource-manager/relay/2017-04-01/namespaces/method_listbyresourcegroup_autorest.go deleted file mode 100644 index e1248f2d5aa..00000000000 --- a/resource-manager/relay/2017-04-01/namespaces/method_listbyresourcegroup_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package namespaces - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByResourceGroupOperationResponse struct { - HttpResponse *http.Response - Model *[]RelayNamespace - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByResourceGroupOperationResponse, error) -} - -type ListByResourceGroupCompleteResult struct { - Items []RelayNamespace -} - -func (r ListByResourceGroupOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByResourceGroupOperationResponse) LoadMore(ctx context.Context) (resp ListByResourceGroupOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByResourceGroup ... -func (c NamespacesClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (resp ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroup(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "ListByResourceGroup", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByResourceGroup(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "ListByResourceGroup", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByResourceGroup prepares the ListByResourceGroup request. -func (c NamespacesClient) preparerForListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Relay/namespaces", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByResourceGroupWithNextLink prepares the ListByResourceGroup request with the given nextLink token. -func (c NamespacesClient) preparerForListByResourceGroupWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByResourceGroup handles the response to the ListByResourceGroup request. The method always -// closes the http.Response Body. -func (c NamespacesClient) responderForListByResourceGroup(resp *http.Response) (result ListByResourceGroupOperationResponse, err error) { - type page struct { - Values []RelayNamespace `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroupWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "ListByResourceGroup", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByResourceGroup(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "ListByResourceGroup", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByResourceGroupComplete retrieves all of the results into a single object -func (c NamespacesClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { - return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, RelayNamespaceOperationPredicate{}) -} - -// ListByResourceGroupCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c NamespacesClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate RelayNamespaceOperationPredicate) (resp ListByResourceGroupCompleteResult, err error) { - items := make([]RelayNamespace, 0) - - page, err := c.ListByResourceGroup(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByResourceGroupCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/relay/2017-04-01/namespaces/method_listkeys.go b/resource-manager/relay/2017-04-01/namespaces/method_listkeys.go new file mode 100644 index 00000000000..4d4fc5509dd --- /dev/null +++ b/resource-manager/relay/2017-04-01/namespaces/method_listkeys.go @@ -0,0 +1,52 @@ +package namespaces + +import ( + "context" + "fmt" + "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 ListKeysOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AccessKeys +} + +// ListKeys ... +func (c NamespacesClient) ListKeys(ctx context.Context, id AuthorizationRuleId) (result ListKeysOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listKeys", 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 +} diff --git a/resource-manager/relay/2017-04-01/namespaces/method_listkeys_autorest.go b/resource-manager/relay/2017-04-01/namespaces/method_listkeys_autorest.go deleted file mode 100644 index 5dfd71ec198..00000000000 --- a/resource-manager/relay/2017-04-01/namespaces/method_listkeys_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package namespaces - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListKeysOperationResponse struct { - HttpResponse *http.Response - Model *AccessKeys -} - -// ListKeys ... -func (c NamespacesClient) ListKeys(ctx context.Context, id AuthorizationRuleId) (result ListKeysOperationResponse, err error) { - req, err := c.preparerForListKeys(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "ListKeys", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "ListKeys", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListKeys(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "ListKeys", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListKeys prepares the ListKeys request. -func (c NamespacesClient) preparerForListKeys(ctx context.Context, id AuthorizationRuleId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/listKeys", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListKeys handles the response to the ListKeys request. The method always -// closes the http.Response Body. -func (c NamespacesClient) responderForListKeys(resp *http.Response) (result ListKeysOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/relay/2017-04-01/namespaces/method_regeneratekeys.go b/resource-manager/relay/2017-04-01/namespaces/method_regeneratekeys.go new file mode 100644 index 00000000000..2f8667ac338 --- /dev/null +++ b/resource-manager/relay/2017-04-01/namespaces/method_regeneratekeys.go @@ -0,0 +1,56 @@ +package namespaces + +import ( + "context" + "fmt" + "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 RegenerateKeysOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AccessKeys +} + +// RegenerateKeys ... +func (c NamespacesClient) RegenerateKeys(ctx context.Context, id AuthorizationRuleId, input RegenerateAccessKeyParameters) (result RegenerateKeysOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/regenerateKeys", 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 +} diff --git a/resource-manager/relay/2017-04-01/namespaces/method_regeneratekeys_autorest.go b/resource-manager/relay/2017-04-01/namespaces/method_regeneratekeys_autorest.go deleted file mode 100644 index 4f9dd06f42a..00000000000 --- a/resource-manager/relay/2017-04-01/namespaces/method_regeneratekeys_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package namespaces - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type RegenerateKeysOperationResponse struct { - HttpResponse *http.Response - Model *AccessKeys -} - -// RegenerateKeys ... -func (c NamespacesClient) RegenerateKeys(ctx context.Context, id AuthorizationRuleId, input RegenerateAccessKeyParameters) (result RegenerateKeysOperationResponse, err error) { - req, err := c.preparerForRegenerateKeys(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "RegenerateKeys", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "RegenerateKeys", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForRegenerateKeys(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "RegenerateKeys", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForRegenerateKeys prepares the RegenerateKeys request. -func (c NamespacesClient) preparerForRegenerateKeys(ctx context.Context, id AuthorizationRuleId, input RegenerateAccessKeyParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/regenerateKeys", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForRegenerateKeys handles the response to the RegenerateKeys request. The method always -// closes the http.Response Body. -func (c NamespacesClient) responderForRegenerateKeys(resp *http.Response) (result RegenerateKeysOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/relay/2017-04-01/namespaces/method_update.go b/resource-manager/relay/2017-04-01/namespaces/method_update.go new file mode 100644 index 00000000000..4ffff26b5b3 --- /dev/null +++ b/resource-manager/relay/2017-04-01/namespaces/method_update.go @@ -0,0 +1,56 @@ +package namespaces + +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 UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RelayNamespace +} + +// Update ... +func (c NamespacesClient) Update(ctx context.Context, id NamespaceId, input RelayUpdateParameters) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + 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 +} diff --git a/resource-manager/relay/2017-04-01/namespaces/method_update_autorest.go b/resource-manager/relay/2017-04-01/namespaces/method_update_autorest.go deleted file mode 100644 index cf1ca8cfd12..00000000000 --- a/resource-manager/relay/2017-04-01/namespaces/method_update_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package namespaces - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateOperationResponse struct { - HttpResponse *http.Response - Model *RelayNamespace -} - -// Update ... -func (c NamespacesClient) Update(ctx context.Context, id NamespaceId, input RelayUpdateParameters) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c NamespacesClient) preparerForUpdate(ctx context.Context, id NamespaceId, input RelayUpdateParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdate handles the response to the Update request. The method always -// closes the http.Response Body. -func (c NamespacesClient) responderForUpdate(resp *http.Response) (result UpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/relay/2017-04-01/wcfrelays/client.go b/resource-manager/relay/2017-04-01/wcfrelays/client.go index 1f541cc4209..9e151c39a16 100644 --- a/resource-manager/relay/2017-04-01/wcfrelays/client.go +++ b/resource-manager/relay/2017-04-01/wcfrelays/client.go @@ -1,18 +1,26 @@ package wcfrelays -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 WCFRelaysClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewWCFRelaysClientWithBaseURI(endpoint string) WCFRelaysClient { - return WCFRelaysClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewWCFRelaysClientWithBaseURI(api environments.Api) (*WCFRelaysClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "wcfrelays", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating WCFRelaysClient: %+v", err) } + + return &WCFRelaysClient{ + Client: client, + }, nil } diff --git a/resource-manager/relay/2017-04-01/wcfrelays/constants.go b/resource-manager/relay/2017-04-01/wcfrelays/constants.go index aa1fc8c65ac..26a898b6bed 100644 --- a/resource-manager/relay/2017-04-01/wcfrelays/constants.go +++ b/resource-manager/relay/2017-04-01/wcfrelays/constants.go @@ -1,6 +1,10 @@ package wcfrelays -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. @@ -21,6 +25,19 @@ func PossibleValuesForAccessRights() []string { } } +func (s *AccessRights) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAccessRights(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAccessRights(input string) (*AccessRights, error) { vals := map[string]AccessRights{ "listen": AccessRightsListen, @@ -50,6 +67,19 @@ func PossibleValuesForKeyType() []string { } } +func (s *KeyType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKeyType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseKeyType(input string) (*KeyType, error) { vals := map[string]KeyType{ "primarykey": KeyTypePrimaryKey, @@ -78,6 +108,19 @@ func PossibleValuesForRelaytype() []string { } } +func (s *Relaytype) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRelaytype(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseRelaytype(input string) (*Relaytype, error) { vals := map[string]Relaytype{ "http": RelaytypeHTTP, diff --git a/resource-manager/relay/2017-04-01/wcfrelays/method_createorupdate.go b/resource-manager/relay/2017-04-01/wcfrelays/method_createorupdate.go new file mode 100644 index 00000000000..8a946521af8 --- /dev/null +++ b/resource-manager/relay/2017-04-01/wcfrelays/method_createorupdate.go @@ -0,0 +1,55 @@ +package wcfrelays + +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 *WcfRelay +} + +// CreateOrUpdate ... +func (c WCFRelaysClient) CreateOrUpdate(ctx context.Context, id WcfRelayId, input WcfRelay) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 +} diff --git a/resource-manager/relay/2017-04-01/wcfrelays/method_createorupdate_autorest.go b/resource-manager/relay/2017-04-01/wcfrelays/method_createorupdate_autorest.go deleted file mode 100644 index da043d6ead9..00000000000 --- a/resource-manager/relay/2017-04-01/wcfrelays/method_createorupdate_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package wcfrelays - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// 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 - Model *WcfRelay -} - -// CreateOrUpdate ... -func (c WCFRelaysClient) CreateOrUpdate(ctx context.Context, id WcfRelayId, input WcfRelay) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c WCFRelaysClient) preparerForCreateOrUpdate(ctx context.Context, id WcfRelayId, input WcfRelay) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateOrUpdate handles the response to the CreateOrUpdate request. The method always -// closes the http.Response Body. -func (c WCFRelaysClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/relay/2017-04-01/wcfrelays/method_createorupdateauthorizationrule.go b/resource-manager/relay/2017-04-01/wcfrelays/method_createorupdateauthorizationrule.go new file mode 100644 index 00000000000..2f4af0d3ef7 --- /dev/null +++ b/resource-manager/relay/2017-04-01/wcfrelays/method_createorupdateauthorizationrule.go @@ -0,0 +1,55 @@ +package wcfrelays + +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 CreateOrUpdateAuthorizationRuleOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AuthorizationRule +} + +// CreateOrUpdateAuthorizationRule ... +func (c WCFRelaysClient) CreateOrUpdateAuthorizationRule(ctx context.Context, id WcfRelayAuthorizationRuleId, input AuthorizationRule) (result CreateOrUpdateAuthorizationRuleOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 +} diff --git a/resource-manager/relay/2017-04-01/wcfrelays/method_createorupdateauthorizationrule_autorest.go b/resource-manager/relay/2017-04-01/wcfrelays/method_createorupdateauthorizationrule_autorest.go deleted file mode 100644 index e5dd5ac7b87..00000000000 --- a/resource-manager/relay/2017-04-01/wcfrelays/method_createorupdateauthorizationrule_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package wcfrelays - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateAuthorizationRuleOperationResponse struct { - HttpResponse *http.Response - Model *AuthorizationRule -} - -// CreateOrUpdateAuthorizationRule ... -func (c WCFRelaysClient) CreateOrUpdateAuthorizationRule(ctx context.Context, id WcfRelayAuthorizationRuleId, input AuthorizationRule) (result CreateOrUpdateAuthorizationRuleOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdateAuthorizationRule(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "CreateOrUpdateAuthorizationRule", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "CreateOrUpdateAuthorizationRule", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdateAuthorizationRule(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "CreateOrUpdateAuthorizationRule", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdateAuthorizationRule prepares the CreateOrUpdateAuthorizationRule request. -func (c WCFRelaysClient) preparerForCreateOrUpdateAuthorizationRule(ctx context.Context, id WcfRelayAuthorizationRuleId, input AuthorizationRule) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateOrUpdateAuthorizationRule handles the response to the CreateOrUpdateAuthorizationRule request. The method always -// closes the http.Response Body. -func (c WCFRelaysClient) responderForCreateOrUpdateAuthorizationRule(resp *http.Response) (result CreateOrUpdateAuthorizationRuleOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/relay/2017-04-01/wcfrelays/method_delete.go b/resource-manager/relay/2017-04-01/wcfrelays/method_delete.go new file mode 100644 index 00000000000..f99797d14b3 --- /dev/null +++ b/resource-manager/relay/2017-04-01/wcfrelays/method_delete.go @@ -0,0 +1,47 @@ +package wcfrelays + +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 +} + +// Delete ... +func (c WCFRelaysClient) Delete(ctx context.Context, id WcfRelayId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 + } + + return +} diff --git a/resource-manager/relay/2017-04-01/wcfrelays/method_delete_autorest.go b/resource-manager/relay/2017-04-01/wcfrelays/method_delete_autorest.go deleted file mode 100644 index 42146e0d6da..00000000000 --- a/resource-manager/relay/2017-04-01/wcfrelays/method_delete_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package wcfrelays - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// 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 -} - -// Delete ... -func (c WCFRelaysClient) Delete(ctx context.Context, id WcfRelayId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c WCFRelaysClient) preparerForDelete(ctx context.Context, id WcfRelayId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c WCFRelaysClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/relay/2017-04-01/wcfrelays/method_deleteauthorizationrule.go b/resource-manager/relay/2017-04-01/wcfrelays/method_deleteauthorizationrule.go new file mode 100644 index 00000000000..9a276f3d10a --- /dev/null +++ b/resource-manager/relay/2017-04-01/wcfrelays/method_deleteauthorizationrule.go @@ -0,0 +1,47 @@ +package wcfrelays + +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 DeleteAuthorizationRuleOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteAuthorizationRule ... +func (c WCFRelaysClient) DeleteAuthorizationRule(ctx context.Context, id WcfRelayAuthorizationRuleId) (result DeleteAuthorizationRuleOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 + } + + return +} diff --git a/resource-manager/relay/2017-04-01/wcfrelays/method_deleteauthorizationrule_autorest.go b/resource-manager/relay/2017-04-01/wcfrelays/method_deleteauthorizationrule_autorest.go deleted file mode 100644 index c222f387d35..00000000000 --- a/resource-manager/relay/2017-04-01/wcfrelays/method_deleteauthorizationrule_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package wcfrelays - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteAuthorizationRuleOperationResponse struct { - HttpResponse *http.Response -} - -// DeleteAuthorizationRule ... -func (c WCFRelaysClient) DeleteAuthorizationRule(ctx context.Context, id WcfRelayAuthorizationRuleId) (result DeleteAuthorizationRuleOperationResponse, err error) { - req, err := c.preparerForDeleteAuthorizationRule(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "DeleteAuthorizationRule", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "DeleteAuthorizationRule", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeleteAuthorizationRule(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "DeleteAuthorizationRule", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeleteAuthorizationRule prepares the DeleteAuthorizationRule request. -func (c WCFRelaysClient) preparerForDeleteAuthorizationRule(ctx context.Context, id WcfRelayAuthorizationRuleId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeleteAuthorizationRule handles the response to the DeleteAuthorizationRule request. The method always -// closes the http.Response Body. -func (c WCFRelaysClient) responderForDeleteAuthorizationRule(resp *http.Response) (result DeleteAuthorizationRuleOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/relay/2017-04-01/wcfrelays/method_get.go b/resource-manager/relay/2017-04-01/wcfrelays/method_get.go new file mode 100644 index 00000000000..a41520b6316 --- /dev/null +++ b/resource-manager/relay/2017-04-01/wcfrelays/method_get.go @@ -0,0 +1,52 @@ +package wcfrelays + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WcfRelay +} + +// Get ... +func (c WCFRelaysClient) Get(ctx context.Context, id WcfRelayId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/relay/2017-04-01/wcfrelays/method_get_autorest.go b/resource-manager/relay/2017-04-01/wcfrelays/method_get_autorest.go deleted file mode 100644 index b119542150f..00000000000 --- a/resource-manager/relay/2017-04-01/wcfrelays/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package wcfrelays - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *WcfRelay -} - -// Get ... -func (c WCFRelaysClient) Get(ctx context.Context, id WcfRelayId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c WCFRelaysClient) preparerForGet(ctx context.Context, id WcfRelayId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c WCFRelaysClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/relay/2017-04-01/wcfrelays/method_getauthorizationrule.go b/resource-manager/relay/2017-04-01/wcfrelays/method_getauthorizationrule.go new file mode 100644 index 00000000000..e5bf04ce923 --- /dev/null +++ b/resource-manager/relay/2017-04-01/wcfrelays/method_getauthorizationrule.go @@ -0,0 +1,51 @@ +package wcfrelays + +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 GetAuthorizationRuleOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AuthorizationRule +} + +// GetAuthorizationRule ... +func (c WCFRelaysClient) GetAuthorizationRule(ctx context.Context, id WcfRelayAuthorizationRuleId) (result GetAuthorizationRuleOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/relay/2017-04-01/wcfrelays/method_getauthorizationrule_autorest.go b/resource-manager/relay/2017-04-01/wcfrelays/method_getauthorizationrule_autorest.go deleted file mode 100644 index 0defa5a466d..00000000000 --- a/resource-manager/relay/2017-04-01/wcfrelays/method_getauthorizationrule_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package wcfrelays - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetAuthorizationRuleOperationResponse struct { - HttpResponse *http.Response - Model *AuthorizationRule -} - -// GetAuthorizationRule ... -func (c WCFRelaysClient) GetAuthorizationRule(ctx context.Context, id WcfRelayAuthorizationRuleId) (result GetAuthorizationRuleOperationResponse, err error) { - req, err := c.preparerForGetAuthorizationRule(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "GetAuthorizationRule", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "GetAuthorizationRule", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetAuthorizationRule(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "GetAuthorizationRule", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetAuthorizationRule prepares the GetAuthorizationRule request. -func (c WCFRelaysClient) preparerForGetAuthorizationRule(ctx context.Context, id WcfRelayAuthorizationRuleId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetAuthorizationRule handles the response to the GetAuthorizationRule request. The method always -// closes the http.Response Body. -func (c WCFRelaysClient) responderForGetAuthorizationRule(resp *http.Response) (result GetAuthorizationRuleOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/relay/2017-04-01/wcfrelays/method_listauthorizationrules.go b/resource-manager/relay/2017-04-01/wcfrelays/method_listauthorizationrules.go new file mode 100644 index 00000000000..827435c8ddb --- /dev/null +++ b/resource-manager/relay/2017-04-01/wcfrelays/method_listauthorizationrules.go @@ -0,0 +1,89 @@ +package wcfrelays + +import ( + "context" + "fmt" + "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 ListAuthorizationRulesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AuthorizationRule +} + +type ListAuthorizationRulesCompleteResult struct { + Items []AuthorizationRule +} + +// ListAuthorizationRules ... +func (c WCFRelaysClient) ListAuthorizationRules(ctx context.Context, id WcfRelayId) (result ListAuthorizationRulesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/authorizationRules", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AuthorizationRule `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAuthorizationRulesComplete retrieves all the results into a single object +func (c WCFRelaysClient) ListAuthorizationRulesComplete(ctx context.Context, id WcfRelayId) (ListAuthorizationRulesCompleteResult, error) { + return c.ListAuthorizationRulesCompleteMatchingPredicate(ctx, id, AuthorizationRuleOperationPredicate{}) +} + +// ListAuthorizationRulesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WCFRelaysClient) ListAuthorizationRulesCompleteMatchingPredicate(ctx context.Context, id WcfRelayId, predicate AuthorizationRuleOperationPredicate) (result ListAuthorizationRulesCompleteResult, err error) { + items := make([]AuthorizationRule, 0) + + resp, err := c.ListAuthorizationRules(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListAuthorizationRulesCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/relay/2017-04-01/wcfrelays/method_listauthorizationrules_autorest.go b/resource-manager/relay/2017-04-01/wcfrelays/method_listauthorizationrules_autorest.go deleted file mode 100644 index 8eb47777305..00000000000 --- a/resource-manager/relay/2017-04-01/wcfrelays/method_listauthorizationrules_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package wcfrelays - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListAuthorizationRulesOperationResponse struct { - HttpResponse *http.Response - Model *[]AuthorizationRule - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListAuthorizationRulesOperationResponse, error) -} - -type ListAuthorizationRulesCompleteResult struct { - Items []AuthorizationRule -} - -func (r ListAuthorizationRulesOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListAuthorizationRulesOperationResponse) LoadMore(ctx context.Context) (resp ListAuthorizationRulesOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListAuthorizationRules ... -func (c WCFRelaysClient) ListAuthorizationRules(ctx context.Context, id WcfRelayId) (resp ListAuthorizationRulesOperationResponse, err error) { - req, err := c.preparerForListAuthorizationRules(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "ListAuthorizationRules", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "ListAuthorizationRules", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListAuthorizationRules(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "ListAuthorizationRules", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListAuthorizationRules prepares the ListAuthorizationRules request. -func (c WCFRelaysClient) preparerForListAuthorizationRules(ctx context.Context, id WcfRelayId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/authorizationRules", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListAuthorizationRulesWithNextLink prepares the ListAuthorizationRules request with the given nextLink token. -func (c WCFRelaysClient) preparerForListAuthorizationRulesWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListAuthorizationRules handles the response to the ListAuthorizationRules request. The method always -// closes the http.Response Body. -func (c WCFRelaysClient) responderForListAuthorizationRules(resp *http.Response) (result ListAuthorizationRulesOperationResponse, err error) { - type page struct { - Values []AuthorizationRule `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListAuthorizationRulesOperationResponse, err error) { - req, err := c.preparerForListAuthorizationRulesWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "ListAuthorizationRules", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "ListAuthorizationRules", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListAuthorizationRules(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "ListAuthorizationRules", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListAuthorizationRulesComplete retrieves all of the results into a single object -func (c WCFRelaysClient) ListAuthorizationRulesComplete(ctx context.Context, id WcfRelayId) (ListAuthorizationRulesCompleteResult, error) { - return c.ListAuthorizationRulesCompleteMatchingPredicate(ctx, id, AuthorizationRuleOperationPredicate{}) -} - -// ListAuthorizationRulesCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WCFRelaysClient) ListAuthorizationRulesCompleteMatchingPredicate(ctx context.Context, id WcfRelayId, predicate AuthorizationRuleOperationPredicate) (resp ListAuthorizationRulesCompleteResult, err error) { - items := make([]AuthorizationRule, 0) - - page, err := c.ListAuthorizationRules(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListAuthorizationRulesCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/relay/2017-04-01/wcfrelays/method_listbynamespace.go b/resource-manager/relay/2017-04-01/wcfrelays/method_listbynamespace.go new file mode 100644 index 00000000000..967f4732650 --- /dev/null +++ b/resource-manager/relay/2017-04-01/wcfrelays/method_listbynamespace.go @@ -0,0 +1,89 @@ +package wcfrelays + +import ( + "context" + "fmt" + "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 ListByNamespaceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WcfRelay +} + +type ListByNamespaceCompleteResult struct { + Items []WcfRelay +} + +// ListByNamespace ... +func (c WCFRelaysClient) ListByNamespace(ctx context.Context, id NamespaceId) (result ListByNamespaceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/wcfRelays", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]WcfRelay `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByNamespaceComplete retrieves all the results into a single object +func (c WCFRelaysClient) ListByNamespaceComplete(ctx context.Context, id NamespaceId) (ListByNamespaceCompleteResult, error) { + return c.ListByNamespaceCompleteMatchingPredicate(ctx, id, WcfRelayOperationPredicate{}) +} + +// ListByNamespaceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WCFRelaysClient) ListByNamespaceCompleteMatchingPredicate(ctx context.Context, id NamespaceId, predicate WcfRelayOperationPredicate) (result ListByNamespaceCompleteResult, err error) { + items := make([]WcfRelay, 0) + + resp, err := c.ListByNamespace(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByNamespaceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/relay/2017-04-01/wcfrelays/method_listbynamespace_autorest.go b/resource-manager/relay/2017-04-01/wcfrelays/method_listbynamespace_autorest.go deleted file mode 100644 index 2864700ce74..00000000000 --- a/resource-manager/relay/2017-04-01/wcfrelays/method_listbynamespace_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package wcfrelays - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByNamespaceOperationResponse struct { - HttpResponse *http.Response - Model *[]WcfRelay - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByNamespaceOperationResponse, error) -} - -type ListByNamespaceCompleteResult struct { - Items []WcfRelay -} - -func (r ListByNamespaceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByNamespaceOperationResponse) LoadMore(ctx context.Context) (resp ListByNamespaceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByNamespace ... -func (c WCFRelaysClient) ListByNamespace(ctx context.Context, id NamespaceId) (resp ListByNamespaceOperationResponse, err error) { - req, err := c.preparerForListByNamespace(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "ListByNamespace", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "ListByNamespace", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByNamespace(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "ListByNamespace", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByNamespace prepares the ListByNamespace request. -func (c WCFRelaysClient) preparerForListByNamespace(ctx context.Context, id NamespaceId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/wcfRelays", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByNamespaceWithNextLink prepares the ListByNamespace request with the given nextLink token. -func (c WCFRelaysClient) preparerForListByNamespaceWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByNamespace handles the response to the ListByNamespace request. The method always -// closes the http.Response Body. -func (c WCFRelaysClient) responderForListByNamespace(resp *http.Response) (result ListByNamespaceOperationResponse, err error) { - type page struct { - Values []WcfRelay `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByNamespaceOperationResponse, err error) { - req, err := c.preparerForListByNamespaceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "ListByNamespace", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "ListByNamespace", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByNamespace(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "ListByNamespace", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByNamespaceComplete retrieves all of the results into a single object -func (c WCFRelaysClient) ListByNamespaceComplete(ctx context.Context, id NamespaceId) (ListByNamespaceCompleteResult, error) { - return c.ListByNamespaceCompleteMatchingPredicate(ctx, id, WcfRelayOperationPredicate{}) -} - -// ListByNamespaceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WCFRelaysClient) ListByNamespaceCompleteMatchingPredicate(ctx context.Context, id NamespaceId, predicate WcfRelayOperationPredicate) (resp ListByNamespaceCompleteResult, err error) { - items := make([]WcfRelay, 0) - - page, err := c.ListByNamespace(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByNamespaceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/relay/2017-04-01/wcfrelays/method_listkeys.go b/resource-manager/relay/2017-04-01/wcfrelays/method_listkeys.go new file mode 100644 index 00000000000..c4ace582b3e --- /dev/null +++ b/resource-manager/relay/2017-04-01/wcfrelays/method_listkeys.go @@ -0,0 +1,52 @@ +package wcfrelays + +import ( + "context" + "fmt" + "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 ListKeysOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AccessKeys +} + +// ListKeys ... +func (c WCFRelaysClient) ListKeys(ctx context.Context, id WcfRelayAuthorizationRuleId) (result ListKeysOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listKeys", 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 +} diff --git a/resource-manager/relay/2017-04-01/wcfrelays/method_listkeys_autorest.go b/resource-manager/relay/2017-04-01/wcfrelays/method_listkeys_autorest.go deleted file mode 100644 index 79cfcb860a4..00000000000 --- a/resource-manager/relay/2017-04-01/wcfrelays/method_listkeys_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package wcfrelays - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListKeysOperationResponse struct { - HttpResponse *http.Response - Model *AccessKeys -} - -// ListKeys ... -func (c WCFRelaysClient) ListKeys(ctx context.Context, id WcfRelayAuthorizationRuleId) (result ListKeysOperationResponse, err error) { - req, err := c.preparerForListKeys(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "ListKeys", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "ListKeys", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListKeys(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "ListKeys", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListKeys prepares the ListKeys request. -func (c WCFRelaysClient) preparerForListKeys(ctx context.Context, id WcfRelayAuthorizationRuleId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/listKeys", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListKeys handles the response to the ListKeys request. The method always -// closes the http.Response Body. -func (c WCFRelaysClient) responderForListKeys(resp *http.Response) (result ListKeysOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/relay/2017-04-01/wcfrelays/method_regeneratekeys.go b/resource-manager/relay/2017-04-01/wcfrelays/method_regeneratekeys.go new file mode 100644 index 00000000000..46eb4be71b1 --- /dev/null +++ b/resource-manager/relay/2017-04-01/wcfrelays/method_regeneratekeys.go @@ -0,0 +1,56 @@ +package wcfrelays + +import ( + "context" + "fmt" + "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 RegenerateKeysOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AccessKeys +} + +// RegenerateKeys ... +func (c WCFRelaysClient) RegenerateKeys(ctx context.Context, id WcfRelayAuthorizationRuleId, input RegenerateAccessKeyParameters) (result RegenerateKeysOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/regenerateKeys", 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 +} diff --git a/resource-manager/relay/2017-04-01/wcfrelays/method_regeneratekeys_autorest.go b/resource-manager/relay/2017-04-01/wcfrelays/method_regeneratekeys_autorest.go deleted file mode 100644 index f8303131211..00000000000 --- a/resource-manager/relay/2017-04-01/wcfrelays/method_regeneratekeys_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package wcfrelays - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type RegenerateKeysOperationResponse struct { - HttpResponse *http.Response - Model *AccessKeys -} - -// RegenerateKeys ... -func (c WCFRelaysClient) RegenerateKeys(ctx context.Context, id WcfRelayAuthorizationRuleId, input RegenerateAccessKeyParameters) (result RegenerateKeysOperationResponse, err error) { - req, err := c.preparerForRegenerateKeys(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "RegenerateKeys", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "RegenerateKeys", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForRegenerateKeys(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "RegenerateKeys", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForRegenerateKeys prepares the RegenerateKeys request. -func (c WCFRelaysClient) preparerForRegenerateKeys(ctx context.Context, id WcfRelayAuthorizationRuleId, input RegenerateAccessKeyParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/regenerateKeys", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForRegenerateKeys handles the response to the RegenerateKeys request. The method always -// closes the http.Response Body. -func (c WCFRelaysClient) responderForRegenerateKeys(resp *http.Response) (result RegenerateKeysOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/relay/2021-11-01/client.go b/resource-manager/relay/2021-11-01/client.go index 850c69fed31..adc57214449 100644 --- a/resource-manager/relay/2021-11-01/client.go +++ b/resource-manager/relay/2021-11-01/client.go @@ -4,12 +4,15 @@ package v2021_11_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/relay/2021-11-01/hybridconnections" "github.com/hashicorp/go-azure-sdk/resource-manager/relay/2021-11-01/namespaces" "github.com/hashicorp/go-azure-sdk/resource-manager/relay/2021-11-01/namespacesprivateendpointconnections" "github.com/hashicorp/go-azure-sdk/resource-manager/relay/2021-11-01/namespacesprivatelinkresources" "github.com/hashicorp/go-azure-sdk/resource-manager/relay/2021-11-01/wcfrelays" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/environments" ) type Client struct { @@ -20,28 +23,42 @@ type Client struct { WCFRelays *wcfrelays.WCFRelaysClient } -func NewClientWithBaseURI(endpoint string, configureAuthFunc func(c *autorest.Client)) Client { - - hybridConnectionsClient := hybridconnections.NewHybridConnectionsClientWithBaseURI(endpoint) - configureAuthFunc(&hybridConnectionsClient.Client) - - namespacesClient := namespaces.NewNamespacesClientWithBaseURI(endpoint) - configureAuthFunc(&namespacesClient.Client) +func NewClientWithBaseURI(api environments.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + hybridConnectionsClient, err := hybridconnections.NewHybridConnectionsClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building HybridConnections client: %+v", err) + } + configureFunc(hybridConnectionsClient.Client) - namespacesPrivateEndpointConnectionsClient := namespacesprivateendpointconnections.NewNamespacesPrivateEndpointConnectionsClientWithBaseURI(endpoint) - configureAuthFunc(&namespacesPrivateEndpointConnectionsClient.Client) + namespacesClient, err := namespaces.NewNamespacesClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Namespaces client: %+v", err) + } + configureFunc(namespacesClient.Client) - namespacesPrivateLinkResourcesClient := namespacesprivatelinkresources.NewNamespacesPrivateLinkResourcesClientWithBaseURI(endpoint) - configureAuthFunc(&namespacesPrivateLinkResourcesClient.Client) + namespacesPrivateEndpointConnectionsClient, err := namespacesprivateendpointconnections.NewNamespacesPrivateEndpointConnectionsClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building NamespacesPrivateEndpointConnections client: %+v", err) + } + configureFunc(namespacesPrivateEndpointConnectionsClient.Client) - wCFRelaysClient := wcfrelays.NewWCFRelaysClientWithBaseURI(endpoint) - configureAuthFunc(&wCFRelaysClient.Client) + namespacesPrivateLinkResourcesClient, err := namespacesprivatelinkresources.NewNamespacesPrivateLinkResourcesClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building NamespacesPrivateLinkResources client: %+v", err) + } + configureFunc(namespacesPrivateLinkResourcesClient.Client) - return Client{ - HybridConnections: &hybridConnectionsClient, - Namespaces: &namespacesClient, - NamespacesPrivateEndpointConnections: &namespacesPrivateEndpointConnectionsClient, - NamespacesPrivateLinkResources: &namespacesPrivateLinkResourcesClient, - WCFRelays: &wCFRelaysClient, + wCFRelaysClient, err := wcfrelays.NewWCFRelaysClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building WCFRelays client: %+v", err) } + configureFunc(wCFRelaysClient.Client) + + return &Client{ + HybridConnections: hybridConnectionsClient, + Namespaces: namespacesClient, + NamespacesPrivateEndpointConnections: namespacesPrivateEndpointConnectionsClient, + NamespacesPrivateLinkResources: namespacesPrivateLinkResourcesClient, + WCFRelays: wCFRelaysClient, + }, nil } diff --git a/resource-manager/relay/2021-11-01/hybridconnections/client.go b/resource-manager/relay/2021-11-01/hybridconnections/client.go index b2529360ef3..03aa13b066b 100644 --- a/resource-manager/relay/2021-11-01/hybridconnections/client.go +++ b/resource-manager/relay/2021-11-01/hybridconnections/client.go @@ -1,18 +1,26 @@ package hybridconnections -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 HybridConnectionsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewHybridConnectionsClientWithBaseURI(endpoint string) HybridConnectionsClient { - return HybridConnectionsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewHybridConnectionsClientWithBaseURI(api environments.Api) (*HybridConnectionsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "hybridconnections", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating HybridConnectionsClient: %+v", err) } + + return &HybridConnectionsClient{ + Client: client, + }, nil } diff --git a/resource-manager/relay/2021-11-01/hybridconnections/constants.go b/resource-manager/relay/2021-11-01/hybridconnections/constants.go index 356096a5c0c..e6f718014ba 100644 --- a/resource-manager/relay/2021-11-01/hybridconnections/constants.go +++ b/resource-manager/relay/2021-11-01/hybridconnections/constants.go @@ -1,6 +1,10 @@ package hybridconnections -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. @@ -21,6 +25,19 @@ func PossibleValuesForAccessRights() []string { } } +func (s *AccessRights) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAccessRights(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAccessRights(input string) (*AccessRights, error) { vals := map[string]AccessRights{ "listen": AccessRightsListen, @@ -50,6 +67,19 @@ func PossibleValuesForKeyType() []string { } } +func (s *KeyType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKeyType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseKeyType(input string) (*KeyType, error) { vals := map[string]KeyType{ "primarykey": KeyTypePrimaryKey, diff --git a/resource-manager/relay/2021-11-01/hybridconnections/method_createorupdate.go b/resource-manager/relay/2021-11-01/hybridconnections/method_createorupdate.go new file mode 100644 index 00000000000..7b429d3db2b --- /dev/null +++ b/resource-manager/relay/2021-11-01/hybridconnections/method_createorupdate.go @@ -0,0 +1,55 @@ +package hybridconnections + +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 *HybridConnection +} + +// CreateOrUpdate ... +func (c HybridConnectionsClient) CreateOrUpdate(ctx context.Context, id HybridConnectionId, input HybridConnection) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 +} diff --git a/resource-manager/relay/2021-11-01/hybridconnections/method_createorupdate_autorest.go b/resource-manager/relay/2021-11-01/hybridconnections/method_createorupdate_autorest.go deleted file mode 100644 index dfe8081b9f0..00000000000 --- a/resource-manager/relay/2021-11-01/hybridconnections/method_createorupdate_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package hybridconnections - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// 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 - Model *HybridConnection -} - -// CreateOrUpdate ... -func (c HybridConnectionsClient) CreateOrUpdate(ctx context.Context, id HybridConnectionId, input HybridConnection) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c HybridConnectionsClient) preparerForCreateOrUpdate(ctx context.Context, id HybridConnectionId, input HybridConnection) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateOrUpdate handles the response to the CreateOrUpdate request. The method always -// closes the http.Response Body. -func (c HybridConnectionsClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/relay/2021-11-01/hybridconnections/method_createorupdateauthorizationrule.go b/resource-manager/relay/2021-11-01/hybridconnections/method_createorupdateauthorizationrule.go new file mode 100644 index 00000000000..abdea041980 --- /dev/null +++ b/resource-manager/relay/2021-11-01/hybridconnections/method_createorupdateauthorizationrule.go @@ -0,0 +1,55 @@ +package hybridconnections + +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 CreateOrUpdateAuthorizationRuleOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AuthorizationRule +} + +// CreateOrUpdateAuthorizationRule ... +func (c HybridConnectionsClient) CreateOrUpdateAuthorizationRule(ctx context.Context, id HybridConnectionAuthorizationRuleId, input AuthorizationRule) (result CreateOrUpdateAuthorizationRuleOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 +} diff --git a/resource-manager/relay/2021-11-01/hybridconnections/method_createorupdateauthorizationrule_autorest.go b/resource-manager/relay/2021-11-01/hybridconnections/method_createorupdateauthorizationrule_autorest.go deleted file mode 100644 index 2eacea331e4..00000000000 --- a/resource-manager/relay/2021-11-01/hybridconnections/method_createorupdateauthorizationrule_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package hybridconnections - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateAuthorizationRuleOperationResponse struct { - HttpResponse *http.Response - Model *AuthorizationRule -} - -// CreateOrUpdateAuthorizationRule ... -func (c HybridConnectionsClient) CreateOrUpdateAuthorizationRule(ctx context.Context, id HybridConnectionAuthorizationRuleId, input AuthorizationRule) (result CreateOrUpdateAuthorizationRuleOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdateAuthorizationRule(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "CreateOrUpdateAuthorizationRule", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "CreateOrUpdateAuthorizationRule", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdateAuthorizationRule(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "CreateOrUpdateAuthorizationRule", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdateAuthorizationRule prepares the CreateOrUpdateAuthorizationRule request. -func (c HybridConnectionsClient) preparerForCreateOrUpdateAuthorizationRule(ctx context.Context, id HybridConnectionAuthorizationRuleId, input AuthorizationRule) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateOrUpdateAuthorizationRule handles the response to the CreateOrUpdateAuthorizationRule request. The method always -// closes the http.Response Body. -func (c HybridConnectionsClient) responderForCreateOrUpdateAuthorizationRule(resp *http.Response) (result CreateOrUpdateAuthorizationRuleOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/relay/2021-11-01/hybridconnections/method_delete.go b/resource-manager/relay/2021-11-01/hybridconnections/method_delete.go new file mode 100644 index 00000000000..530690502d9 --- /dev/null +++ b/resource-manager/relay/2021-11-01/hybridconnections/method_delete.go @@ -0,0 +1,47 @@ +package hybridconnections + +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 +} + +// Delete ... +func (c HybridConnectionsClient) Delete(ctx context.Context, id HybridConnectionId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 + } + + return +} diff --git a/resource-manager/relay/2021-11-01/hybridconnections/method_delete_autorest.go b/resource-manager/relay/2021-11-01/hybridconnections/method_delete_autorest.go deleted file mode 100644 index fed5efbc8c2..00000000000 --- a/resource-manager/relay/2021-11-01/hybridconnections/method_delete_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package hybridconnections - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// 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 -} - -// Delete ... -func (c HybridConnectionsClient) Delete(ctx context.Context, id HybridConnectionId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c HybridConnectionsClient) preparerForDelete(ctx context.Context, id HybridConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c HybridConnectionsClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/relay/2021-11-01/hybridconnections/method_deleteauthorizationrule.go b/resource-manager/relay/2021-11-01/hybridconnections/method_deleteauthorizationrule.go new file mode 100644 index 00000000000..0b011b062e9 --- /dev/null +++ b/resource-manager/relay/2021-11-01/hybridconnections/method_deleteauthorizationrule.go @@ -0,0 +1,47 @@ +package hybridconnections + +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 DeleteAuthorizationRuleOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteAuthorizationRule ... +func (c HybridConnectionsClient) DeleteAuthorizationRule(ctx context.Context, id HybridConnectionAuthorizationRuleId) (result DeleteAuthorizationRuleOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 + } + + return +} diff --git a/resource-manager/relay/2021-11-01/hybridconnections/method_deleteauthorizationrule_autorest.go b/resource-manager/relay/2021-11-01/hybridconnections/method_deleteauthorizationrule_autorest.go deleted file mode 100644 index d68bada1bd9..00000000000 --- a/resource-manager/relay/2021-11-01/hybridconnections/method_deleteauthorizationrule_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package hybridconnections - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteAuthorizationRuleOperationResponse struct { - HttpResponse *http.Response -} - -// DeleteAuthorizationRule ... -func (c HybridConnectionsClient) DeleteAuthorizationRule(ctx context.Context, id HybridConnectionAuthorizationRuleId) (result DeleteAuthorizationRuleOperationResponse, err error) { - req, err := c.preparerForDeleteAuthorizationRule(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "DeleteAuthorizationRule", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "DeleteAuthorizationRule", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeleteAuthorizationRule(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "DeleteAuthorizationRule", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeleteAuthorizationRule prepares the DeleteAuthorizationRule request. -func (c HybridConnectionsClient) preparerForDeleteAuthorizationRule(ctx context.Context, id HybridConnectionAuthorizationRuleId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeleteAuthorizationRule handles the response to the DeleteAuthorizationRule request. The method always -// closes the http.Response Body. -func (c HybridConnectionsClient) responderForDeleteAuthorizationRule(resp *http.Response) (result DeleteAuthorizationRuleOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/relay/2021-11-01/hybridconnections/method_get.go b/resource-manager/relay/2021-11-01/hybridconnections/method_get.go new file mode 100644 index 00000000000..5d7cf30b876 --- /dev/null +++ b/resource-manager/relay/2021-11-01/hybridconnections/method_get.go @@ -0,0 +1,51 @@ +package hybridconnections + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HybridConnection +} + +// Get ... +func (c HybridConnectionsClient) Get(ctx context.Context, id HybridConnectionId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/relay/2021-11-01/hybridconnections/method_get_autorest.go b/resource-manager/relay/2021-11-01/hybridconnections/method_get_autorest.go deleted file mode 100644 index e74e23ef7e3..00000000000 --- a/resource-manager/relay/2021-11-01/hybridconnections/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package hybridconnections - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *HybridConnection -} - -// Get ... -func (c HybridConnectionsClient) Get(ctx context.Context, id HybridConnectionId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c HybridConnectionsClient) preparerForGet(ctx context.Context, id HybridConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c HybridConnectionsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/relay/2021-11-01/hybridconnections/method_getauthorizationrule.go b/resource-manager/relay/2021-11-01/hybridconnections/method_getauthorizationrule.go new file mode 100644 index 00000000000..4990dc2a4c5 --- /dev/null +++ b/resource-manager/relay/2021-11-01/hybridconnections/method_getauthorizationrule.go @@ -0,0 +1,51 @@ +package hybridconnections + +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 GetAuthorizationRuleOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AuthorizationRule +} + +// GetAuthorizationRule ... +func (c HybridConnectionsClient) GetAuthorizationRule(ctx context.Context, id HybridConnectionAuthorizationRuleId) (result GetAuthorizationRuleOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/relay/2021-11-01/hybridconnections/method_getauthorizationrule_autorest.go b/resource-manager/relay/2021-11-01/hybridconnections/method_getauthorizationrule_autorest.go deleted file mode 100644 index 66dfe02f779..00000000000 --- a/resource-manager/relay/2021-11-01/hybridconnections/method_getauthorizationrule_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package hybridconnections - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetAuthorizationRuleOperationResponse struct { - HttpResponse *http.Response - Model *AuthorizationRule -} - -// GetAuthorizationRule ... -func (c HybridConnectionsClient) GetAuthorizationRule(ctx context.Context, id HybridConnectionAuthorizationRuleId) (result GetAuthorizationRuleOperationResponse, err error) { - req, err := c.preparerForGetAuthorizationRule(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "GetAuthorizationRule", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "GetAuthorizationRule", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetAuthorizationRule(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "GetAuthorizationRule", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetAuthorizationRule prepares the GetAuthorizationRule request. -func (c HybridConnectionsClient) preparerForGetAuthorizationRule(ctx context.Context, id HybridConnectionAuthorizationRuleId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetAuthorizationRule handles the response to the GetAuthorizationRule request. The method always -// closes the http.Response Body. -func (c HybridConnectionsClient) responderForGetAuthorizationRule(resp *http.Response) (result GetAuthorizationRuleOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/relay/2021-11-01/hybridconnections/method_listauthorizationrules.go b/resource-manager/relay/2021-11-01/hybridconnections/method_listauthorizationrules.go new file mode 100644 index 00000000000..935ea4bd140 --- /dev/null +++ b/resource-manager/relay/2021-11-01/hybridconnections/method_listauthorizationrules.go @@ -0,0 +1,89 @@ +package hybridconnections + +import ( + "context" + "fmt" + "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 ListAuthorizationRulesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AuthorizationRule +} + +type ListAuthorizationRulesCompleteResult struct { + Items []AuthorizationRule +} + +// ListAuthorizationRules ... +func (c HybridConnectionsClient) ListAuthorizationRules(ctx context.Context, id HybridConnectionId) (result ListAuthorizationRulesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/authorizationRules", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AuthorizationRule `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAuthorizationRulesComplete retrieves all the results into a single object +func (c HybridConnectionsClient) ListAuthorizationRulesComplete(ctx context.Context, id HybridConnectionId) (ListAuthorizationRulesCompleteResult, error) { + return c.ListAuthorizationRulesCompleteMatchingPredicate(ctx, id, AuthorizationRuleOperationPredicate{}) +} + +// ListAuthorizationRulesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c HybridConnectionsClient) ListAuthorizationRulesCompleteMatchingPredicate(ctx context.Context, id HybridConnectionId, predicate AuthorizationRuleOperationPredicate) (result ListAuthorizationRulesCompleteResult, err error) { + items := make([]AuthorizationRule, 0) + + resp, err := c.ListAuthorizationRules(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListAuthorizationRulesCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/relay/2021-11-01/hybridconnections/method_listauthorizationrules_autorest.go b/resource-manager/relay/2021-11-01/hybridconnections/method_listauthorizationrules_autorest.go deleted file mode 100644 index 23c40087266..00000000000 --- a/resource-manager/relay/2021-11-01/hybridconnections/method_listauthorizationrules_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package hybridconnections - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListAuthorizationRulesOperationResponse struct { - HttpResponse *http.Response - Model *[]AuthorizationRule - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListAuthorizationRulesOperationResponse, error) -} - -type ListAuthorizationRulesCompleteResult struct { - Items []AuthorizationRule -} - -func (r ListAuthorizationRulesOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListAuthorizationRulesOperationResponse) LoadMore(ctx context.Context) (resp ListAuthorizationRulesOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListAuthorizationRules ... -func (c HybridConnectionsClient) ListAuthorizationRules(ctx context.Context, id HybridConnectionId) (resp ListAuthorizationRulesOperationResponse, err error) { - req, err := c.preparerForListAuthorizationRules(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "ListAuthorizationRules", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "ListAuthorizationRules", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListAuthorizationRules(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "ListAuthorizationRules", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListAuthorizationRules prepares the ListAuthorizationRules request. -func (c HybridConnectionsClient) preparerForListAuthorizationRules(ctx context.Context, id HybridConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/authorizationRules", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListAuthorizationRulesWithNextLink prepares the ListAuthorizationRules request with the given nextLink token. -func (c HybridConnectionsClient) preparerForListAuthorizationRulesWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListAuthorizationRules handles the response to the ListAuthorizationRules request. The method always -// closes the http.Response Body. -func (c HybridConnectionsClient) responderForListAuthorizationRules(resp *http.Response) (result ListAuthorizationRulesOperationResponse, err error) { - type page struct { - Values []AuthorizationRule `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListAuthorizationRulesOperationResponse, err error) { - req, err := c.preparerForListAuthorizationRulesWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "ListAuthorizationRules", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "ListAuthorizationRules", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListAuthorizationRules(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "ListAuthorizationRules", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListAuthorizationRulesComplete retrieves all of the results into a single object -func (c HybridConnectionsClient) ListAuthorizationRulesComplete(ctx context.Context, id HybridConnectionId) (ListAuthorizationRulesCompleteResult, error) { - return c.ListAuthorizationRulesCompleteMatchingPredicate(ctx, id, AuthorizationRuleOperationPredicate{}) -} - -// ListAuthorizationRulesCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c HybridConnectionsClient) ListAuthorizationRulesCompleteMatchingPredicate(ctx context.Context, id HybridConnectionId, predicate AuthorizationRuleOperationPredicate) (resp ListAuthorizationRulesCompleteResult, err error) { - items := make([]AuthorizationRule, 0) - - page, err := c.ListAuthorizationRules(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListAuthorizationRulesCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/relay/2021-11-01/hybridconnections/method_listbynamespace.go b/resource-manager/relay/2021-11-01/hybridconnections/method_listbynamespace.go new file mode 100644 index 00000000000..93bf80ee2c0 --- /dev/null +++ b/resource-manager/relay/2021-11-01/hybridconnections/method_listbynamespace.go @@ -0,0 +1,89 @@ +package hybridconnections + +import ( + "context" + "fmt" + "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 ListByNamespaceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]HybridConnection +} + +type ListByNamespaceCompleteResult struct { + Items []HybridConnection +} + +// ListByNamespace ... +func (c HybridConnectionsClient) ListByNamespace(ctx context.Context, id NamespaceId) (result ListByNamespaceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/hybridConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]HybridConnection `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByNamespaceComplete retrieves all the results into a single object +func (c HybridConnectionsClient) ListByNamespaceComplete(ctx context.Context, id NamespaceId) (ListByNamespaceCompleteResult, error) { + return c.ListByNamespaceCompleteMatchingPredicate(ctx, id, HybridConnectionOperationPredicate{}) +} + +// ListByNamespaceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c HybridConnectionsClient) ListByNamespaceCompleteMatchingPredicate(ctx context.Context, id NamespaceId, predicate HybridConnectionOperationPredicate) (result ListByNamespaceCompleteResult, err error) { + items := make([]HybridConnection, 0) + + resp, err := c.ListByNamespace(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByNamespaceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/relay/2021-11-01/hybridconnections/method_listbynamespace_autorest.go b/resource-manager/relay/2021-11-01/hybridconnections/method_listbynamespace_autorest.go deleted file mode 100644 index 1062f8d85d5..00000000000 --- a/resource-manager/relay/2021-11-01/hybridconnections/method_listbynamespace_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package hybridconnections - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByNamespaceOperationResponse struct { - HttpResponse *http.Response - Model *[]HybridConnection - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByNamespaceOperationResponse, error) -} - -type ListByNamespaceCompleteResult struct { - Items []HybridConnection -} - -func (r ListByNamespaceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByNamespaceOperationResponse) LoadMore(ctx context.Context) (resp ListByNamespaceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByNamespace ... -func (c HybridConnectionsClient) ListByNamespace(ctx context.Context, id NamespaceId) (resp ListByNamespaceOperationResponse, err error) { - req, err := c.preparerForListByNamespace(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "ListByNamespace", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "ListByNamespace", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByNamespace(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "ListByNamespace", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByNamespace prepares the ListByNamespace request. -func (c HybridConnectionsClient) preparerForListByNamespace(ctx context.Context, id NamespaceId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/hybridConnections", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByNamespaceWithNextLink prepares the ListByNamespace request with the given nextLink token. -func (c HybridConnectionsClient) preparerForListByNamespaceWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByNamespace handles the response to the ListByNamespace request. The method always -// closes the http.Response Body. -func (c HybridConnectionsClient) responderForListByNamespace(resp *http.Response) (result ListByNamespaceOperationResponse, err error) { - type page struct { - Values []HybridConnection `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByNamespaceOperationResponse, err error) { - req, err := c.preparerForListByNamespaceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "ListByNamespace", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "ListByNamespace", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByNamespace(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "ListByNamespace", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByNamespaceComplete retrieves all of the results into a single object -func (c HybridConnectionsClient) ListByNamespaceComplete(ctx context.Context, id NamespaceId) (ListByNamespaceCompleteResult, error) { - return c.ListByNamespaceCompleteMatchingPredicate(ctx, id, HybridConnectionOperationPredicate{}) -} - -// ListByNamespaceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c HybridConnectionsClient) ListByNamespaceCompleteMatchingPredicate(ctx context.Context, id NamespaceId, predicate HybridConnectionOperationPredicate) (resp ListByNamespaceCompleteResult, err error) { - items := make([]HybridConnection, 0) - - page, err := c.ListByNamespace(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByNamespaceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/relay/2021-11-01/hybridconnections/method_listkeys.go b/resource-manager/relay/2021-11-01/hybridconnections/method_listkeys.go new file mode 100644 index 00000000000..2ac6bc956d8 --- /dev/null +++ b/resource-manager/relay/2021-11-01/hybridconnections/method_listkeys.go @@ -0,0 +1,52 @@ +package hybridconnections + +import ( + "context" + "fmt" + "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 ListKeysOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AccessKeys +} + +// ListKeys ... +func (c HybridConnectionsClient) ListKeys(ctx context.Context, id HybridConnectionAuthorizationRuleId) (result ListKeysOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listKeys", 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 +} diff --git a/resource-manager/relay/2021-11-01/hybridconnections/method_listkeys_autorest.go b/resource-manager/relay/2021-11-01/hybridconnections/method_listkeys_autorest.go deleted file mode 100644 index 2156a9c6838..00000000000 --- a/resource-manager/relay/2021-11-01/hybridconnections/method_listkeys_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package hybridconnections - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListKeysOperationResponse struct { - HttpResponse *http.Response - Model *AccessKeys -} - -// ListKeys ... -func (c HybridConnectionsClient) ListKeys(ctx context.Context, id HybridConnectionAuthorizationRuleId) (result ListKeysOperationResponse, err error) { - req, err := c.preparerForListKeys(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "ListKeys", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "ListKeys", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListKeys(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "ListKeys", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListKeys prepares the ListKeys request. -func (c HybridConnectionsClient) preparerForListKeys(ctx context.Context, id HybridConnectionAuthorizationRuleId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/listKeys", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListKeys handles the response to the ListKeys request. The method always -// closes the http.Response Body. -func (c HybridConnectionsClient) responderForListKeys(resp *http.Response) (result ListKeysOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/relay/2021-11-01/hybridconnections/method_regeneratekeys.go b/resource-manager/relay/2021-11-01/hybridconnections/method_regeneratekeys.go new file mode 100644 index 00000000000..942fa8b66d4 --- /dev/null +++ b/resource-manager/relay/2021-11-01/hybridconnections/method_regeneratekeys.go @@ -0,0 +1,56 @@ +package hybridconnections + +import ( + "context" + "fmt" + "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 RegenerateKeysOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AccessKeys +} + +// RegenerateKeys ... +func (c HybridConnectionsClient) RegenerateKeys(ctx context.Context, id HybridConnectionAuthorizationRuleId, input RegenerateAccessKeyParameters) (result RegenerateKeysOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/regenerateKeys", 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 +} diff --git a/resource-manager/relay/2021-11-01/hybridconnections/method_regeneratekeys_autorest.go b/resource-manager/relay/2021-11-01/hybridconnections/method_regeneratekeys_autorest.go deleted file mode 100644 index f036fe194c4..00000000000 --- a/resource-manager/relay/2021-11-01/hybridconnections/method_regeneratekeys_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package hybridconnections - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type RegenerateKeysOperationResponse struct { - HttpResponse *http.Response - Model *AccessKeys -} - -// RegenerateKeys ... -func (c HybridConnectionsClient) RegenerateKeys(ctx context.Context, id HybridConnectionAuthorizationRuleId, input RegenerateAccessKeyParameters) (result RegenerateKeysOperationResponse, err error) { - req, err := c.preparerForRegenerateKeys(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "RegenerateKeys", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "RegenerateKeys", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForRegenerateKeys(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "hybridconnections.HybridConnectionsClient", "RegenerateKeys", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForRegenerateKeys prepares the RegenerateKeys request. -func (c HybridConnectionsClient) preparerForRegenerateKeys(ctx context.Context, id HybridConnectionAuthorizationRuleId, input RegenerateAccessKeyParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/regenerateKeys", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForRegenerateKeys handles the response to the RegenerateKeys request. The method always -// closes the http.Response Body. -func (c HybridConnectionsClient) responderForRegenerateKeys(resp *http.Response) (result RegenerateKeysOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/relay/2021-11-01/namespaces/client.go b/resource-manager/relay/2021-11-01/namespaces/client.go index bf25155c419..6b0ae358115 100644 --- a/resource-manager/relay/2021-11-01/namespaces/client.go +++ b/resource-manager/relay/2021-11-01/namespaces/client.go @@ -1,18 +1,26 @@ package namespaces -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 NamespacesClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewNamespacesClientWithBaseURI(endpoint string) NamespacesClient { - return NamespacesClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewNamespacesClientWithBaseURI(api environments.Api) (*NamespacesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "namespaces", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating NamespacesClient: %+v", err) } + + return &NamespacesClient{ + Client: client, + }, nil } diff --git a/resource-manager/relay/2021-11-01/namespaces/constants.go b/resource-manager/relay/2021-11-01/namespaces/constants.go index 76cf95b6612..39e03d328de 100644 --- a/resource-manager/relay/2021-11-01/namespaces/constants.go +++ b/resource-manager/relay/2021-11-01/namespaces/constants.go @@ -1,6 +1,10 @@ package namespaces -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. @@ -21,6 +25,19 @@ func PossibleValuesForAccessRights() []string { } } +func (s *AccessRights) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAccessRights(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAccessRights(input string) (*AccessRights, error) { vals := map[string]AccessRights{ "listen": AccessRightsListen, @@ -50,6 +67,19 @@ func PossibleValuesForDefaultAction() []string { } } +func (s *DefaultAction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDefaultAction(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseDefaultAction(input string) (*DefaultAction, error) { vals := map[string]DefaultAction{ "allow": DefaultActionAllow, @@ -86,6 +116,19 @@ func PossibleValuesForEndPointProvisioningState() []string { } } +func (s *EndPointProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEndPointProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseEndPointProvisioningState(input string) (*EndPointProvisioningState, error) { vals := map[string]EndPointProvisioningState{ "canceled": EndPointProvisioningStateCanceled, @@ -118,6 +161,19 @@ func PossibleValuesForKeyType() []string { } } +func (s *KeyType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKeyType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseKeyType(input string) (*KeyType, error) { vals := map[string]KeyType{ "primarykey": KeyTypePrimaryKey, @@ -144,6 +200,19 @@ func PossibleValuesForNetworkRuleIPAction() []string { } } +func (s *NetworkRuleIPAction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkRuleIPAction(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseNetworkRuleIPAction(input string) (*NetworkRuleIPAction, error) { vals := map[string]NetworkRuleIPAction{ "allow": NetworkRuleIPActionAllow, @@ -175,6 +244,19 @@ func PossibleValuesForPrivateLinkConnectionStatus() []string { } } +func (s *PrivateLinkConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateLinkConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePrivateLinkConnectionStatus(input string) (*PrivateLinkConnectionStatus, error) { vals := map[string]PrivateLinkConnectionStatus{ "approved": PrivateLinkConnectionStatusApproved, @@ -207,6 +289,19 @@ func PossibleValuesForPublicNetworkAccess() []string { } } +func (s *PublicNetworkAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicNetworkAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePublicNetworkAccess(input string) (*PublicNetworkAccess, error) { vals := map[string]PublicNetworkAccess{ "disabled": PublicNetworkAccessDisabled, @@ -234,6 +329,19 @@ func PossibleValuesForSkuName() []string { } } +func (s *SkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseSkuName(input string) (*SkuName, error) { vals := map[string]SkuName{ "standard": SkuNameStandard, @@ -259,6 +367,19 @@ func PossibleValuesForSkuTier() []string { } } +func (s *SkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseSkuTier(input string) (*SkuTier, error) { vals := map[string]SkuTier{ "standard": SkuTierStandard, @@ -294,6 +415,19 @@ func PossibleValuesForUnavailableReason() []string { } } +func (s *UnavailableReason) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUnavailableReason(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseUnavailableReason(input string) (*UnavailableReason, error) { vals := map[string]UnavailableReason{ "invalidname": UnavailableReasonInvalidName, diff --git a/resource-manager/relay/2021-11-01/namespaces/method_checknameavailability.go b/resource-manager/relay/2021-11-01/namespaces/method_checknameavailability.go new file mode 100644 index 00000000000..c59f7d2954e --- /dev/null +++ b/resource-manager/relay/2021-11-01/namespaces/method_checknameavailability.go @@ -0,0 +1,57 @@ +package namespaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 CheckNameAvailabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CheckNameAvailabilityResult +} + +// CheckNameAvailability ... +func (c NamespacesClient) CheckNameAvailability(ctx context.Context, id commonids.SubscriptionId, input CheckNameAvailability) (result CheckNameAvailabilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.Relay/checkNameAvailability", 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 +} diff --git a/resource-manager/relay/2021-11-01/namespaces/method_checknameavailability_autorest.go b/resource-manager/relay/2021-11-01/namespaces/method_checknameavailability_autorest.go deleted file mode 100644 index 67ba0ea69f0..00000000000 --- a/resource-manager/relay/2021-11-01/namespaces/method_checknameavailability_autorest.go +++ /dev/null @@ -1,71 +0,0 @@ -package namespaces - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CheckNameAvailabilityOperationResponse struct { - HttpResponse *http.Response - Model *CheckNameAvailabilityResult -} - -// CheckNameAvailability ... -func (c NamespacesClient) CheckNameAvailability(ctx context.Context, id commonids.SubscriptionId, input CheckNameAvailability) (result CheckNameAvailabilityOperationResponse, err error) { - req, err := c.preparerForCheckNameAvailability(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "CheckNameAvailability", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "CheckNameAvailability", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCheckNameAvailability(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "CheckNameAvailability", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCheckNameAvailability prepares the CheckNameAvailability request. -func (c NamespacesClient) preparerForCheckNameAvailability(ctx context.Context, id commonids.SubscriptionId, input CheckNameAvailability) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Relay/checkNameAvailability", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCheckNameAvailability handles the response to the CheckNameAvailability request. The method always -// closes the http.Response Body. -func (c NamespacesClient) responderForCheckNameAvailability(resp *http.Response) (result CheckNameAvailabilityOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/relay/2021-11-01/namespaces/method_createorupdate.go b/resource-manager/relay/2021-11-01/namespaces/method_createorupdate.go new file mode 100644 index 00000000000..7c31eb5e47f --- /dev/null +++ b/resource-manager/relay/2021-11-01/namespaces/method_createorupdate.go @@ -0,0 +1,74 @@ +package namespaces + +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 +} + +// CreateOrUpdate ... +func (c NamespacesClient) CreateOrUpdate(ctx context.Context, id NamespaceId, input RelayNamespace) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 NamespacesClient) CreateOrUpdateThenPoll(ctx context.Context, id NamespaceId, input RelayNamespace) 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 +} diff --git a/resource-manager/relay/2021-11-01/namespaces/method_createorupdate_autorest.go b/resource-manager/relay/2021-11-01/namespaces/method_createorupdate_autorest.go deleted file mode 100644 index 09581fdbbbf..00000000000 --- a/resource-manager/relay/2021-11-01/namespaces/method_createorupdate_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package namespaces - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateOrUpdate ... -func (c NamespacesClient) CreateOrUpdate(ctx context.Context, id NamespaceId, input RelayNamespace) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c NamespacesClient) CreateOrUpdateThenPoll(ctx context.Context, id NamespaceId, input RelayNamespace) error { - result, err := c.CreateOrUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateOrUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateOrUpdate: %+v", err) - } - - return nil -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c NamespacesClient) preparerForCreateOrUpdate(ctx context.Context, id NamespaceId, input RelayNamespace) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateOrUpdate sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c NamespacesClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/relay/2021-11-01/namespaces/method_createorupdateauthorizationrule.go b/resource-manager/relay/2021-11-01/namespaces/method_createorupdateauthorizationrule.go new file mode 100644 index 00000000000..d5427180484 --- /dev/null +++ b/resource-manager/relay/2021-11-01/namespaces/method_createorupdateauthorizationrule.go @@ -0,0 +1,55 @@ +package namespaces + +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 CreateOrUpdateAuthorizationRuleOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AuthorizationRule +} + +// CreateOrUpdateAuthorizationRule ... +func (c NamespacesClient) CreateOrUpdateAuthorizationRule(ctx context.Context, id AuthorizationRuleId, input AuthorizationRule) (result CreateOrUpdateAuthorizationRuleOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 +} diff --git a/resource-manager/relay/2021-11-01/namespaces/method_createorupdateauthorizationrule_autorest.go b/resource-manager/relay/2021-11-01/namespaces/method_createorupdateauthorizationrule_autorest.go deleted file mode 100644 index 427b471540d..00000000000 --- a/resource-manager/relay/2021-11-01/namespaces/method_createorupdateauthorizationrule_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package namespaces - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateAuthorizationRuleOperationResponse struct { - HttpResponse *http.Response - Model *AuthorizationRule -} - -// CreateOrUpdateAuthorizationRule ... -func (c NamespacesClient) CreateOrUpdateAuthorizationRule(ctx context.Context, id AuthorizationRuleId, input AuthorizationRule) (result CreateOrUpdateAuthorizationRuleOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdateAuthorizationRule(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "CreateOrUpdateAuthorizationRule", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "CreateOrUpdateAuthorizationRule", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdateAuthorizationRule(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "CreateOrUpdateAuthorizationRule", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdateAuthorizationRule prepares the CreateOrUpdateAuthorizationRule request. -func (c NamespacesClient) preparerForCreateOrUpdateAuthorizationRule(ctx context.Context, id AuthorizationRuleId, input AuthorizationRule) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateOrUpdateAuthorizationRule handles the response to the CreateOrUpdateAuthorizationRule request. The method always -// closes the http.Response Body. -func (c NamespacesClient) responderForCreateOrUpdateAuthorizationRule(resp *http.Response) (result CreateOrUpdateAuthorizationRuleOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/relay/2021-11-01/namespaces/method_createorupdatenetworkruleset.go b/resource-manager/relay/2021-11-01/namespaces/method_createorupdatenetworkruleset.go new file mode 100644 index 00000000000..200f300665a --- /dev/null +++ b/resource-manager/relay/2021-11-01/namespaces/method_createorupdatenetworkruleset.go @@ -0,0 +1,56 @@ +package namespaces + +import ( + "context" + "fmt" + "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 CreateOrUpdateNetworkRuleSetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetworkRuleSet +} + +// CreateOrUpdateNetworkRuleSet ... +func (c NamespacesClient) CreateOrUpdateNetworkRuleSet(ctx context.Context, id NamespaceId, input NetworkRuleSet) (result CreateOrUpdateNetworkRuleSetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/networkRuleSets/default", 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 +} diff --git a/resource-manager/relay/2021-11-01/namespaces/method_createorupdatenetworkruleset_autorest.go b/resource-manager/relay/2021-11-01/namespaces/method_createorupdatenetworkruleset_autorest.go deleted file mode 100644 index 5c25e67a347..00000000000 --- a/resource-manager/relay/2021-11-01/namespaces/method_createorupdatenetworkruleset_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package namespaces - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateNetworkRuleSetOperationResponse struct { - HttpResponse *http.Response - Model *NetworkRuleSet -} - -// CreateOrUpdateNetworkRuleSet ... -func (c NamespacesClient) CreateOrUpdateNetworkRuleSet(ctx context.Context, id NamespaceId, input NetworkRuleSet) (result CreateOrUpdateNetworkRuleSetOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdateNetworkRuleSet(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "CreateOrUpdateNetworkRuleSet", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "CreateOrUpdateNetworkRuleSet", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdateNetworkRuleSet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "CreateOrUpdateNetworkRuleSet", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdateNetworkRuleSet prepares the CreateOrUpdateNetworkRuleSet request. -func (c NamespacesClient) preparerForCreateOrUpdateNetworkRuleSet(ctx context.Context, id NamespaceId, input NetworkRuleSet) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/networkRuleSets/default", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateOrUpdateNetworkRuleSet handles the response to the CreateOrUpdateNetworkRuleSet request. The method always -// closes the http.Response Body. -func (c NamespacesClient) responderForCreateOrUpdateNetworkRuleSet(resp *http.Response) (result CreateOrUpdateNetworkRuleSetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/relay/2021-11-01/namespaces/method_delete.go b/resource-manager/relay/2021-11-01/namespaces/method_delete.go new file mode 100644 index 00000000000..e4aa04bb843 --- /dev/null +++ b/resource-manager/relay/2021-11-01/namespaces/method_delete.go @@ -0,0 +1,71 @@ +package namespaces + +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 NamespacesClient) Delete(ctx context.Context, id NamespaceId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 NamespacesClient) DeleteThenPoll(ctx context.Context, id NamespaceId) 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 +} diff --git a/resource-manager/relay/2021-11-01/namespaces/method_delete_autorest.go b/resource-manager/relay/2021-11-01/namespaces/method_delete_autorest.go deleted file mode 100644 index 968dfe754f2..00000000000 --- a/resource-manager/relay/2021-11-01/namespaces/method_delete_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package namespaces - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// Delete ... -func (c NamespacesClient) Delete(ctx context.Context, id NamespaceId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c NamespacesClient) DeleteThenPoll(ctx context.Context, id NamespaceId) error { - result, err := c.Delete(ctx, id) - if err != nil { - return fmt.Errorf("performing Delete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Delete: %+v", err) - } - - return nil -} - -// preparerForDelete prepares the Delete request. -func (c NamespacesClient) preparerForDelete(ctx context.Context, id NamespaceId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDelete sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (c NamespacesClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/relay/2021-11-01/namespaces/method_deleteauthorizationrule.go b/resource-manager/relay/2021-11-01/namespaces/method_deleteauthorizationrule.go new file mode 100644 index 00000000000..222c32eb344 --- /dev/null +++ b/resource-manager/relay/2021-11-01/namespaces/method_deleteauthorizationrule.go @@ -0,0 +1,47 @@ +package namespaces + +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 DeleteAuthorizationRuleOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteAuthorizationRule ... +func (c NamespacesClient) DeleteAuthorizationRule(ctx context.Context, id AuthorizationRuleId) (result DeleteAuthorizationRuleOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 + } + + return +} diff --git a/resource-manager/relay/2021-11-01/namespaces/method_deleteauthorizationrule_autorest.go b/resource-manager/relay/2021-11-01/namespaces/method_deleteauthorizationrule_autorest.go deleted file mode 100644 index 92336c4b4a0..00000000000 --- a/resource-manager/relay/2021-11-01/namespaces/method_deleteauthorizationrule_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package namespaces - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteAuthorizationRuleOperationResponse struct { - HttpResponse *http.Response -} - -// DeleteAuthorizationRule ... -func (c NamespacesClient) DeleteAuthorizationRule(ctx context.Context, id AuthorizationRuleId) (result DeleteAuthorizationRuleOperationResponse, err error) { - req, err := c.preparerForDeleteAuthorizationRule(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "DeleteAuthorizationRule", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "DeleteAuthorizationRule", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeleteAuthorizationRule(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "DeleteAuthorizationRule", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeleteAuthorizationRule prepares the DeleteAuthorizationRule request. -func (c NamespacesClient) preparerForDeleteAuthorizationRule(ctx context.Context, id AuthorizationRuleId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeleteAuthorizationRule handles the response to the DeleteAuthorizationRule request. The method always -// closes the http.Response Body. -func (c NamespacesClient) responderForDeleteAuthorizationRule(resp *http.Response) (result DeleteAuthorizationRuleOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/relay/2021-11-01/namespaces/method_get.go b/resource-manager/relay/2021-11-01/namespaces/method_get.go new file mode 100644 index 00000000000..df0c5cc36c6 --- /dev/null +++ b/resource-manager/relay/2021-11-01/namespaces/method_get.go @@ -0,0 +1,51 @@ +package namespaces + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RelayNamespace +} + +// Get ... +func (c NamespacesClient) Get(ctx context.Context, id NamespaceId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/relay/2021-11-01/namespaces/method_get_autorest.go b/resource-manager/relay/2021-11-01/namespaces/method_get_autorest.go deleted file mode 100644 index 1ab016389fc..00000000000 --- a/resource-manager/relay/2021-11-01/namespaces/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package namespaces - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *RelayNamespace -} - -// Get ... -func (c NamespacesClient) Get(ctx context.Context, id NamespaceId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c NamespacesClient) preparerForGet(ctx context.Context, id NamespaceId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c NamespacesClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/relay/2021-11-01/namespaces/method_getauthorizationrule.go b/resource-manager/relay/2021-11-01/namespaces/method_getauthorizationrule.go new file mode 100644 index 00000000000..ba8fbc1a27a --- /dev/null +++ b/resource-manager/relay/2021-11-01/namespaces/method_getauthorizationrule.go @@ -0,0 +1,51 @@ +package namespaces + +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 GetAuthorizationRuleOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AuthorizationRule +} + +// GetAuthorizationRule ... +func (c NamespacesClient) GetAuthorizationRule(ctx context.Context, id AuthorizationRuleId) (result GetAuthorizationRuleOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/relay/2021-11-01/namespaces/method_getauthorizationrule_autorest.go b/resource-manager/relay/2021-11-01/namespaces/method_getauthorizationrule_autorest.go deleted file mode 100644 index 24a7f00cb69..00000000000 --- a/resource-manager/relay/2021-11-01/namespaces/method_getauthorizationrule_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package namespaces - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetAuthorizationRuleOperationResponse struct { - HttpResponse *http.Response - Model *AuthorizationRule -} - -// GetAuthorizationRule ... -func (c NamespacesClient) GetAuthorizationRule(ctx context.Context, id AuthorizationRuleId) (result GetAuthorizationRuleOperationResponse, err error) { - req, err := c.preparerForGetAuthorizationRule(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "GetAuthorizationRule", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "GetAuthorizationRule", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetAuthorizationRule(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "GetAuthorizationRule", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetAuthorizationRule prepares the GetAuthorizationRule request. -func (c NamespacesClient) preparerForGetAuthorizationRule(ctx context.Context, id AuthorizationRuleId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetAuthorizationRule handles the response to the GetAuthorizationRule request. The method always -// closes the http.Response Body. -func (c NamespacesClient) responderForGetAuthorizationRule(resp *http.Response) (result GetAuthorizationRuleOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/relay/2021-11-01/namespaces/method_getnetworkruleset.go b/resource-manager/relay/2021-11-01/namespaces/method_getnetworkruleset.go new file mode 100644 index 00000000000..6b45e52ca7d --- /dev/null +++ b/resource-manager/relay/2021-11-01/namespaces/method_getnetworkruleset.go @@ -0,0 +1,52 @@ +package namespaces + +import ( + "context" + "fmt" + "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 GetNetworkRuleSetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetworkRuleSet +} + +// GetNetworkRuleSet ... +func (c NamespacesClient) GetNetworkRuleSet(ctx context.Context, id NamespaceId) (result GetNetworkRuleSetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/networkRuleSets/default", 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 +} diff --git a/resource-manager/relay/2021-11-01/namespaces/method_getnetworkruleset_autorest.go b/resource-manager/relay/2021-11-01/namespaces/method_getnetworkruleset_autorest.go deleted file mode 100644 index ce51bb141b1..00000000000 --- a/resource-manager/relay/2021-11-01/namespaces/method_getnetworkruleset_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package namespaces - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetNetworkRuleSetOperationResponse struct { - HttpResponse *http.Response - Model *NetworkRuleSet -} - -// GetNetworkRuleSet ... -func (c NamespacesClient) GetNetworkRuleSet(ctx context.Context, id NamespaceId) (result GetNetworkRuleSetOperationResponse, err error) { - req, err := c.preparerForGetNetworkRuleSet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "GetNetworkRuleSet", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "GetNetworkRuleSet", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetNetworkRuleSet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "GetNetworkRuleSet", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetNetworkRuleSet prepares the GetNetworkRuleSet request. -func (c NamespacesClient) preparerForGetNetworkRuleSet(ctx context.Context, id NamespaceId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/networkRuleSets/default", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetNetworkRuleSet handles the response to the GetNetworkRuleSet request. The method always -// closes the http.Response Body. -func (c NamespacesClient) responderForGetNetworkRuleSet(resp *http.Response) (result GetNetworkRuleSetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/relay/2021-11-01/namespaces/method_list.go b/resource-manager/relay/2021-11-01/namespaces/method_list.go new file mode 100644 index 00000000000..59b1a72af9c --- /dev/null +++ b/resource-manager/relay/2021-11-01/namespaces/method_list.go @@ -0,0 +1,90 @@ +package namespaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RelayNamespace +} + +type ListCompleteResult struct { + Items []RelayNamespace +} + +// List ... +func (c NamespacesClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Relay/namespaces", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]RelayNamespace `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c NamespacesClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, RelayNamespaceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NamespacesClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate RelayNamespaceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]RelayNamespace, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/relay/2021-11-01/namespaces/method_list_autorest.go b/resource-manager/relay/2021-11-01/namespaces/method_list_autorest.go deleted file mode 100644 index f5067719cee..00000000000 --- a/resource-manager/relay/2021-11-01/namespaces/method_list_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package namespaces - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListOperationResponse struct { - HttpResponse *http.Response - Model *[]RelayNamespace - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []RelayNamespace -} - -func (r ListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// List ... -func (c NamespacesClient) List(ctx context.Context, id commonids.SubscriptionId) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c NamespacesClient) preparerForList(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Relay/namespaces", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c NamespacesClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForList handles the response to the List request. The method always -// closes the http.Response Body. -func (c NamespacesClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []RelayNamespace `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { - req, err := c.preparerForListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c NamespacesClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, RelayNamespaceOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c NamespacesClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate RelayNamespaceOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]RelayNamespace, 0) - - page, err := c.List(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/relay/2021-11-01/namespaces/method_listauthorizationrules.go b/resource-manager/relay/2021-11-01/namespaces/method_listauthorizationrules.go new file mode 100644 index 00000000000..f040c69ed45 --- /dev/null +++ b/resource-manager/relay/2021-11-01/namespaces/method_listauthorizationrules.go @@ -0,0 +1,89 @@ +package namespaces + +import ( + "context" + "fmt" + "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 ListAuthorizationRulesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AuthorizationRule +} + +type ListAuthorizationRulesCompleteResult struct { + Items []AuthorizationRule +} + +// ListAuthorizationRules ... +func (c NamespacesClient) ListAuthorizationRules(ctx context.Context, id NamespaceId) (result ListAuthorizationRulesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/authorizationRules", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AuthorizationRule `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAuthorizationRulesComplete retrieves all the results into a single object +func (c NamespacesClient) ListAuthorizationRulesComplete(ctx context.Context, id NamespaceId) (ListAuthorizationRulesCompleteResult, error) { + return c.ListAuthorizationRulesCompleteMatchingPredicate(ctx, id, AuthorizationRuleOperationPredicate{}) +} + +// ListAuthorizationRulesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NamespacesClient) ListAuthorizationRulesCompleteMatchingPredicate(ctx context.Context, id NamespaceId, predicate AuthorizationRuleOperationPredicate) (result ListAuthorizationRulesCompleteResult, err error) { + items := make([]AuthorizationRule, 0) + + resp, err := c.ListAuthorizationRules(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListAuthorizationRulesCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/relay/2021-11-01/namespaces/method_listauthorizationrules_autorest.go b/resource-manager/relay/2021-11-01/namespaces/method_listauthorizationrules_autorest.go deleted file mode 100644 index 39e6b9d4eca..00000000000 --- a/resource-manager/relay/2021-11-01/namespaces/method_listauthorizationrules_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package namespaces - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListAuthorizationRulesOperationResponse struct { - HttpResponse *http.Response - Model *[]AuthorizationRule - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListAuthorizationRulesOperationResponse, error) -} - -type ListAuthorizationRulesCompleteResult struct { - Items []AuthorizationRule -} - -func (r ListAuthorizationRulesOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListAuthorizationRulesOperationResponse) LoadMore(ctx context.Context) (resp ListAuthorizationRulesOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListAuthorizationRules ... -func (c NamespacesClient) ListAuthorizationRules(ctx context.Context, id NamespaceId) (resp ListAuthorizationRulesOperationResponse, err error) { - req, err := c.preparerForListAuthorizationRules(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "ListAuthorizationRules", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "ListAuthorizationRules", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListAuthorizationRules(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "ListAuthorizationRules", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListAuthorizationRules prepares the ListAuthorizationRules request. -func (c NamespacesClient) preparerForListAuthorizationRules(ctx context.Context, id NamespaceId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/authorizationRules", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListAuthorizationRulesWithNextLink prepares the ListAuthorizationRules request with the given nextLink token. -func (c NamespacesClient) preparerForListAuthorizationRulesWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListAuthorizationRules handles the response to the ListAuthorizationRules request. The method always -// closes the http.Response Body. -func (c NamespacesClient) responderForListAuthorizationRules(resp *http.Response) (result ListAuthorizationRulesOperationResponse, err error) { - type page struct { - Values []AuthorizationRule `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListAuthorizationRulesOperationResponse, err error) { - req, err := c.preparerForListAuthorizationRulesWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "ListAuthorizationRules", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "ListAuthorizationRules", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListAuthorizationRules(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "ListAuthorizationRules", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListAuthorizationRulesComplete retrieves all of the results into a single object -func (c NamespacesClient) ListAuthorizationRulesComplete(ctx context.Context, id NamespaceId) (ListAuthorizationRulesCompleteResult, error) { - return c.ListAuthorizationRulesCompleteMatchingPredicate(ctx, id, AuthorizationRuleOperationPredicate{}) -} - -// ListAuthorizationRulesCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c NamespacesClient) ListAuthorizationRulesCompleteMatchingPredicate(ctx context.Context, id NamespaceId, predicate AuthorizationRuleOperationPredicate) (resp ListAuthorizationRulesCompleteResult, err error) { - items := make([]AuthorizationRule, 0) - - page, err := c.ListAuthorizationRules(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListAuthorizationRulesCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/relay/2021-11-01/namespaces/method_listbyresourcegroup.go b/resource-manager/relay/2021-11-01/namespaces/method_listbyresourcegroup.go new file mode 100644 index 00000000000..90ed4ad4844 --- /dev/null +++ b/resource-manager/relay/2021-11-01/namespaces/method_listbyresourcegroup.go @@ -0,0 +1,90 @@ +package namespaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RelayNamespace +} + +type ListByResourceGroupCompleteResult struct { + Items []RelayNamespace +} + +// ListByResourceGroup ... +func (c NamespacesClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Relay/namespaces", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]RelayNamespace `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c NamespacesClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, RelayNamespaceOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NamespacesClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate RelayNamespaceOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]RelayNamespace, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/relay/2021-11-01/namespaces/method_listbyresourcegroup_autorest.go b/resource-manager/relay/2021-11-01/namespaces/method_listbyresourcegroup_autorest.go deleted file mode 100644 index e1248f2d5aa..00000000000 --- a/resource-manager/relay/2021-11-01/namespaces/method_listbyresourcegroup_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package namespaces - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByResourceGroupOperationResponse struct { - HttpResponse *http.Response - Model *[]RelayNamespace - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByResourceGroupOperationResponse, error) -} - -type ListByResourceGroupCompleteResult struct { - Items []RelayNamespace -} - -func (r ListByResourceGroupOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByResourceGroupOperationResponse) LoadMore(ctx context.Context) (resp ListByResourceGroupOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByResourceGroup ... -func (c NamespacesClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (resp ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroup(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "ListByResourceGroup", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByResourceGroup(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "ListByResourceGroup", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByResourceGroup prepares the ListByResourceGroup request. -func (c NamespacesClient) preparerForListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Relay/namespaces", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByResourceGroupWithNextLink prepares the ListByResourceGroup request with the given nextLink token. -func (c NamespacesClient) preparerForListByResourceGroupWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByResourceGroup handles the response to the ListByResourceGroup request. The method always -// closes the http.Response Body. -func (c NamespacesClient) responderForListByResourceGroup(resp *http.Response) (result ListByResourceGroupOperationResponse, err error) { - type page struct { - Values []RelayNamespace `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroupWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "ListByResourceGroup", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByResourceGroup(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "ListByResourceGroup", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByResourceGroupComplete retrieves all of the results into a single object -func (c NamespacesClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { - return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, RelayNamespaceOperationPredicate{}) -} - -// ListByResourceGroupCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c NamespacesClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate RelayNamespaceOperationPredicate) (resp ListByResourceGroupCompleteResult, err error) { - items := make([]RelayNamespace, 0) - - page, err := c.ListByResourceGroup(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByResourceGroupCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/relay/2021-11-01/namespaces/method_listkeys.go b/resource-manager/relay/2021-11-01/namespaces/method_listkeys.go new file mode 100644 index 00000000000..4d4fc5509dd --- /dev/null +++ b/resource-manager/relay/2021-11-01/namespaces/method_listkeys.go @@ -0,0 +1,52 @@ +package namespaces + +import ( + "context" + "fmt" + "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 ListKeysOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AccessKeys +} + +// ListKeys ... +func (c NamespacesClient) ListKeys(ctx context.Context, id AuthorizationRuleId) (result ListKeysOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listKeys", 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 +} diff --git a/resource-manager/relay/2021-11-01/namespaces/method_listkeys_autorest.go b/resource-manager/relay/2021-11-01/namespaces/method_listkeys_autorest.go deleted file mode 100644 index 5dfd71ec198..00000000000 --- a/resource-manager/relay/2021-11-01/namespaces/method_listkeys_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package namespaces - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListKeysOperationResponse struct { - HttpResponse *http.Response - Model *AccessKeys -} - -// ListKeys ... -func (c NamespacesClient) ListKeys(ctx context.Context, id AuthorizationRuleId) (result ListKeysOperationResponse, err error) { - req, err := c.preparerForListKeys(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "ListKeys", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "ListKeys", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListKeys(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "ListKeys", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListKeys prepares the ListKeys request. -func (c NamespacesClient) preparerForListKeys(ctx context.Context, id AuthorizationRuleId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/listKeys", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListKeys handles the response to the ListKeys request. The method always -// closes the http.Response Body. -func (c NamespacesClient) responderForListKeys(resp *http.Response) (result ListKeysOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/relay/2021-11-01/namespaces/method_regeneratekeys.go b/resource-manager/relay/2021-11-01/namespaces/method_regeneratekeys.go new file mode 100644 index 00000000000..2f8667ac338 --- /dev/null +++ b/resource-manager/relay/2021-11-01/namespaces/method_regeneratekeys.go @@ -0,0 +1,56 @@ +package namespaces + +import ( + "context" + "fmt" + "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 RegenerateKeysOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AccessKeys +} + +// RegenerateKeys ... +func (c NamespacesClient) RegenerateKeys(ctx context.Context, id AuthorizationRuleId, input RegenerateAccessKeyParameters) (result RegenerateKeysOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/regenerateKeys", 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 +} diff --git a/resource-manager/relay/2021-11-01/namespaces/method_regeneratekeys_autorest.go b/resource-manager/relay/2021-11-01/namespaces/method_regeneratekeys_autorest.go deleted file mode 100644 index 4f9dd06f42a..00000000000 --- a/resource-manager/relay/2021-11-01/namespaces/method_regeneratekeys_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package namespaces - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type RegenerateKeysOperationResponse struct { - HttpResponse *http.Response - Model *AccessKeys -} - -// RegenerateKeys ... -func (c NamespacesClient) RegenerateKeys(ctx context.Context, id AuthorizationRuleId, input RegenerateAccessKeyParameters) (result RegenerateKeysOperationResponse, err error) { - req, err := c.preparerForRegenerateKeys(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "RegenerateKeys", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "RegenerateKeys", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForRegenerateKeys(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "RegenerateKeys", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForRegenerateKeys prepares the RegenerateKeys request. -func (c NamespacesClient) preparerForRegenerateKeys(ctx context.Context, id AuthorizationRuleId, input RegenerateAccessKeyParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/regenerateKeys", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForRegenerateKeys handles the response to the RegenerateKeys request. The method always -// closes the http.Response Body. -func (c NamespacesClient) responderForRegenerateKeys(resp *http.Response) (result RegenerateKeysOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/relay/2021-11-01/namespaces/method_update.go b/resource-manager/relay/2021-11-01/namespaces/method_update.go new file mode 100644 index 00000000000..4ffff26b5b3 --- /dev/null +++ b/resource-manager/relay/2021-11-01/namespaces/method_update.go @@ -0,0 +1,56 @@ +package namespaces + +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 UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RelayNamespace +} + +// Update ... +func (c NamespacesClient) Update(ctx context.Context, id NamespaceId, input RelayUpdateParameters) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + 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 +} diff --git a/resource-manager/relay/2021-11-01/namespaces/method_update_autorest.go b/resource-manager/relay/2021-11-01/namespaces/method_update_autorest.go deleted file mode 100644 index cf1ca8cfd12..00000000000 --- a/resource-manager/relay/2021-11-01/namespaces/method_update_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package namespaces - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateOperationResponse struct { - HttpResponse *http.Response - Model *RelayNamespace -} - -// Update ... -func (c NamespacesClient) Update(ctx context.Context, id NamespaceId, input RelayUpdateParameters) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "namespaces.NamespacesClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c NamespacesClient) preparerForUpdate(ctx context.Context, id NamespaceId, input RelayUpdateParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdate handles the response to the Update request. The method always -// closes the http.Response Body. -func (c NamespacesClient) responderForUpdate(resp *http.Response) (result UpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/relay/2021-11-01/namespacesprivateendpointconnections/client.go b/resource-manager/relay/2021-11-01/namespacesprivateendpointconnections/client.go index 352e7dabd1b..b6799829ed0 100644 --- a/resource-manager/relay/2021-11-01/namespacesprivateendpointconnections/client.go +++ b/resource-manager/relay/2021-11-01/namespacesprivateendpointconnections/client.go @@ -1,18 +1,26 @@ package namespacesprivateendpointconnections -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 NamespacesPrivateEndpointConnectionsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewNamespacesPrivateEndpointConnectionsClientWithBaseURI(endpoint string) NamespacesPrivateEndpointConnectionsClient { - return NamespacesPrivateEndpointConnectionsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewNamespacesPrivateEndpointConnectionsClientWithBaseURI(api environments.Api) (*NamespacesPrivateEndpointConnectionsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "namespacesprivateendpointconnections", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating NamespacesPrivateEndpointConnectionsClient: %+v", err) } + + return &NamespacesPrivateEndpointConnectionsClient{ + Client: client, + }, nil } diff --git a/resource-manager/relay/2021-11-01/namespacesprivateendpointconnections/constants.go b/resource-manager/relay/2021-11-01/namespacesprivateendpointconnections/constants.go index cc6848f2b9b..69cf399ad3f 100644 --- a/resource-manager/relay/2021-11-01/namespacesprivateendpointconnections/constants.go +++ b/resource-manager/relay/2021-11-01/namespacesprivateendpointconnections/constants.go @@ -1,6 +1,10 @@ package namespacesprivateendpointconnections -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. @@ -27,6 +31,19 @@ func PossibleValuesForEndPointProvisioningState() []string { } } +func (s *EndPointProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEndPointProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseEndPointProvisioningState(input string) (*EndPointProvisioningState, error) { vals := map[string]EndPointProvisioningState{ "canceled": EndPointProvisioningStateCanceled, @@ -63,6 +80,19 @@ func PossibleValuesForPrivateLinkConnectionStatus() []string { } } +func (s *PrivateLinkConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateLinkConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePrivateLinkConnectionStatus(input string) (*PrivateLinkConnectionStatus, error) { vals := map[string]PrivateLinkConnectionStatus{ "approved": PrivateLinkConnectionStatusApproved, diff --git a/resource-manager/relay/2021-11-01/namespacesprivateendpointconnections/method_privateendpointconnectionscreateorupdate.go b/resource-manager/relay/2021-11-01/namespacesprivateendpointconnections/method_privateendpointconnectionscreateorupdate.go new file mode 100644 index 00000000000..7b2838e7ab6 --- /dev/null +++ b/resource-manager/relay/2021-11-01/namespacesprivateendpointconnections/method_privateendpointconnectionscreateorupdate.go @@ -0,0 +1,57 @@ +package namespacesprivateendpointconnections + +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 PrivateEndpointConnectionsCreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateEndpointConnection +} + +// PrivateEndpointConnectionsCreateOrUpdate ... +func (c NamespacesPrivateEndpointConnectionsClient) PrivateEndpointConnectionsCreateOrUpdate(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) (result PrivateEndpointConnectionsCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} diff --git a/resource-manager/relay/2021-11-01/namespacesprivateendpointconnections/method_privateendpointconnectionscreateorupdate_autorest.go b/resource-manager/relay/2021-11-01/namespacesprivateendpointconnections/method_privateendpointconnectionscreateorupdate_autorest.go deleted file mode 100644 index 636b3b31a89..00000000000 --- a/resource-manager/relay/2021-11-01/namespacesprivateendpointconnections/method_privateendpointconnectionscreateorupdate_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package namespacesprivateendpointconnections - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PrivateEndpointConnectionsCreateOrUpdateOperationResponse struct { - HttpResponse *http.Response - Model *PrivateEndpointConnection -} - -// PrivateEndpointConnectionsCreateOrUpdate ... -func (c NamespacesPrivateEndpointConnectionsClient) PrivateEndpointConnectionsCreateOrUpdate(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) (result PrivateEndpointConnectionsCreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForPrivateEndpointConnectionsCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "namespacesprivateendpointconnections.NamespacesPrivateEndpointConnectionsClient", "PrivateEndpointConnectionsCreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "namespacesprivateendpointconnections.NamespacesPrivateEndpointConnectionsClient", "PrivateEndpointConnectionsCreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForPrivateEndpointConnectionsCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "namespacesprivateendpointconnections.NamespacesPrivateEndpointConnectionsClient", "PrivateEndpointConnectionsCreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForPrivateEndpointConnectionsCreateOrUpdate prepares the PrivateEndpointConnectionsCreateOrUpdate request. -func (c NamespacesPrivateEndpointConnectionsClient) preparerForPrivateEndpointConnectionsCreateOrUpdate(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForPrivateEndpointConnectionsCreateOrUpdate handles the response to the PrivateEndpointConnectionsCreateOrUpdate request. The method always -// closes the http.Response Body. -func (c NamespacesPrivateEndpointConnectionsClient) responderForPrivateEndpointConnectionsCreateOrUpdate(resp *http.Response) (result PrivateEndpointConnectionsCreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/relay/2021-11-01/namespacesprivateendpointconnections/method_privateendpointconnectionsdelete.go b/resource-manager/relay/2021-11-01/namespacesprivateendpointconnections/method_privateendpointconnectionsdelete.go new file mode 100644 index 00000000000..1859d54f033 --- /dev/null +++ b/resource-manager/relay/2021-11-01/namespacesprivateendpointconnections/method_privateendpointconnectionsdelete.go @@ -0,0 +1,71 @@ +package namespacesprivateendpointconnections + +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 PrivateEndpointConnectionsDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// PrivateEndpointConnectionsDelete ... +func (c NamespacesPrivateEndpointConnectionsClient) PrivateEndpointConnectionsDelete(ctx context.Context, id PrivateEndpointConnectionId) (result PrivateEndpointConnectionsDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 +} + +// PrivateEndpointConnectionsDeleteThenPoll performs PrivateEndpointConnectionsDelete then polls until it's completed +func (c NamespacesPrivateEndpointConnectionsClient) PrivateEndpointConnectionsDeleteThenPoll(ctx context.Context, id PrivateEndpointConnectionId) error { + result, err := c.PrivateEndpointConnectionsDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing PrivateEndpointConnectionsDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after PrivateEndpointConnectionsDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/relay/2021-11-01/namespacesprivateendpointconnections/method_privateendpointconnectionsdelete_autorest.go b/resource-manager/relay/2021-11-01/namespacesprivateendpointconnections/method_privateendpointconnectionsdelete_autorest.go deleted file mode 100644 index 96e55056dd4..00000000000 --- a/resource-manager/relay/2021-11-01/namespacesprivateendpointconnections/method_privateendpointconnectionsdelete_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package namespacesprivateendpointconnections - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PrivateEndpointConnectionsDeleteOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// PrivateEndpointConnectionsDelete ... -func (c NamespacesPrivateEndpointConnectionsClient) PrivateEndpointConnectionsDelete(ctx context.Context, id PrivateEndpointConnectionId) (result PrivateEndpointConnectionsDeleteOperationResponse, err error) { - req, err := c.preparerForPrivateEndpointConnectionsDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "namespacesprivateendpointconnections.NamespacesPrivateEndpointConnectionsClient", "PrivateEndpointConnectionsDelete", nil, "Failure preparing request") - return - } - - result, err = c.senderForPrivateEndpointConnectionsDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "namespacesprivateendpointconnections.NamespacesPrivateEndpointConnectionsClient", "PrivateEndpointConnectionsDelete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// PrivateEndpointConnectionsDeleteThenPoll performs PrivateEndpointConnectionsDelete then polls until it's completed -func (c NamespacesPrivateEndpointConnectionsClient) PrivateEndpointConnectionsDeleteThenPoll(ctx context.Context, id PrivateEndpointConnectionId) error { - result, err := c.PrivateEndpointConnectionsDelete(ctx, id) - if err != nil { - return fmt.Errorf("performing PrivateEndpointConnectionsDelete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after PrivateEndpointConnectionsDelete: %+v", err) - } - - return nil -} - -// preparerForPrivateEndpointConnectionsDelete prepares the PrivateEndpointConnectionsDelete request. -func (c NamespacesPrivateEndpointConnectionsClient) preparerForPrivateEndpointConnectionsDelete(ctx context.Context, id PrivateEndpointConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForPrivateEndpointConnectionsDelete sends the PrivateEndpointConnectionsDelete request. The method will close the -// http.Response Body if it receives an error. -func (c NamespacesPrivateEndpointConnectionsClient) senderForPrivateEndpointConnectionsDelete(ctx context.Context, req *http.Request) (future PrivateEndpointConnectionsDeleteOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/relay/2021-11-01/namespacesprivateendpointconnections/method_privateendpointconnectionsget.go b/resource-manager/relay/2021-11-01/namespacesprivateendpointconnections/method_privateendpointconnectionsget.go new file mode 100644 index 00000000000..981831665a3 --- /dev/null +++ b/resource-manager/relay/2021-11-01/namespacesprivateendpointconnections/method_privateendpointconnectionsget.go @@ -0,0 +1,51 @@ +package namespacesprivateendpointconnections + +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 PrivateEndpointConnectionsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateEndpointConnection +} + +// PrivateEndpointConnectionsGet ... +func (c NamespacesPrivateEndpointConnectionsClient) PrivateEndpointConnectionsGet(ctx context.Context, id PrivateEndpointConnectionId) (result PrivateEndpointConnectionsGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/relay/2021-11-01/namespacesprivateendpointconnections/method_privateendpointconnectionsget_autorest.go b/resource-manager/relay/2021-11-01/namespacesprivateendpointconnections/method_privateendpointconnectionsget_autorest.go deleted file mode 100644 index 5b3261b94ba..00000000000 --- a/resource-manager/relay/2021-11-01/namespacesprivateendpointconnections/method_privateendpointconnectionsget_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package namespacesprivateendpointconnections - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PrivateEndpointConnectionsGetOperationResponse struct { - HttpResponse *http.Response - Model *PrivateEndpointConnection -} - -// PrivateEndpointConnectionsGet ... -func (c NamespacesPrivateEndpointConnectionsClient) PrivateEndpointConnectionsGet(ctx context.Context, id PrivateEndpointConnectionId) (result PrivateEndpointConnectionsGetOperationResponse, err error) { - req, err := c.preparerForPrivateEndpointConnectionsGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "namespacesprivateendpointconnections.NamespacesPrivateEndpointConnectionsClient", "PrivateEndpointConnectionsGet", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "namespacesprivateendpointconnections.NamespacesPrivateEndpointConnectionsClient", "PrivateEndpointConnectionsGet", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForPrivateEndpointConnectionsGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "namespacesprivateendpointconnections.NamespacesPrivateEndpointConnectionsClient", "PrivateEndpointConnectionsGet", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForPrivateEndpointConnectionsGet prepares the PrivateEndpointConnectionsGet request. -func (c NamespacesPrivateEndpointConnectionsClient) preparerForPrivateEndpointConnectionsGet(ctx context.Context, id PrivateEndpointConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForPrivateEndpointConnectionsGet handles the response to the PrivateEndpointConnectionsGet request. The method always -// closes the http.Response Body. -func (c NamespacesPrivateEndpointConnectionsClient) responderForPrivateEndpointConnectionsGet(resp *http.Response) (result PrivateEndpointConnectionsGetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/relay/2021-11-01/namespacesprivateendpointconnections/method_privateendpointconnectionslist.go b/resource-manager/relay/2021-11-01/namespacesprivateendpointconnections/method_privateendpointconnectionslist.go new file mode 100644 index 00000000000..6af2143f3f7 --- /dev/null +++ b/resource-manager/relay/2021-11-01/namespacesprivateendpointconnections/method_privateendpointconnectionslist.go @@ -0,0 +1,89 @@ +package namespacesprivateendpointconnections + +import ( + "context" + "fmt" + "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 PrivateEndpointConnectionsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PrivateEndpointConnection +} + +type PrivateEndpointConnectionsListCompleteResult struct { + Items []PrivateEndpointConnection +} + +// PrivateEndpointConnectionsList ... +func (c NamespacesPrivateEndpointConnectionsClient) PrivateEndpointConnectionsList(ctx context.Context, id NamespaceId) (result PrivateEndpointConnectionsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateEndpointConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PrivateEndpointConnection `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// PrivateEndpointConnectionsListComplete retrieves all the results into a single object +func (c NamespacesPrivateEndpointConnectionsClient) PrivateEndpointConnectionsListComplete(ctx context.Context, id NamespaceId) (PrivateEndpointConnectionsListCompleteResult, error) { + return c.PrivateEndpointConnectionsListCompleteMatchingPredicate(ctx, id, PrivateEndpointConnectionOperationPredicate{}) +} + +// PrivateEndpointConnectionsListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NamespacesPrivateEndpointConnectionsClient) PrivateEndpointConnectionsListCompleteMatchingPredicate(ctx context.Context, id NamespaceId, predicate PrivateEndpointConnectionOperationPredicate) (result PrivateEndpointConnectionsListCompleteResult, err error) { + items := make([]PrivateEndpointConnection, 0) + + resp, err := c.PrivateEndpointConnectionsList(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = PrivateEndpointConnectionsListCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/relay/2021-11-01/namespacesprivateendpointconnections/method_privateendpointconnectionslist_autorest.go b/resource-manager/relay/2021-11-01/namespacesprivateendpointconnections/method_privateendpointconnectionslist_autorest.go deleted file mode 100644 index 4a31dedf025..00000000000 --- a/resource-manager/relay/2021-11-01/namespacesprivateendpointconnections/method_privateendpointconnectionslist_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package namespacesprivateendpointconnections - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PrivateEndpointConnectionsListOperationResponse struct { - HttpResponse *http.Response - Model *[]PrivateEndpointConnection - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (PrivateEndpointConnectionsListOperationResponse, error) -} - -type PrivateEndpointConnectionsListCompleteResult struct { - Items []PrivateEndpointConnection -} - -func (r PrivateEndpointConnectionsListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r PrivateEndpointConnectionsListOperationResponse) LoadMore(ctx context.Context) (resp PrivateEndpointConnectionsListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// PrivateEndpointConnectionsList ... -func (c NamespacesPrivateEndpointConnectionsClient) PrivateEndpointConnectionsList(ctx context.Context, id NamespaceId) (resp PrivateEndpointConnectionsListOperationResponse, err error) { - req, err := c.preparerForPrivateEndpointConnectionsList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "namespacesprivateendpointconnections.NamespacesPrivateEndpointConnectionsClient", "PrivateEndpointConnectionsList", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "namespacesprivateendpointconnections.NamespacesPrivateEndpointConnectionsClient", "PrivateEndpointConnectionsList", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForPrivateEndpointConnectionsList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "namespacesprivateendpointconnections.NamespacesPrivateEndpointConnectionsClient", "PrivateEndpointConnectionsList", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForPrivateEndpointConnectionsList prepares the PrivateEndpointConnectionsList request. -func (c NamespacesPrivateEndpointConnectionsClient) preparerForPrivateEndpointConnectionsList(ctx context.Context, id NamespaceId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/privateEndpointConnections", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForPrivateEndpointConnectionsListWithNextLink prepares the PrivateEndpointConnectionsList request with the given nextLink token. -func (c NamespacesPrivateEndpointConnectionsClient) preparerForPrivateEndpointConnectionsListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForPrivateEndpointConnectionsList handles the response to the PrivateEndpointConnectionsList request. The method always -// closes the http.Response Body. -func (c NamespacesPrivateEndpointConnectionsClient) responderForPrivateEndpointConnectionsList(resp *http.Response) (result PrivateEndpointConnectionsListOperationResponse, err error) { - type page struct { - Values []PrivateEndpointConnection `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result PrivateEndpointConnectionsListOperationResponse, err error) { - req, err := c.preparerForPrivateEndpointConnectionsListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "namespacesprivateendpointconnections.NamespacesPrivateEndpointConnectionsClient", "PrivateEndpointConnectionsList", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "namespacesprivateendpointconnections.NamespacesPrivateEndpointConnectionsClient", "PrivateEndpointConnectionsList", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForPrivateEndpointConnectionsList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "namespacesprivateendpointconnections.NamespacesPrivateEndpointConnectionsClient", "PrivateEndpointConnectionsList", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// PrivateEndpointConnectionsListComplete retrieves all of the results into a single object -func (c NamespacesPrivateEndpointConnectionsClient) PrivateEndpointConnectionsListComplete(ctx context.Context, id NamespaceId) (PrivateEndpointConnectionsListCompleteResult, error) { - return c.PrivateEndpointConnectionsListCompleteMatchingPredicate(ctx, id, PrivateEndpointConnectionOperationPredicate{}) -} - -// PrivateEndpointConnectionsListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c NamespacesPrivateEndpointConnectionsClient) PrivateEndpointConnectionsListCompleteMatchingPredicate(ctx context.Context, id NamespaceId, predicate PrivateEndpointConnectionOperationPredicate) (resp PrivateEndpointConnectionsListCompleteResult, err error) { - items := make([]PrivateEndpointConnection, 0) - - page, err := c.PrivateEndpointConnectionsList(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := PrivateEndpointConnectionsListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/relay/2021-11-01/namespacesprivatelinkresources/client.go b/resource-manager/relay/2021-11-01/namespacesprivatelinkresources/client.go index c6c325f59cd..91bf1934f90 100644 --- a/resource-manager/relay/2021-11-01/namespacesprivatelinkresources/client.go +++ b/resource-manager/relay/2021-11-01/namespacesprivatelinkresources/client.go @@ -1,18 +1,26 @@ package namespacesprivatelinkresources -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 NamespacesPrivateLinkResourcesClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewNamespacesPrivateLinkResourcesClientWithBaseURI(endpoint string) NamespacesPrivateLinkResourcesClient { - return NamespacesPrivateLinkResourcesClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewNamespacesPrivateLinkResourcesClientWithBaseURI(api environments.Api) (*NamespacesPrivateLinkResourcesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "namespacesprivatelinkresources", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating NamespacesPrivateLinkResourcesClient: %+v", err) } + + return &NamespacesPrivateLinkResourcesClient{ + Client: client, + }, nil } diff --git a/resource-manager/relay/2021-11-01/namespacesprivatelinkresources/method_privatelinkresourcesget.go b/resource-manager/relay/2021-11-01/namespacesprivatelinkresources/method_privatelinkresourcesget.go new file mode 100644 index 00000000000..cca83a2c36f --- /dev/null +++ b/resource-manager/relay/2021-11-01/namespacesprivatelinkresources/method_privatelinkresourcesget.go @@ -0,0 +1,51 @@ +package namespacesprivatelinkresources + +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 PrivateLinkResourcesGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateLinkResource +} + +// PrivateLinkResourcesGet ... +func (c NamespacesPrivateLinkResourcesClient) PrivateLinkResourcesGet(ctx context.Context, id PrivateLinkResourceId) (result PrivateLinkResourcesGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/relay/2021-11-01/namespacesprivatelinkresources/method_privatelinkresourcesget_autorest.go b/resource-manager/relay/2021-11-01/namespacesprivatelinkresources/method_privatelinkresourcesget_autorest.go deleted file mode 100644 index aabb5499925..00000000000 --- a/resource-manager/relay/2021-11-01/namespacesprivatelinkresources/method_privatelinkresourcesget_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package namespacesprivatelinkresources - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PrivateLinkResourcesGetOperationResponse struct { - HttpResponse *http.Response - Model *PrivateLinkResource -} - -// PrivateLinkResourcesGet ... -func (c NamespacesPrivateLinkResourcesClient) PrivateLinkResourcesGet(ctx context.Context, id PrivateLinkResourceId) (result PrivateLinkResourcesGetOperationResponse, err error) { - req, err := c.preparerForPrivateLinkResourcesGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "namespacesprivatelinkresources.NamespacesPrivateLinkResourcesClient", "PrivateLinkResourcesGet", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "namespacesprivatelinkresources.NamespacesPrivateLinkResourcesClient", "PrivateLinkResourcesGet", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForPrivateLinkResourcesGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "namespacesprivatelinkresources.NamespacesPrivateLinkResourcesClient", "PrivateLinkResourcesGet", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForPrivateLinkResourcesGet prepares the PrivateLinkResourcesGet request. -func (c NamespacesPrivateLinkResourcesClient) preparerForPrivateLinkResourcesGet(ctx context.Context, id PrivateLinkResourceId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForPrivateLinkResourcesGet handles the response to the PrivateLinkResourcesGet request. The method always -// closes the http.Response Body. -func (c NamespacesPrivateLinkResourcesClient) responderForPrivateLinkResourcesGet(resp *http.Response) (result PrivateLinkResourcesGetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/relay/2021-11-01/namespacesprivatelinkresources/method_privatelinkresourceslist.go b/resource-manager/relay/2021-11-01/namespacesprivatelinkresources/method_privatelinkresourceslist.go new file mode 100644 index 00000000000..7b0e138a519 --- /dev/null +++ b/resource-manager/relay/2021-11-01/namespacesprivatelinkresources/method_privatelinkresourceslist.go @@ -0,0 +1,52 @@ +package namespacesprivatelinkresources + +import ( + "context" + "fmt" + "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 PrivateLinkResourcesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateLinkResourcesListResult +} + +// PrivateLinkResourcesList ... +func (c NamespacesPrivateLinkResourcesClient) PrivateLinkResourcesList(ctx context.Context, id NamespaceId) (result PrivateLinkResourcesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateLinkResources", 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 +} diff --git a/resource-manager/relay/2021-11-01/namespacesprivatelinkresources/method_privatelinkresourceslist_autorest.go b/resource-manager/relay/2021-11-01/namespacesprivatelinkresources/method_privatelinkresourceslist_autorest.go deleted file mode 100644 index 18d89c97d67..00000000000 --- a/resource-manager/relay/2021-11-01/namespacesprivatelinkresources/method_privatelinkresourceslist_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package namespacesprivatelinkresources - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PrivateLinkResourcesListOperationResponse struct { - HttpResponse *http.Response - Model *PrivateLinkResourcesListResult -} - -// PrivateLinkResourcesList ... -func (c NamespacesPrivateLinkResourcesClient) PrivateLinkResourcesList(ctx context.Context, id NamespaceId) (result PrivateLinkResourcesListOperationResponse, err error) { - req, err := c.preparerForPrivateLinkResourcesList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "namespacesprivatelinkresources.NamespacesPrivateLinkResourcesClient", "PrivateLinkResourcesList", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "namespacesprivatelinkresources.NamespacesPrivateLinkResourcesClient", "PrivateLinkResourcesList", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForPrivateLinkResourcesList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "namespacesprivatelinkresources.NamespacesPrivateLinkResourcesClient", "PrivateLinkResourcesList", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForPrivateLinkResourcesList prepares the PrivateLinkResourcesList request. -func (c NamespacesPrivateLinkResourcesClient) preparerForPrivateLinkResourcesList(ctx context.Context, id NamespaceId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/privateLinkResources", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForPrivateLinkResourcesList handles the response to the PrivateLinkResourcesList request. The method always -// closes the http.Response Body. -func (c NamespacesPrivateLinkResourcesClient) responderForPrivateLinkResourcesList(resp *http.Response) (result PrivateLinkResourcesListOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/relay/2021-11-01/wcfrelays/client.go b/resource-manager/relay/2021-11-01/wcfrelays/client.go index 1f541cc4209..9e151c39a16 100644 --- a/resource-manager/relay/2021-11-01/wcfrelays/client.go +++ b/resource-manager/relay/2021-11-01/wcfrelays/client.go @@ -1,18 +1,26 @@ package wcfrelays -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 WCFRelaysClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewWCFRelaysClientWithBaseURI(endpoint string) WCFRelaysClient { - return WCFRelaysClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewWCFRelaysClientWithBaseURI(api environments.Api) (*WCFRelaysClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "wcfrelays", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating WCFRelaysClient: %+v", err) } + + return &WCFRelaysClient{ + Client: client, + }, nil } diff --git a/resource-manager/relay/2021-11-01/wcfrelays/constants.go b/resource-manager/relay/2021-11-01/wcfrelays/constants.go index aa1fc8c65ac..26a898b6bed 100644 --- a/resource-manager/relay/2021-11-01/wcfrelays/constants.go +++ b/resource-manager/relay/2021-11-01/wcfrelays/constants.go @@ -1,6 +1,10 @@ package wcfrelays -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. @@ -21,6 +25,19 @@ func PossibleValuesForAccessRights() []string { } } +func (s *AccessRights) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAccessRights(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAccessRights(input string) (*AccessRights, error) { vals := map[string]AccessRights{ "listen": AccessRightsListen, @@ -50,6 +67,19 @@ func PossibleValuesForKeyType() []string { } } +func (s *KeyType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKeyType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseKeyType(input string) (*KeyType, error) { vals := map[string]KeyType{ "primarykey": KeyTypePrimaryKey, @@ -78,6 +108,19 @@ func PossibleValuesForRelaytype() []string { } } +func (s *Relaytype) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRelaytype(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseRelaytype(input string) (*Relaytype, error) { vals := map[string]Relaytype{ "http": RelaytypeHTTP, diff --git a/resource-manager/relay/2021-11-01/wcfrelays/method_createorupdate.go b/resource-manager/relay/2021-11-01/wcfrelays/method_createorupdate.go new file mode 100644 index 00000000000..8a946521af8 --- /dev/null +++ b/resource-manager/relay/2021-11-01/wcfrelays/method_createorupdate.go @@ -0,0 +1,55 @@ +package wcfrelays + +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 *WcfRelay +} + +// CreateOrUpdate ... +func (c WCFRelaysClient) CreateOrUpdate(ctx context.Context, id WcfRelayId, input WcfRelay) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 +} diff --git a/resource-manager/relay/2021-11-01/wcfrelays/method_createorupdate_autorest.go b/resource-manager/relay/2021-11-01/wcfrelays/method_createorupdate_autorest.go deleted file mode 100644 index da043d6ead9..00000000000 --- a/resource-manager/relay/2021-11-01/wcfrelays/method_createorupdate_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package wcfrelays - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// 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 - Model *WcfRelay -} - -// CreateOrUpdate ... -func (c WCFRelaysClient) CreateOrUpdate(ctx context.Context, id WcfRelayId, input WcfRelay) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c WCFRelaysClient) preparerForCreateOrUpdate(ctx context.Context, id WcfRelayId, input WcfRelay) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateOrUpdate handles the response to the CreateOrUpdate request. The method always -// closes the http.Response Body. -func (c WCFRelaysClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/relay/2021-11-01/wcfrelays/method_createorupdateauthorizationrule.go b/resource-manager/relay/2021-11-01/wcfrelays/method_createorupdateauthorizationrule.go new file mode 100644 index 00000000000..2f4af0d3ef7 --- /dev/null +++ b/resource-manager/relay/2021-11-01/wcfrelays/method_createorupdateauthorizationrule.go @@ -0,0 +1,55 @@ +package wcfrelays + +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 CreateOrUpdateAuthorizationRuleOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AuthorizationRule +} + +// CreateOrUpdateAuthorizationRule ... +func (c WCFRelaysClient) CreateOrUpdateAuthorizationRule(ctx context.Context, id WcfRelayAuthorizationRuleId, input AuthorizationRule) (result CreateOrUpdateAuthorizationRuleOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 +} diff --git a/resource-manager/relay/2021-11-01/wcfrelays/method_createorupdateauthorizationrule_autorest.go b/resource-manager/relay/2021-11-01/wcfrelays/method_createorupdateauthorizationrule_autorest.go deleted file mode 100644 index e5dd5ac7b87..00000000000 --- a/resource-manager/relay/2021-11-01/wcfrelays/method_createorupdateauthorizationrule_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package wcfrelays - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateAuthorizationRuleOperationResponse struct { - HttpResponse *http.Response - Model *AuthorizationRule -} - -// CreateOrUpdateAuthorizationRule ... -func (c WCFRelaysClient) CreateOrUpdateAuthorizationRule(ctx context.Context, id WcfRelayAuthorizationRuleId, input AuthorizationRule) (result CreateOrUpdateAuthorizationRuleOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdateAuthorizationRule(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "CreateOrUpdateAuthorizationRule", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "CreateOrUpdateAuthorizationRule", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdateAuthorizationRule(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "CreateOrUpdateAuthorizationRule", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdateAuthorizationRule prepares the CreateOrUpdateAuthorizationRule request. -func (c WCFRelaysClient) preparerForCreateOrUpdateAuthorizationRule(ctx context.Context, id WcfRelayAuthorizationRuleId, input AuthorizationRule) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateOrUpdateAuthorizationRule handles the response to the CreateOrUpdateAuthorizationRule request. The method always -// closes the http.Response Body. -func (c WCFRelaysClient) responderForCreateOrUpdateAuthorizationRule(resp *http.Response) (result CreateOrUpdateAuthorizationRuleOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/relay/2021-11-01/wcfrelays/method_delete.go b/resource-manager/relay/2021-11-01/wcfrelays/method_delete.go new file mode 100644 index 00000000000..f99797d14b3 --- /dev/null +++ b/resource-manager/relay/2021-11-01/wcfrelays/method_delete.go @@ -0,0 +1,47 @@ +package wcfrelays + +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 +} + +// Delete ... +func (c WCFRelaysClient) Delete(ctx context.Context, id WcfRelayId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 + } + + return +} diff --git a/resource-manager/relay/2021-11-01/wcfrelays/method_delete_autorest.go b/resource-manager/relay/2021-11-01/wcfrelays/method_delete_autorest.go deleted file mode 100644 index 42146e0d6da..00000000000 --- a/resource-manager/relay/2021-11-01/wcfrelays/method_delete_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package wcfrelays - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// 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 -} - -// Delete ... -func (c WCFRelaysClient) Delete(ctx context.Context, id WcfRelayId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c WCFRelaysClient) preparerForDelete(ctx context.Context, id WcfRelayId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c WCFRelaysClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/relay/2021-11-01/wcfrelays/method_deleteauthorizationrule.go b/resource-manager/relay/2021-11-01/wcfrelays/method_deleteauthorizationrule.go new file mode 100644 index 00000000000..9a276f3d10a --- /dev/null +++ b/resource-manager/relay/2021-11-01/wcfrelays/method_deleteauthorizationrule.go @@ -0,0 +1,47 @@ +package wcfrelays + +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 DeleteAuthorizationRuleOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteAuthorizationRule ... +func (c WCFRelaysClient) DeleteAuthorizationRule(ctx context.Context, id WcfRelayAuthorizationRuleId) (result DeleteAuthorizationRuleOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 + } + + return +} diff --git a/resource-manager/relay/2021-11-01/wcfrelays/method_deleteauthorizationrule_autorest.go b/resource-manager/relay/2021-11-01/wcfrelays/method_deleteauthorizationrule_autorest.go deleted file mode 100644 index c222f387d35..00000000000 --- a/resource-manager/relay/2021-11-01/wcfrelays/method_deleteauthorizationrule_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package wcfrelays - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteAuthorizationRuleOperationResponse struct { - HttpResponse *http.Response -} - -// DeleteAuthorizationRule ... -func (c WCFRelaysClient) DeleteAuthorizationRule(ctx context.Context, id WcfRelayAuthorizationRuleId) (result DeleteAuthorizationRuleOperationResponse, err error) { - req, err := c.preparerForDeleteAuthorizationRule(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "DeleteAuthorizationRule", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "DeleteAuthorizationRule", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeleteAuthorizationRule(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "DeleteAuthorizationRule", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeleteAuthorizationRule prepares the DeleteAuthorizationRule request. -func (c WCFRelaysClient) preparerForDeleteAuthorizationRule(ctx context.Context, id WcfRelayAuthorizationRuleId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeleteAuthorizationRule handles the response to the DeleteAuthorizationRule request. The method always -// closes the http.Response Body. -func (c WCFRelaysClient) responderForDeleteAuthorizationRule(resp *http.Response) (result DeleteAuthorizationRuleOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/relay/2021-11-01/wcfrelays/method_get.go b/resource-manager/relay/2021-11-01/wcfrelays/method_get.go new file mode 100644 index 00000000000..a41520b6316 --- /dev/null +++ b/resource-manager/relay/2021-11-01/wcfrelays/method_get.go @@ -0,0 +1,52 @@ +package wcfrelays + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WcfRelay +} + +// Get ... +func (c WCFRelaysClient) Get(ctx context.Context, id WcfRelayId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/relay/2021-11-01/wcfrelays/method_get_autorest.go b/resource-manager/relay/2021-11-01/wcfrelays/method_get_autorest.go deleted file mode 100644 index b119542150f..00000000000 --- a/resource-manager/relay/2021-11-01/wcfrelays/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package wcfrelays - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *WcfRelay -} - -// Get ... -func (c WCFRelaysClient) Get(ctx context.Context, id WcfRelayId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c WCFRelaysClient) preparerForGet(ctx context.Context, id WcfRelayId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c WCFRelaysClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/relay/2021-11-01/wcfrelays/method_getauthorizationrule.go b/resource-manager/relay/2021-11-01/wcfrelays/method_getauthorizationrule.go new file mode 100644 index 00000000000..e5bf04ce923 --- /dev/null +++ b/resource-manager/relay/2021-11-01/wcfrelays/method_getauthorizationrule.go @@ -0,0 +1,51 @@ +package wcfrelays + +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 GetAuthorizationRuleOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AuthorizationRule +} + +// GetAuthorizationRule ... +func (c WCFRelaysClient) GetAuthorizationRule(ctx context.Context, id WcfRelayAuthorizationRuleId) (result GetAuthorizationRuleOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/relay/2021-11-01/wcfrelays/method_getauthorizationrule_autorest.go b/resource-manager/relay/2021-11-01/wcfrelays/method_getauthorizationrule_autorest.go deleted file mode 100644 index 0defa5a466d..00000000000 --- a/resource-manager/relay/2021-11-01/wcfrelays/method_getauthorizationrule_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package wcfrelays - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetAuthorizationRuleOperationResponse struct { - HttpResponse *http.Response - Model *AuthorizationRule -} - -// GetAuthorizationRule ... -func (c WCFRelaysClient) GetAuthorizationRule(ctx context.Context, id WcfRelayAuthorizationRuleId) (result GetAuthorizationRuleOperationResponse, err error) { - req, err := c.preparerForGetAuthorizationRule(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "GetAuthorizationRule", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "GetAuthorizationRule", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetAuthorizationRule(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "GetAuthorizationRule", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetAuthorizationRule prepares the GetAuthorizationRule request. -func (c WCFRelaysClient) preparerForGetAuthorizationRule(ctx context.Context, id WcfRelayAuthorizationRuleId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetAuthorizationRule handles the response to the GetAuthorizationRule request. The method always -// closes the http.Response Body. -func (c WCFRelaysClient) responderForGetAuthorizationRule(resp *http.Response) (result GetAuthorizationRuleOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/relay/2021-11-01/wcfrelays/method_listauthorizationrules.go b/resource-manager/relay/2021-11-01/wcfrelays/method_listauthorizationrules.go new file mode 100644 index 00000000000..827435c8ddb --- /dev/null +++ b/resource-manager/relay/2021-11-01/wcfrelays/method_listauthorizationrules.go @@ -0,0 +1,89 @@ +package wcfrelays + +import ( + "context" + "fmt" + "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 ListAuthorizationRulesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AuthorizationRule +} + +type ListAuthorizationRulesCompleteResult struct { + Items []AuthorizationRule +} + +// ListAuthorizationRules ... +func (c WCFRelaysClient) ListAuthorizationRules(ctx context.Context, id WcfRelayId) (result ListAuthorizationRulesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/authorizationRules", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AuthorizationRule `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAuthorizationRulesComplete retrieves all the results into a single object +func (c WCFRelaysClient) ListAuthorizationRulesComplete(ctx context.Context, id WcfRelayId) (ListAuthorizationRulesCompleteResult, error) { + return c.ListAuthorizationRulesCompleteMatchingPredicate(ctx, id, AuthorizationRuleOperationPredicate{}) +} + +// ListAuthorizationRulesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WCFRelaysClient) ListAuthorizationRulesCompleteMatchingPredicate(ctx context.Context, id WcfRelayId, predicate AuthorizationRuleOperationPredicate) (result ListAuthorizationRulesCompleteResult, err error) { + items := make([]AuthorizationRule, 0) + + resp, err := c.ListAuthorizationRules(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListAuthorizationRulesCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/relay/2021-11-01/wcfrelays/method_listauthorizationrules_autorest.go b/resource-manager/relay/2021-11-01/wcfrelays/method_listauthorizationrules_autorest.go deleted file mode 100644 index 8eb47777305..00000000000 --- a/resource-manager/relay/2021-11-01/wcfrelays/method_listauthorizationrules_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package wcfrelays - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListAuthorizationRulesOperationResponse struct { - HttpResponse *http.Response - Model *[]AuthorizationRule - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListAuthorizationRulesOperationResponse, error) -} - -type ListAuthorizationRulesCompleteResult struct { - Items []AuthorizationRule -} - -func (r ListAuthorizationRulesOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListAuthorizationRulesOperationResponse) LoadMore(ctx context.Context) (resp ListAuthorizationRulesOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListAuthorizationRules ... -func (c WCFRelaysClient) ListAuthorizationRules(ctx context.Context, id WcfRelayId) (resp ListAuthorizationRulesOperationResponse, err error) { - req, err := c.preparerForListAuthorizationRules(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "ListAuthorizationRules", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "ListAuthorizationRules", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListAuthorizationRules(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "ListAuthorizationRules", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListAuthorizationRules prepares the ListAuthorizationRules request. -func (c WCFRelaysClient) preparerForListAuthorizationRules(ctx context.Context, id WcfRelayId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/authorizationRules", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListAuthorizationRulesWithNextLink prepares the ListAuthorizationRules request with the given nextLink token. -func (c WCFRelaysClient) preparerForListAuthorizationRulesWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListAuthorizationRules handles the response to the ListAuthorizationRules request. The method always -// closes the http.Response Body. -func (c WCFRelaysClient) responderForListAuthorizationRules(resp *http.Response) (result ListAuthorizationRulesOperationResponse, err error) { - type page struct { - Values []AuthorizationRule `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListAuthorizationRulesOperationResponse, err error) { - req, err := c.preparerForListAuthorizationRulesWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "ListAuthorizationRules", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "ListAuthorizationRules", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListAuthorizationRules(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "ListAuthorizationRules", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListAuthorizationRulesComplete retrieves all of the results into a single object -func (c WCFRelaysClient) ListAuthorizationRulesComplete(ctx context.Context, id WcfRelayId) (ListAuthorizationRulesCompleteResult, error) { - return c.ListAuthorizationRulesCompleteMatchingPredicate(ctx, id, AuthorizationRuleOperationPredicate{}) -} - -// ListAuthorizationRulesCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WCFRelaysClient) ListAuthorizationRulesCompleteMatchingPredicate(ctx context.Context, id WcfRelayId, predicate AuthorizationRuleOperationPredicate) (resp ListAuthorizationRulesCompleteResult, err error) { - items := make([]AuthorizationRule, 0) - - page, err := c.ListAuthorizationRules(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListAuthorizationRulesCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/relay/2021-11-01/wcfrelays/method_listbynamespace.go b/resource-manager/relay/2021-11-01/wcfrelays/method_listbynamespace.go new file mode 100644 index 00000000000..967f4732650 --- /dev/null +++ b/resource-manager/relay/2021-11-01/wcfrelays/method_listbynamespace.go @@ -0,0 +1,89 @@ +package wcfrelays + +import ( + "context" + "fmt" + "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 ListByNamespaceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WcfRelay +} + +type ListByNamespaceCompleteResult struct { + Items []WcfRelay +} + +// ListByNamespace ... +func (c WCFRelaysClient) ListByNamespace(ctx context.Context, id NamespaceId) (result ListByNamespaceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/wcfRelays", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]WcfRelay `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByNamespaceComplete retrieves all the results into a single object +func (c WCFRelaysClient) ListByNamespaceComplete(ctx context.Context, id NamespaceId) (ListByNamespaceCompleteResult, error) { + return c.ListByNamespaceCompleteMatchingPredicate(ctx, id, WcfRelayOperationPredicate{}) +} + +// ListByNamespaceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WCFRelaysClient) ListByNamespaceCompleteMatchingPredicate(ctx context.Context, id NamespaceId, predicate WcfRelayOperationPredicate) (result ListByNamespaceCompleteResult, err error) { + items := make([]WcfRelay, 0) + + resp, err := c.ListByNamespace(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByNamespaceCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/relay/2021-11-01/wcfrelays/method_listbynamespace_autorest.go b/resource-manager/relay/2021-11-01/wcfrelays/method_listbynamespace_autorest.go deleted file mode 100644 index 2864700ce74..00000000000 --- a/resource-manager/relay/2021-11-01/wcfrelays/method_listbynamespace_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package wcfrelays - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByNamespaceOperationResponse struct { - HttpResponse *http.Response - Model *[]WcfRelay - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByNamespaceOperationResponse, error) -} - -type ListByNamespaceCompleteResult struct { - Items []WcfRelay -} - -func (r ListByNamespaceOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByNamespaceOperationResponse) LoadMore(ctx context.Context) (resp ListByNamespaceOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByNamespace ... -func (c WCFRelaysClient) ListByNamespace(ctx context.Context, id NamespaceId) (resp ListByNamespaceOperationResponse, err error) { - req, err := c.preparerForListByNamespace(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "ListByNamespace", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "ListByNamespace", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByNamespace(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "ListByNamespace", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByNamespace prepares the ListByNamespace request. -func (c WCFRelaysClient) preparerForListByNamespace(ctx context.Context, id NamespaceId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/wcfRelays", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByNamespaceWithNextLink prepares the ListByNamespace request with the given nextLink token. -func (c WCFRelaysClient) preparerForListByNamespaceWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByNamespace handles the response to the ListByNamespace request. The method always -// closes the http.Response Body. -func (c WCFRelaysClient) responderForListByNamespace(resp *http.Response) (result ListByNamespaceOperationResponse, err error) { - type page struct { - Values []WcfRelay `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByNamespaceOperationResponse, err error) { - req, err := c.preparerForListByNamespaceWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "ListByNamespace", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "ListByNamespace", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByNamespace(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "ListByNamespace", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByNamespaceComplete retrieves all of the results into a single object -func (c WCFRelaysClient) ListByNamespaceComplete(ctx context.Context, id NamespaceId) (ListByNamespaceCompleteResult, error) { - return c.ListByNamespaceCompleteMatchingPredicate(ctx, id, WcfRelayOperationPredicate{}) -} - -// ListByNamespaceCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WCFRelaysClient) ListByNamespaceCompleteMatchingPredicate(ctx context.Context, id NamespaceId, predicate WcfRelayOperationPredicate) (resp ListByNamespaceCompleteResult, err error) { - items := make([]WcfRelay, 0) - - page, err := c.ListByNamespace(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByNamespaceCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/relay/2021-11-01/wcfrelays/method_listkeys.go b/resource-manager/relay/2021-11-01/wcfrelays/method_listkeys.go new file mode 100644 index 00000000000..c4ace582b3e --- /dev/null +++ b/resource-manager/relay/2021-11-01/wcfrelays/method_listkeys.go @@ -0,0 +1,52 @@ +package wcfrelays + +import ( + "context" + "fmt" + "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 ListKeysOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AccessKeys +} + +// ListKeys ... +func (c WCFRelaysClient) ListKeys(ctx context.Context, id WcfRelayAuthorizationRuleId) (result ListKeysOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listKeys", 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 +} diff --git a/resource-manager/relay/2021-11-01/wcfrelays/method_listkeys_autorest.go b/resource-manager/relay/2021-11-01/wcfrelays/method_listkeys_autorest.go deleted file mode 100644 index 79cfcb860a4..00000000000 --- a/resource-manager/relay/2021-11-01/wcfrelays/method_listkeys_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package wcfrelays - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListKeysOperationResponse struct { - HttpResponse *http.Response - Model *AccessKeys -} - -// ListKeys ... -func (c WCFRelaysClient) ListKeys(ctx context.Context, id WcfRelayAuthorizationRuleId) (result ListKeysOperationResponse, err error) { - req, err := c.preparerForListKeys(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "ListKeys", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "ListKeys", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListKeys(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "ListKeys", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListKeys prepares the ListKeys request. -func (c WCFRelaysClient) preparerForListKeys(ctx context.Context, id WcfRelayAuthorizationRuleId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/listKeys", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListKeys handles the response to the ListKeys request. The method always -// closes the http.Response Body. -func (c WCFRelaysClient) responderForListKeys(resp *http.Response) (result ListKeysOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/relay/2021-11-01/wcfrelays/method_regeneratekeys.go b/resource-manager/relay/2021-11-01/wcfrelays/method_regeneratekeys.go new file mode 100644 index 00000000000..46eb4be71b1 --- /dev/null +++ b/resource-manager/relay/2021-11-01/wcfrelays/method_regeneratekeys.go @@ -0,0 +1,56 @@ +package wcfrelays + +import ( + "context" + "fmt" + "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 RegenerateKeysOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AccessKeys +} + +// RegenerateKeys ... +func (c WCFRelaysClient) RegenerateKeys(ctx context.Context, id WcfRelayAuthorizationRuleId, input RegenerateAccessKeyParameters) (result RegenerateKeysOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/regenerateKeys", 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 +} diff --git a/resource-manager/relay/2021-11-01/wcfrelays/method_regeneratekeys_autorest.go b/resource-manager/relay/2021-11-01/wcfrelays/method_regeneratekeys_autorest.go deleted file mode 100644 index f8303131211..00000000000 --- a/resource-manager/relay/2021-11-01/wcfrelays/method_regeneratekeys_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package wcfrelays - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type RegenerateKeysOperationResponse struct { - HttpResponse *http.Response - Model *AccessKeys -} - -// RegenerateKeys ... -func (c WCFRelaysClient) RegenerateKeys(ctx context.Context, id WcfRelayAuthorizationRuleId, input RegenerateAccessKeyParameters) (result RegenerateKeysOperationResponse, err error) { - req, err := c.preparerForRegenerateKeys(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "RegenerateKeys", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "RegenerateKeys", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForRegenerateKeys(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "wcfrelays.WCFRelaysClient", "RegenerateKeys", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForRegenerateKeys prepares the RegenerateKeys request. -func (c WCFRelaysClient) preparerForRegenerateKeys(ctx context.Context, id WcfRelayAuthorizationRuleId, input RegenerateAccessKeyParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/regenerateKeys", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForRegenerateKeys handles the response to the RegenerateKeys request. The method always -// closes the http.Response Body. -func (c WCFRelaysClient) responderForRegenerateKeys(resp *http.Response) (result RegenerateKeysOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2016-06-01/client.go b/resource-manager/web/2016-06-01/client.go index e177f585326..27cd5338d38 100644 --- a/resource-manager/web/2016-06-01/client.go +++ b/resource-manager/web/2016-06-01/client.go @@ -4,11 +4,14 @@ package v2016_06_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/web/2016-06-01/connectiongateways" "github.com/hashicorp/go-azure-sdk/resource-manager/web/2016-06-01/connections" "github.com/hashicorp/go-azure-sdk/resource-manager/web/2016-06-01/customapis" "github.com/hashicorp/go-azure-sdk/resource-manager/web/2016-06-01/managedapis" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/environments" ) type Client struct { @@ -18,24 +21,35 @@ type Client struct { ManagedAPIs *managedapis.ManagedAPIsClient } -func NewClientWithBaseURI(endpoint string, configureAuthFunc func(c *autorest.Client)) Client { - - connectionGatewaysClient := connectiongateways.NewConnectionGatewaysClientWithBaseURI(endpoint) - configureAuthFunc(&connectionGatewaysClient.Client) - - connectionsClient := connections.NewConnectionsClientWithBaseURI(endpoint) - configureAuthFunc(&connectionsClient.Client) +func NewClientWithBaseURI(api environments.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + connectionGatewaysClient, err := connectiongateways.NewConnectionGatewaysClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ConnectionGateways client: %+v", err) + } + configureFunc(connectionGatewaysClient.Client) - customAPIsClient := customapis.NewCustomAPIsClientWithBaseURI(endpoint) - configureAuthFunc(&customAPIsClient.Client) + connectionsClient, err := connections.NewConnectionsClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Connections client: %+v", err) + } + configureFunc(connectionsClient.Client) - managedAPIsClient := managedapis.NewManagedAPIsClientWithBaseURI(endpoint) - configureAuthFunc(&managedAPIsClient.Client) + customAPIsClient, err := customapis.NewCustomAPIsClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building CustomAPIs client: %+v", err) + } + configureFunc(customAPIsClient.Client) - return Client{ - ConnectionGateways: &connectionGatewaysClient, - Connections: &connectionsClient, - CustomAPIs: &customAPIsClient, - ManagedAPIs: &managedAPIsClient, + managedAPIsClient, err := managedapis.NewManagedAPIsClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ManagedAPIs client: %+v", err) } + configureFunc(managedAPIsClient.Client) + + return &Client{ + ConnectionGateways: connectionGatewaysClient, + Connections: connectionsClient, + CustomAPIs: customAPIsClient, + ManagedAPIs: managedAPIsClient, + }, nil } diff --git a/resource-manager/web/2016-06-01/connectiongateways/client.go b/resource-manager/web/2016-06-01/connectiongateways/client.go index a288289bd79..b05d99ac7e2 100644 --- a/resource-manager/web/2016-06-01/connectiongateways/client.go +++ b/resource-manager/web/2016-06-01/connectiongateways/client.go @@ -1,18 +1,26 @@ package connectiongateways -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 ConnectionGatewaysClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewConnectionGatewaysClientWithBaseURI(endpoint string) ConnectionGatewaysClient { - return ConnectionGatewaysClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewConnectionGatewaysClientWithBaseURI(api environments.Api) (*ConnectionGatewaysClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "connectiongateways", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ConnectionGatewaysClient: %+v", err) } + + return &ConnectionGatewaysClient{ + Client: client, + }, nil } diff --git a/resource-manager/web/2016-06-01/connectiongateways/method_connectiongatewayinstallationsget.go b/resource-manager/web/2016-06-01/connectiongateways/method_connectiongatewayinstallationsget.go new file mode 100644 index 00000000000..194748f6a62 --- /dev/null +++ b/resource-manager/web/2016-06-01/connectiongateways/method_connectiongatewayinstallationsget.go @@ -0,0 +1,51 @@ +package connectiongateways + +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 ConnectionGatewayInstallationsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ConnectionGatewayInstallationDefinition +} + +// ConnectionGatewayInstallationsGet ... +func (c ConnectionGatewaysClient) ConnectionGatewayInstallationsGet(ctx context.Context, id ConnectionGatewayInstallationId) (result ConnectionGatewayInstallationsGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2016-06-01/connectiongateways/method_connectiongatewayinstallationsget_autorest.go b/resource-manager/web/2016-06-01/connectiongateways/method_connectiongatewayinstallationsget_autorest.go deleted file mode 100644 index f1964351e2b..00000000000 --- a/resource-manager/web/2016-06-01/connectiongateways/method_connectiongatewayinstallationsget_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package connectiongateways - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ConnectionGatewayInstallationsGetOperationResponse struct { - HttpResponse *http.Response - Model *ConnectionGatewayInstallationDefinition -} - -// ConnectionGatewayInstallationsGet ... -func (c ConnectionGatewaysClient) ConnectionGatewayInstallationsGet(ctx context.Context, id ConnectionGatewayInstallationId) (result ConnectionGatewayInstallationsGetOperationResponse, err error) { - req, err := c.preparerForConnectionGatewayInstallationsGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "connectiongateways.ConnectionGatewaysClient", "ConnectionGatewayInstallationsGet", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "connectiongateways.ConnectionGatewaysClient", "ConnectionGatewayInstallationsGet", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForConnectionGatewayInstallationsGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "connectiongateways.ConnectionGatewaysClient", "ConnectionGatewayInstallationsGet", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForConnectionGatewayInstallationsGet prepares the ConnectionGatewayInstallationsGet request. -func (c ConnectionGatewaysClient) preparerForConnectionGatewayInstallationsGet(ctx context.Context, id ConnectionGatewayInstallationId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForConnectionGatewayInstallationsGet handles the response to the ConnectionGatewayInstallationsGet request. The method always -// closes the http.Response Body. -func (c ConnectionGatewaysClient) responderForConnectionGatewayInstallationsGet(resp *http.Response) (result ConnectionGatewayInstallationsGetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2016-06-01/connectiongateways/method_connectiongatewayinstallationslist.go b/resource-manager/web/2016-06-01/connectiongateways/method_connectiongatewayinstallationslist.go new file mode 100644 index 00000000000..d1c6decea2b --- /dev/null +++ b/resource-manager/web/2016-06-01/connectiongateways/method_connectiongatewayinstallationslist.go @@ -0,0 +1,52 @@ +package connectiongateways + +import ( + "context" + "fmt" + "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 ConnectionGatewayInstallationsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ConnectionGatewayInstallationDefinitionCollection +} + +// ConnectionGatewayInstallationsList ... +func (c ConnectionGatewaysClient) ConnectionGatewayInstallationsList(ctx context.Context, id LocationId) (result ConnectionGatewayInstallationsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/connectionGatewayInstallations", 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 +} diff --git a/resource-manager/web/2016-06-01/connectiongateways/method_connectiongatewayinstallationslist_autorest.go b/resource-manager/web/2016-06-01/connectiongateways/method_connectiongatewayinstallationslist_autorest.go deleted file mode 100644 index 150ca562b1a..00000000000 --- a/resource-manager/web/2016-06-01/connectiongateways/method_connectiongatewayinstallationslist_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package connectiongateways - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ConnectionGatewayInstallationsListOperationResponse struct { - HttpResponse *http.Response - Model *ConnectionGatewayInstallationDefinitionCollection -} - -// ConnectionGatewayInstallationsList ... -func (c ConnectionGatewaysClient) ConnectionGatewayInstallationsList(ctx context.Context, id LocationId) (result ConnectionGatewayInstallationsListOperationResponse, err error) { - req, err := c.preparerForConnectionGatewayInstallationsList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "connectiongateways.ConnectionGatewaysClient", "ConnectionGatewayInstallationsList", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "connectiongateways.ConnectionGatewaysClient", "ConnectionGatewayInstallationsList", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForConnectionGatewayInstallationsList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "connectiongateways.ConnectionGatewaysClient", "ConnectionGatewayInstallationsList", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForConnectionGatewayInstallationsList prepares the ConnectionGatewayInstallationsList request. -func (c ConnectionGatewaysClient) preparerForConnectionGatewayInstallationsList(ctx context.Context, id LocationId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/connectionGatewayInstallations", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForConnectionGatewayInstallationsList handles the response to the ConnectionGatewayInstallationsList request. The method always -// closes the http.Response Body. -func (c ConnectionGatewaysClient) responderForConnectionGatewayInstallationsList(resp *http.Response) (result ConnectionGatewayInstallationsListOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2016-06-01/connectiongateways/method_connectiongatewayscreateorupdate.go b/resource-manager/web/2016-06-01/connectiongateways/method_connectiongatewayscreateorupdate.go new file mode 100644 index 00000000000..5918ba78952 --- /dev/null +++ b/resource-manager/web/2016-06-01/connectiongateways/method_connectiongatewayscreateorupdate.go @@ -0,0 +1,56 @@ +package connectiongateways + +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 ConnectionGatewaysCreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ConnectionGatewayDefinition +} + +// ConnectionGatewaysCreateOrUpdate ... +func (c ConnectionGatewaysClient) ConnectionGatewaysCreateOrUpdate(ctx context.Context, id ConnectionGatewayId, input ConnectionGatewayDefinition) (result ConnectionGatewaysCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 +} diff --git a/resource-manager/web/2016-06-01/connectiongateways/method_connectiongatewayscreateorupdate_autorest.go b/resource-manager/web/2016-06-01/connectiongateways/method_connectiongatewayscreateorupdate_autorest.go deleted file mode 100644 index f4153e11d06..00000000000 --- a/resource-manager/web/2016-06-01/connectiongateways/method_connectiongatewayscreateorupdate_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package connectiongateways - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ConnectionGatewaysCreateOrUpdateOperationResponse struct { - HttpResponse *http.Response - Model *ConnectionGatewayDefinition -} - -// ConnectionGatewaysCreateOrUpdate ... -func (c ConnectionGatewaysClient) ConnectionGatewaysCreateOrUpdate(ctx context.Context, id ConnectionGatewayId, input ConnectionGatewayDefinition) (result ConnectionGatewaysCreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForConnectionGatewaysCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "connectiongateways.ConnectionGatewaysClient", "ConnectionGatewaysCreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "connectiongateways.ConnectionGatewaysClient", "ConnectionGatewaysCreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForConnectionGatewaysCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "connectiongateways.ConnectionGatewaysClient", "ConnectionGatewaysCreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForConnectionGatewaysCreateOrUpdate prepares the ConnectionGatewaysCreateOrUpdate request. -func (c ConnectionGatewaysClient) preparerForConnectionGatewaysCreateOrUpdate(ctx context.Context, id ConnectionGatewayId, input ConnectionGatewayDefinition) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForConnectionGatewaysCreateOrUpdate handles the response to the ConnectionGatewaysCreateOrUpdate request. The method always -// closes the http.Response Body. -func (c ConnectionGatewaysClient) responderForConnectionGatewaysCreateOrUpdate(resp *http.Response) (result ConnectionGatewaysCreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2016-06-01/connectiongateways/method_connectiongatewaysdelete.go b/resource-manager/web/2016-06-01/connectiongateways/method_connectiongatewaysdelete.go new file mode 100644 index 00000000000..dce81c81af1 --- /dev/null +++ b/resource-manager/web/2016-06-01/connectiongateways/method_connectiongatewaysdelete.go @@ -0,0 +1,47 @@ +package connectiongateways + +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 ConnectionGatewaysDeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ConnectionGatewaysDelete ... +func (c ConnectionGatewaysClient) ConnectionGatewaysDelete(ctx context.Context, id ConnectionGatewayId) (result ConnectionGatewaysDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 + } + + return +} diff --git a/resource-manager/web/2016-06-01/connectiongateways/method_connectiongatewaysdelete_autorest.go b/resource-manager/web/2016-06-01/connectiongateways/method_connectiongatewaysdelete_autorest.go deleted file mode 100644 index 5dd030749bd..00000000000 --- a/resource-manager/web/2016-06-01/connectiongateways/method_connectiongatewaysdelete_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package connectiongateways - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ConnectionGatewaysDeleteOperationResponse struct { - HttpResponse *http.Response -} - -// ConnectionGatewaysDelete ... -func (c ConnectionGatewaysClient) ConnectionGatewaysDelete(ctx context.Context, id ConnectionGatewayId) (result ConnectionGatewaysDeleteOperationResponse, err error) { - req, err := c.preparerForConnectionGatewaysDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "connectiongateways.ConnectionGatewaysClient", "ConnectionGatewaysDelete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "connectiongateways.ConnectionGatewaysClient", "ConnectionGatewaysDelete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForConnectionGatewaysDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "connectiongateways.ConnectionGatewaysClient", "ConnectionGatewaysDelete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForConnectionGatewaysDelete prepares the ConnectionGatewaysDelete request. -func (c ConnectionGatewaysClient) preparerForConnectionGatewaysDelete(ctx context.Context, id ConnectionGatewayId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForConnectionGatewaysDelete handles the response to the ConnectionGatewaysDelete request. The method always -// closes the http.Response Body. -func (c ConnectionGatewaysClient) responderForConnectionGatewaysDelete(resp *http.Response) (result ConnectionGatewaysDeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2016-06-01/connectiongateways/method_connectiongatewaysget.go b/resource-manager/web/2016-06-01/connectiongateways/method_connectiongatewaysget.go new file mode 100644 index 00000000000..0a6ecbd34a9 --- /dev/null +++ b/resource-manager/web/2016-06-01/connectiongateways/method_connectiongatewaysget.go @@ -0,0 +1,51 @@ +package connectiongateways + +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 ConnectionGatewaysGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ConnectionGatewayDefinition +} + +// ConnectionGatewaysGet ... +func (c ConnectionGatewaysClient) ConnectionGatewaysGet(ctx context.Context, id ConnectionGatewayId) (result ConnectionGatewaysGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2016-06-01/connectiongateways/method_connectiongatewaysget_autorest.go b/resource-manager/web/2016-06-01/connectiongateways/method_connectiongatewaysget_autorest.go deleted file mode 100644 index 653f3787210..00000000000 --- a/resource-manager/web/2016-06-01/connectiongateways/method_connectiongatewaysget_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package connectiongateways - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ConnectionGatewaysGetOperationResponse struct { - HttpResponse *http.Response - Model *ConnectionGatewayDefinition -} - -// ConnectionGatewaysGet ... -func (c ConnectionGatewaysClient) ConnectionGatewaysGet(ctx context.Context, id ConnectionGatewayId) (result ConnectionGatewaysGetOperationResponse, err error) { - req, err := c.preparerForConnectionGatewaysGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "connectiongateways.ConnectionGatewaysClient", "ConnectionGatewaysGet", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "connectiongateways.ConnectionGatewaysClient", "ConnectionGatewaysGet", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForConnectionGatewaysGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "connectiongateways.ConnectionGatewaysClient", "ConnectionGatewaysGet", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForConnectionGatewaysGet prepares the ConnectionGatewaysGet request. -func (c ConnectionGatewaysClient) preparerForConnectionGatewaysGet(ctx context.Context, id ConnectionGatewayId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForConnectionGatewaysGet handles the response to the ConnectionGatewaysGet request. The method always -// closes the http.Response Body. -func (c ConnectionGatewaysClient) responderForConnectionGatewaysGet(resp *http.Response) (result ConnectionGatewaysGetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2016-06-01/connectiongateways/method_connectiongatewayslist.go b/resource-manager/web/2016-06-01/connectiongateways/method_connectiongatewayslist.go new file mode 100644 index 00000000000..f714bd35251 --- /dev/null +++ b/resource-manager/web/2016-06-01/connectiongateways/method_connectiongatewayslist.go @@ -0,0 +1,53 @@ +package connectiongateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ConnectionGatewaysListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ConnectionGatewayDefinitionCollection +} + +// ConnectionGatewaysList ... +func (c ConnectionGatewaysClient) ConnectionGatewaysList(ctx context.Context, id commonids.SubscriptionId) (result ConnectionGatewaysListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/connectionGateways", 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 +} diff --git a/resource-manager/web/2016-06-01/connectiongateways/method_connectiongatewayslist_autorest.go b/resource-manager/web/2016-06-01/connectiongateways/method_connectiongatewayslist_autorest.go deleted file mode 100644 index eda96ad86f1..00000000000 --- a/resource-manager/web/2016-06-01/connectiongateways/method_connectiongatewayslist_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package connectiongateways - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ConnectionGatewaysListOperationResponse struct { - HttpResponse *http.Response - Model *ConnectionGatewayDefinitionCollection -} - -// ConnectionGatewaysList ... -func (c ConnectionGatewaysClient) ConnectionGatewaysList(ctx context.Context, id commonids.SubscriptionId) (result ConnectionGatewaysListOperationResponse, err error) { - req, err := c.preparerForConnectionGatewaysList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "connectiongateways.ConnectionGatewaysClient", "ConnectionGatewaysList", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "connectiongateways.ConnectionGatewaysClient", "ConnectionGatewaysList", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForConnectionGatewaysList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "connectiongateways.ConnectionGatewaysClient", "ConnectionGatewaysList", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForConnectionGatewaysList prepares the ConnectionGatewaysList request. -func (c ConnectionGatewaysClient) preparerForConnectionGatewaysList(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Web/connectionGateways", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForConnectionGatewaysList handles the response to the ConnectionGatewaysList request. The method always -// closes the http.Response Body. -func (c ConnectionGatewaysClient) responderForConnectionGatewaysList(resp *http.Response) (result ConnectionGatewaysListOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2016-06-01/connectiongateways/method_connectiongatewayslistbyresourcegroup.go b/resource-manager/web/2016-06-01/connectiongateways/method_connectiongatewayslistbyresourcegroup.go new file mode 100644 index 00000000000..3a029024717 --- /dev/null +++ b/resource-manager/web/2016-06-01/connectiongateways/method_connectiongatewayslistbyresourcegroup.go @@ -0,0 +1,53 @@ +package connectiongateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ConnectionGatewaysListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ConnectionGatewayDefinitionCollection +} + +// ConnectionGatewaysListByResourceGroup ... +func (c ConnectionGatewaysClient) ConnectionGatewaysListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ConnectionGatewaysListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/connectionGateways", 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 +} diff --git a/resource-manager/web/2016-06-01/connectiongateways/method_connectiongatewayslistbyresourcegroup_autorest.go b/resource-manager/web/2016-06-01/connectiongateways/method_connectiongatewayslistbyresourcegroup_autorest.go deleted file mode 100644 index 617c5b6580a..00000000000 --- a/resource-manager/web/2016-06-01/connectiongateways/method_connectiongatewayslistbyresourcegroup_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package connectiongateways - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ConnectionGatewaysListByResourceGroupOperationResponse struct { - HttpResponse *http.Response - Model *ConnectionGatewayDefinitionCollection -} - -// ConnectionGatewaysListByResourceGroup ... -func (c ConnectionGatewaysClient) ConnectionGatewaysListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ConnectionGatewaysListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForConnectionGatewaysListByResourceGroup(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "connectiongateways.ConnectionGatewaysClient", "ConnectionGatewaysListByResourceGroup", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "connectiongateways.ConnectionGatewaysClient", "ConnectionGatewaysListByResourceGroup", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForConnectionGatewaysListByResourceGroup(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "connectiongateways.ConnectionGatewaysClient", "ConnectionGatewaysListByResourceGroup", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForConnectionGatewaysListByResourceGroup prepares the ConnectionGatewaysListByResourceGroup request. -func (c ConnectionGatewaysClient) preparerForConnectionGatewaysListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Web/connectionGateways", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForConnectionGatewaysListByResourceGroup handles the response to the ConnectionGatewaysListByResourceGroup request. The method always -// closes the http.Response Body. -func (c ConnectionGatewaysClient) responderForConnectionGatewaysListByResourceGroup(resp *http.Response) (result ConnectionGatewaysListByResourceGroupOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2016-06-01/connectiongateways/method_connectiongatewaysupdate.go b/resource-manager/web/2016-06-01/connectiongateways/method_connectiongatewaysupdate.go new file mode 100644 index 00000000000..e5ddb3871f2 --- /dev/null +++ b/resource-manager/web/2016-06-01/connectiongateways/method_connectiongatewaysupdate.go @@ -0,0 +1,55 @@ +package connectiongateways + +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 ConnectionGatewaysUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ConnectionGatewayDefinition +} + +// ConnectionGatewaysUpdate ... +func (c ConnectionGatewaysClient) ConnectionGatewaysUpdate(ctx context.Context, id ConnectionGatewayId, input ConnectionGatewayDefinition) (result ConnectionGatewaysUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + 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 +} diff --git a/resource-manager/web/2016-06-01/connectiongateways/method_connectiongatewaysupdate_autorest.go b/resource-manager/web/2016-06-01/connectiongateways/method_connectiongatewaysupdate_autorest.go deleted file mode 100644 index 7e46e461e7b..00000000000 --- a/resource-manager/web/2016-06-01/connectiongateways/method_connectiongatewaysupdate_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package connectiongateways - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ConnectionGatewaysUpdateOperationResponse struct { - HttpResponse *http.Response - Model *ConnectionGatewayDefinition -} - -// ConnectionGatewaysUpdate ... -func (c ConnectionGatewaysClient) ConnectionGatewaysUpdate(ctx context.Context, id ConnectionGatewayId, input ConnectionGatewayDefinition) (result ConnectionGatewaysUpdateOperationResponse, err error) { - req, err := c.preparerForConnectionGatewaysUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "connectiongateways.ConnectionGatewaysClient", "ConnectionGatewaysUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "connectiongateways.ConnectionGatewaysClient", "ConnectionGatewaysUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForConnectionGatewaysUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "connectiongateways.ConnectionGatewaysClient", "ConnectionGatewaysUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForConnectionGatewaysUpdate prepares the ConnectionGatewaysUpdate request. -func (c ConnectionGatewaysClient) preparerForConnectionGatewaysUpdate(ctx context.Context, id ConnectionGatewayId, input ConnectionGatewayDefinition) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForConnectionGatewaysUpdate handles the response to the ConnectionGatewaysUpdate request. The method always -// closes the http.Response Body. -func (c ConnectionGatewaysClient) responderForConnectionGatewaysUpdate(resp *http.Response) (result ConnectionGatewaysUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2016-06-01/connections/client.go b/resource-manager/web/2016-06-01/connections/client.go index 60dc2ebd15e..896f2b69be8 100644 --- a/resource-manager/web/2016-06-01/connections/client.go +++ b/resource-manager/web/2016-06-01/connections/client.go @@ -1,18 +1,26 @@ package connections -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 ConnectionsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewConnectionsClientWithBaseURI(endpoint string) ConnectionsClient { - return ConnectionsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewConnectionsClientWithBaseURI(api environments.Api) (*ConnectionsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "connections", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ConnectionsClient: %+v", err) } + + return &ConnectionsClient{ + Client: client, + }, nil } diff --git a/resource-manager/web/2016-06-01/connections/constants.go b/resource-manager/web/2016-06-01/connections/constants.go index effd8664188..f58634076f4 100644 --- a/resource-manager/web/2016-06-01/connections/constants.go +++ b/resource-manager/web/2016-06-01/connections/constants.go @@ -1,6 +1,10 @@ package connections -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. @@ -21,6 +25,19 @@ func PossibleValuesForLinkState() []string { } } +func (s *LinkState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLinkState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseLinkState(input string) (*LinkState, error) { vals := map[string]LinkState{ "authenticated": LinkStateAuthenticated, diff --git a/resource-manager/web/2016-06-01/connections/method_confirmconsentcode.go b/resource-manager/web/2016-06-01/connections/method_confirmconsentcode.go new file mode 100644 index 00000000000..18759dd3202 --- /dev/null +++ b/resource-manager/web/2016-06-01/connections/method_confirmconsentcode.go @@ -0,0 +1,56 @@ +package connections + +import ( + "context" + "fmt" + "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 ConfirmConsentCodeOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ConfirmConsentCodeDefinition +} + +// ConfirmConsentCode ... +func (c ConnectionsClient) ConfirmConsentCode(ctx context.Context, id ConnectionId, input ConfirmConsentCodeDefinition) (result ConfirmConsentCodeOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/confirmConsentCode", 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 +} diff --git a/resource-manager/web/2016-06-01/connections/method_confirmconsentcode_autorest.go b/resource-manager/web/2016-06-01/connections/method_confirmconsentcode_autorest.go deleted file mode 100644 index b646e40521a..00000000000 --- a/resource-manager/web/2016-06-01/connections/method_confirmconsentcode_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package connections - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ConfirmConsentCodeOperationResponse struct { - HttpResponse *http.Response - Model *ConfirmConsentCodeDefinition -} - -// ConfirmConsentCode ... -func (c ConnectionsClient) ConfirmConsentCode(ctx context.Context, id ConnectionId, input ConfirmConsentCodeDefinition) (result ConfirmConsentCodeOperationResponse, err error) { - req, err := c.preparerForConfirmConsentCode(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "connections.ConnectionsClient", "ConfirmConsentCode", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "connections.ConnectionsClient", "ConfirmConsentCode", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForConfirmConsentCode(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "connections.ConnectionsClient", "ConfirmConsentCode", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForConfirmConsentCode prepares the ConfirmConsentCode request. -func (c ConnectionsClient) preparerForConfirmConsentCode(ctx context.Context, id ConnectionId, input ConfirmConsentCodeDefinition) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/confirmConsentCode", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForConfirmConsentCode handles the response to the ConfirmConsentCode request. The method always -// closes the http.Response Body. -func (c ConnectionsClient) responderForConfirmConsentCode(resp *http.Response) (result ConfirmConsentCodeOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2016-06-01/connections/method_createorupdate.go b/resource-manager/web/2016-06-01/connections/method_createorupdate.go new file mode 100644 index 00000000000..eacac9d6cc8 --- /dev/null +++ b/resource-manager/web/2016-06-01/connections/method_createorupdate.go @@ -0,0 +1,56 @@ +package connections + +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 *ApiConnectionDefinition +} + +// CreateOrUpdate ... +func (c ConnectionsClient) CreateOrUpdate(ctx context.Context, id ConnectionId, input ApiConnectionDefinition) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 +} diff --git a/resource-manager/web/2016-06-01/connections/method_createorupdate_autorest.go b/resource-manager/web/2016-06-01/connections/method_createorupdate_autorest.go deleted file mode 100644 index 09efa338eab..00000000000 --- a/resource-manager/web/2016-06-01/connections/method_createorupdate_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package connections - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// 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 - Model *ApiConnectionDefinition -} - -// CreateOrUpdate ... -func (c ConnectionsClient) CreateOrUpdate(ctx context.Context, id ConnectionId, input ApiConnectionDefinition) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "connections.ConnectionsClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "connections.ConnectionsClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "connections.ConnectionsClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c ConnectionsClient) preparerForCreateOrUpdate(ctx context.Context, id ConnectionId, input ApiConnectionDefinition) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateOrUpdate handles the response to the CreateOrUpdate request. The method always -// closes the http.Response Body. -func (c ConnectionsClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2016-06-01/connections/method_delete.go b/resource-manager/web/2016-06-01/connections/method_delete.go new file mode 100644 index 00000000000..550425ea8e1 --- /dev/null +++ b/resource-manager/web/2016-06-01/connections/method_delete.go @@ -0,0 +1,47 @@ +package connections + +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 +} + +// Delete ... +func (c ConnectionsClient) Delete(ctx context.Context, id ConnectionId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 + } + + return +} diff --git a/resource-manager/web/2016-06-01/connections/method_delete_autorest.go b/resource-manager/web/2016-06-01/connections/method_delete_autorest.go deleted file mode 100644 index d28a83ac6a8..00000000000 --- a/resource-manager/web/2016-06-01/connections/method_delete_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package connections - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// 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 -} - -// Delete ... -func (c ConnectionsClient) Delete(ctx context.Context, id ConnectionId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "connections.ConnectionsClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "connections.ConnectionsClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "connections.ConnectionsClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c ConnectionsClient) preparerForDelete(ctx context.Context, id ConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c ConnectionsClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2016-06-01/connections/method_get.go b/resource-manager/web/2016-06-01/connections/method_get.go new file mode 100644 index 00000000000..9092f675deb --- /dev/null +++ b/resource-manager/web/2016-06-01/connections/method_get.go @@ -0,0 +1,51 @@ +package connections + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApiConnectionDefinition +} + +// Get ... +func (c ConnectionsClient) Get(ctx context.Context, id ConnectionId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2016-06-01/connections/method_get_autorest.go b/resource-manager/web/2016-06-01/connections/method_get_autorest.go deleted file mode 100644 index c2dc83d1692..00000000000 --- a/resource-manager/web/2016-06-01/connections/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package connections - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *ApiConnectionDefinition -} - -// Get ... -func (c ConnectionsClient) Get(ctx context.Context, id ConnectionId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "connections.ConnectionsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "connections.ConnectionsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "connections.ConnectionsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ConnectionsClient) preparerForGet(ctx context.Context, id ConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c ConnectionsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2016-06-01/connections/method_list.go b/resource-manager/web/2016-06-01/connections/method_list.go new file mode 100644 index 00000000000..e066b6871a2 --- /dev/null +++ b/resource-manager/web/2016-06-01/connections/method_list.go @@ -0,0 +1,85 @@ +package connections + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApiConnectionDefinitionCollection +} + +type ListOperationOptions struct { + Filter *string + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// List ... +func (c ConnectionsClient) List(ctx context.Context, id commonids.ResourceGroupId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/connections", id.ID()), + OptionsObject: options, + } + + 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 +} diff --git a/resource-manager/web/2016-06-01/connections/method_list_autorest.go b/resource-manager/web/2016-06-01/connections/method_list_autorest.go deleted file mode 100644 index f6e3e97a165..00000000000 --- a/resource-manager/web/2016-06-01/connections/method_list_autorest.go +++ /dev/null @@ -1,104 +0,0 @@ -package connections - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListOperationResponse struct { - HttpResponse *http.Response - Model *ApiConnectionDefinitionCollection -} - -type ListOperationOptions struct { - Filter *string - Top *int64 -} - -func DefaultListOperationOptions() ListOperationOptions { - return ListOperationOptions{} -} - -func (o ListOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// List ... -func (c ConnectionsClient) List(ctx context.Context, id commonids.ResourceGroupId, options ListOperationOptions) (result ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "connections.ConnectionsClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "connections.ConnectionsClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "connections.ConnectionsClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForList prepares the List request. -func (c ConnectionsClient) preparerForList(ctx context.Context, id commonids.ResourceGroupId, options ListOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Web/connections", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForList handles the response to the List request. The method always -// closes the http.Response Body. -func (c ConnectionsClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2016-06-01/connections/method_listconsentlinks.go b/resource-manager/web/2016-06-01/connections/method_listconsentlinks.go new file mode 100644 index 00000000000..fba3a82bea9 --- /dev/null +++ b/resource-manager/web/2016-06-01/connections/method_listconsentlinks.go @@ -0,0 +1,56 @@ +package connections + +import ( + "context" + "fmt" + "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 ListConsentLinksOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ConsentLinkCollection +} + +// ListConsentLinks ... +func (c ConnectionsClient) ListConsentLinks(ctx context.Context, id ConnectionId, input ListConsentLinksDefinition) (result ListConsentLinksOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listConsentLinks", 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 +} diff --git a/resource-manager/web/2016-06-01/connections/method_listconsentlinks_autorest.go b/resource-manager/web/2016-06-01/connections/method_listconsentlinks_autorest.go deleted file mode 100644 index 04c12602d59..00000000000 --- a/resource-manager/web/2016-06-01/connections/method_listconsentlinks_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package connections - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListConsentLinksOperationResponse struct { - HttpResponse *http.Response - Model *ConsentLinkCollection -} - -// ListConsentLinks ... -func (c ConnectionsClient) ListConsentLinks(ctx context.Context, id ConnectionId, input ListConsentLinksDefinition) (result ListConsentLinksOperationResponse, err error) { - req, err := c.preparerForListConsentLinks(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "connections.ConnectionsClient", "ListConsentLinks", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "connections.ConnectionsClient", "ListConsentLinks", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListConsentLinks(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "connections.ConnectionsClient", "ListConsentLinks", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListConsentLinks prepares the ListConsentLinks request. -func (c ConnectionsClient) preparerForListConsentLinks(ctx context.Context, id ConnectionId, input ListConsentLinksDefinition) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/listConsentLinks", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListConsentLinks handles the response to the ListConsentLinks request. The method always -// closes the http.Response Body. -func (c ConnectionsClient) responderForListConsentLinks(resp *http.Response) (result ListConsentLinksOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2016-06-01/connections/method_update.go b/resource-manager/web/2016-06-01/connections/method_update.go new file mode 100644 index 00000000000..815d1652e02 --- /dev/null +++ b/resource-manager/web/2016-06-01/connections/method_update.go @@ -0,0 +1,55 @@ +package connections + +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 UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApiConnectionDefinition +} + +// Update ... +func (c ConnectionsClient) Update(ctx context.Context, id ConnectionId, input ApiConnectionDefinition) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + 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 +} diff --git a/resource-manager/web/2016-06-01/connections/method_update_autorest.go b/resource-manager/web/2016-06-01/connections/method_update_autorest.go deleted file mode 100644 index e652f3c3cec..00000000000 --- a/resource-manager/web/2016-06-01/connections/method_update_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package connections - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateOperationResponse struct { - HttpResponse *http.Response - Model *ApiConnectionDefinition -} - -// Update ... -func (c ConnectionsClient) Update(ctx context.Context, id ConnectionId, input ApiConnectionDefinition) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "connections.ConnectionsClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "connections.ConnectionsClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "connections.ConnectionsClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c ConnectionsClient) preparerForUpdate(ctx context.Context, id ConnectionId, input ApiConnectionDefinition) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdate handles the response to the Update request. The method always -// closes the http.Response Body. -func (c ConnectionsClient) responderForUpdate(resp *http.Response) (result UpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2016-06-01/customapis/client.go b/resource-manager/web/2016-06-01/customapis/client.go index 83746df17c0..d0af98f2c5a 100644 --- a/resource-manager/web/2016-06-01/customapis/client.go +++ b/resource-manager/web/2016-06-01/customapis/client.go @@ -1,18 +1,26 @@ package customapis -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 CustomAPIsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewCustomAPIsClientWithBaseURI(endpoint string) CustomAPIsClient { - return CustomAPIsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewCustomAPIsClientWithBaseURI(api environments.Api) (*CustomAPIsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "customapis", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CustomAPIsClient: %+v", err) } + + return &CustomAPIsClient{ + Client: client, + }, nil } diff --git a/resource-manager/web/2016-06-01/customapis/constants.go b/resource-manager/web/2016-06-01/customapis/constants.go index 512410eee2e..f73f39e8f1e 100644 --- a/resource-manager/web/2016-06-01/customapis/constants.go +++ b/resource-manager/web/2016-06-01/customapis/constants.go @@ -1,6 +1,10 @@ package customapis -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. @@ -21,6 +25,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{ "notspecified": ApiTypeNotSpecified, @@ -64,6 +81,19 @@ func PossibleValuesForConnectionParameterType() []string { } } +func (s *ConnectionParameterType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConnectionParameterType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseConnectionParameterType(input string) (*ConnectionParameterType, error) { vals := map[string]ConnectionParameterType{ "array": ConnectionParameterTypeArray, @@ -101,6 +131,19 @@ func PossibleValuesForWsdlImportMethod() []string { } } +func (s *WsdlImportMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWsdlImportMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseWsdlImportMethod(input string) (*WsdlImportMethod, error) { vals := map[string]WsdlImportMethod{ "notspecified": WsdlImportMethodNotSpecified, diff --git a/resource-manager/web/2016-06-01/customapis/method_customapiscreateorupdate.go b/resource-manager/web/2016-06-01/customapis/method_customapiscreateorupdate.go new file mode 100644 index 00000000000..9f13e610bba --- /dev/null +++ b/resource-manager/web/2016-06-01/customapis/method_customapiscreateorupdate.go @@ -0,0 +1,55 @@ +package customapis + +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 CustomApisCreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CustomApiDefinition +} + +// CustomApisCreateOrUpdate ... +func (c CustomAPIsClient) CustomApisCreateOrUpdate(ctx context.Context, id CustomApiId, input CustomApiDefinition) (result CustomApisCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 +} diff --git a/resource-manager/web/2016-06-01/customapis/method_customapiscreateorupdate_autorest.go b/resource-manager/web/2016-06-01/customapis/method_customapiscreateorupdate_autorest.go deleted file mode 100644 index dd063b45109..00000000000 --- a/resource-manager/web/2016-06-01/customapis/method_customapiscreateorupdate_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package customapis - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CustomApisCreateOrUpdateOperationResponse struct { - HttpResponse *http.Response - Model *CustomApiDefinition -} - -// CustomApisCreateOrUpdate ... -func (c CustomAPIsClient) CustomApisCreateOrUpdate(ctx context.Context, id CustomApiId, input CustomApiDefinition) (result CustomApisCreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCustomApisCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "customapis.CustomAPIsClient", "CustomApisCreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "customapis.CustomAPIsClient", "CustomApisCreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCustomApisCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "customapis.CustomAPIsClient", "CustomApisCreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCustomApisCreateOrUpdate prepares the CustomApisCreateOrUpdate request. -func (c CustomAPIsClient) preparerForCustomApisCreateOrUpdate(ctx context.Context, id CustomApiId, input CustomApiDefinition) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCustomApisCreateOrUpdate handles the response to the CustomApisCreateOrUpdate request. The method always -// closes the http.Response Body. -func (c CustomAPIsClient) responderForCustomApisCreateOrUpdate(resp *http.Response) (result CustomApisCreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2016-06-01/customapis/method_customapisdelete.go b/resource-manager/web/2016-06-01/customapis/method_customapisdelete.go new file mode 100644 index 00000000000..a2e113dc4bc --- /dev/null +++ b/resource-manager/web/2016-06-01/customapis/method_customapisdelete.go @@ -0,0 +1,47 @@ +package customapis + +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 CustomApisDeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// CustomApisDelete ... +func (c CustomAPIsClient) CustomApisDelete(ctx context.Context, id CustomApiId) (result CustomApisDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 + } + + return +} diff --git a/resource-manager/web/2016-06-01/customapis/method_customapisdelete_autorest.go b/resource-manager/web/2016-06-01/customapis/method_customapisdelete_autorest.go deleted file mode 100644 index e8ec0403058..00000000000 --- a/resource-manager/web/2016-06-01/customapis/method_customapisdelete_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package customapis - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CustomApisDeleteOperationResponse struct { - HttpResponse *http.Response -} - -// CustomApisDelete ... -func (c CustomAPIsClient) CustomApisDelete(ctx context.Context, id CustomApiId) (result CustomApisDeleteOperationResponse, err error) { - req, err := c.preparerForCustomApisDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "customapis.CustomAPIsClient", "CustomApisDelete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "customapis.CustomAPIsClient", "CustomApisDelete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCustomApisDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "customapis.CustomAPIsClient", "CustomApisDelete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCustomApisDelete prepares the CustomApisDelete request. -func (c CustomAPIsClient) preparerForCustomApisDelete(ctx context.Context, id CustomApiId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCustomApisDelete handles the response to the CustomApisDelete request. The method always -// closes the http.Response Body. -func (c CustomAPIsClient) responderForCustomApisDelete(resp *http.Response) (result CustomApisDeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2016-06-01/customapis/method_customapisextractapidefinitionfromwsdl.go b/resource-manager/web/2016-06-01/customapis/method_customapisextractapidefinitionfromwsdl.go new file mode 100644 index 00000000000..41a5b086ead --- /dev/null +++ b/resource-manager/web/2016-06-01/customapis/method_customapisextractapidefinitionfromwsdl.go @@ -0,0 +1,56 @@ +package customapis + +import ( + "context" + "fmt" + "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 CustomApisExtractApiDefinitionFromWsdlOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *interface{} +} + +// CustomApisExtractApiDefinitionFromWsdl ... +func (c CustomAPIsClient) CustomApisExtractApiDefinitionFromWsdl(ctx context.Context, id LocationId, input WsdlDefinition) (result CustomApisExtractApiDefinitionFromWsdlOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/extractApiDefinitionFromWsdl", 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 +} diff --git a/resource-manager/web/2016-06-01/customapis/method_customapisextractapidefinitionfromwsdl_autorest.go b/resource-manager/web/2016-06-01/customapis/method_customapisextractapidefinitionfromwsdl_autorest.go deleted file mode 100644 index 3ada3fd64c6..00000000000 --- a/resource-manager/web/2016-06-01/customapis/method_customapisextractapidefinitionfromwsdl_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package customapis - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CustomApisExtractApiDefinitionFromWsdlOperationResponse struct { - HttpResponse *http.Response - Model *interface{} -} - -// CustomApisExtractApiDefinitionFromWsdl ... -func (c CustomAPIsClient) CustomApisExtractApiDefinitionFromWsdl(ctx context.Context, id LocationId, input WsdlDefinition) (result CustomApisExtractApiDefinitionFromWsdlOperationResponse, err error) { - req, err := c.preparerForCustomApisExtractApiDefinitionFromWsdl(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "customapis.CustomAPIsClient", "CustomApisExtractApiDefinitionFromWsdl", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "customapis.CustomAPIsClient", "CustomApisExtractApiDefinitionFromWsdl", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCustomApisExtractApiDefinitionFromWsdl(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "customapis.CustomAPIsClient", "CustomApisExtractApiDefinitionFromWsdl", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCustomApisExtractApiDefinitionFromWsdl prepares the CustomApisExtractApiDefinitionFromWsdl request. -func (c CustomAPIsClient) preparerForCustomApisExtractApiDefinitionFromWsdl(ctx context.Context, id LocationId, input WsdlDefinition) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/extractApiDefinitionFromWsdl", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCustomApisExtractApiDefinitionFromWsdl handles the response to the CustomApisExtractApiDefinitionFromWsdl request. The method always -// closes the http.Response Body. -func (c CustomAPIsClient) responderForCustomApisExtractApiDefinitionFromWsdl(resp *http.Response) (result CustomApisExtractApiDefinitionFromWsdlOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2016-06-01/customapis/method_customapisget.go b/resource-manager/web/2016-06-01/customapis/method_customapisget.go new file mode 100644 index 00000000000..f23cda66126 --- /dev/null +++ b/resource-manager/web/2016-06-01/customapis/method_customapisget.go @@ -0,0 +1,51 @@ +package customapis + +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 CustomApisGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CustomApiDefinition +} + +// CustomApisGet ... +func (c CustomAPIsClient) CustomApisGet(ctx context.Context, id CustomApiId) (result CustomApisGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2016-06-01/customapis/method_customapisget_autorest.go b/resource-manager/web/2016-06-01/customapis/method_customapisget_autorest.go deleted file mode 100644 index b8f9ec2e9e4..00000000000 --- a/resource-manager/web/2016-06-01/customapis/method_customapisget_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package customapis - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CustomApisGetOperationResponse struct { - HttpResponse *http.Response - Model *CustomApiDefinition -} - -// CustomApisGet ... -func (c CustomAPIsClient) CustomApisGet(ctx context.Context, id CustomApiId) (result CustomApisGetOperationResponse, err error) { - req, err := c.preparerForCustomApisGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "customapis.CustomAPIsClient", "CustomApisGet", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "customapis.CustomAPIsClient", "CustomApisGet", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCustomApisGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "customapis.CustomAPIsClient", "CustomApisGet", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCustomApisGet prepares the CustomApisGet request. -func (c CustomAPIsClient) preparerForCustomApisGet(ctx context.Context, id CustomApiId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCustomApisGet handles the response to the CustomApisGet request. The method always -// closes the http.Response Body. -func (c CustomAPIsClient) responderForCustomApisGet(resp *http.Response) (result CustomApisGetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2016-06-01/customapis/method_customapislist.go b/resource-manager/web/2016-06-01/customapis/method_customapislist.go new file mode 100644 index 00000000000..d2d27b463d4 --- /dev/null +++ b/resource-manager/web/2016-06-01/customapis/method_customapislist.go @@ -0,0 +1,85 @@ +package customapis + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 CustomApisListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CustomApiDefinitionCollection +} + +type CustomApisListOperationOptions struct { + Skiptoken *string + Top *int64 +} + +func DefaultCustomApisListOperationOptions() CustomApisListOperationOptions { + return CustomApisListOperationOptions{} +} + +func (o CustomApisListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o CustomApisListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CustomApisListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Skiptoken != nil { + out.Append("skiptoken", fmt.Sprintf("%v", *o.Skiptoken)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// CustomApisList ... +func (c CustomAPIsClient) CustomApisList(ctx context.Context, id commonids.SubscriptionId, options CustomApisListOperationOptions) (result CustomApisListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/customApis", id.ID()), + OptionsObject: options, + } + + 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 +} diff --git a/resource-manager/web/2016-06-01/customapis/method_customapislist_autorest.go b/resource-manager/web/2016-06-01/customapis/method_customapislist_autorest.go deleted file mode 100644 index f666e865903..00000000000 --- a/resource-manager/web/2016-06-01/customapis/method_customapislist_autorest.go +++ /dev/null @@ -1,104 +0,0 @@ -package customapis - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CustomApisListOperationResponse struct { - HttpResponse *http.Response - Model *CustomApiDefinitionCollection -} - -type CustomApisListOperationOptions struct { - Skiptoken *string - Top *int64 -} - -func DefaultCustomApisListOperationOptions() CustomApisListOperationOptions { - return CustomApisListOperationOptions{} -} - -func (o CustomApisListOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o CustomApisListOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Skiptoken != nil { - out["skiptoken"] = *o.Skiptoken - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// CustomApisList ... -func (c CustomAPIsClient) CustomApisList(ctx context.Context, id commonids.SubscriptionId, options CustomApisListOperationOptions) (result CustomApisListOperationResponse, err error) { - req, err := c.preparerForCustomApisList(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "customapis.CustomAPIsClient", "CustomApisList", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "customapis.CustomAPIsClient", "CustomApisList", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCustomApisList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "customapis.CustomAPIsClient", "CustomApisList", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCustomApisList prepares the CustomApisList request. -func (c CustomAPIsClient) preparerForCustomApisList(ctx context.Context, id commonids.SubscriptionId, options CustomApisListOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Web/customApis", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCustomApisList handles the response to the CustomApisList request. The method always -// closes the http.Response Body. -func (c CustomAPIsClient) responderForCustomApisList(resp *http.Response) (result CustomApisListOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2016-06-01/customapis/method_customapislistbyresourcegroup.go b/resource-manager/web/2016-06-01/customapis/method_customapislistbyresourcegroup.go new file mode 100644 index 00000000000..0cf1813f65b --- /dev/null +++ b/resource-manager/web/2016-06-01/customapis/method_customapislistbyresourcegroup.go @@ -0,0 +1,85 @@ +package customapis + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 CustomApisListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CustomApiDefinitionCollection +} + +type CustomApisListByResourceGroupOperationOptions struct { + Skiptoken *string + Top *int64 +} + +func DefaultCustomApisListByResourceGroupOperationOptions() CustomApisListByResourceGroupOperationOptions { + return CustomApisListByResourceGroupOperationOptions{} +} + +func (o CustomApisListByResourceGroupOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o CustomApisListByResourceGroupOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CustomApisListByResourceGroupOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Skiptoken != nil { + out.Append("skiptoken", fmt.Sprintf("%v", *o.Skiptoken)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// CustomApisListByResourceGroup ... +func (c CustomAPIsClient) CustomApisListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId, options CustomApisListByResourceGroupOperationOptions) (result CustomApisListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/customApis", id.ID()), + OptionsObject: options, + } + + 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 +} diff --git a/resource-manager/web/2016-06-01/customapis/method_customapislistbyresourcegroup_autorest.go b/resource-manager/web/2016-06-01/customapis/method_customapislistbyresourcegroup_autorest.go deleted file mode 100644 index 588b6a300b2..00000000000 --- a/resource-manager/web/2016-06-01/customapis/method_customapislistbyresourcegroup_autorest.go +++ /dev/null @@ -1,104 +0,0 @@ -package customapis - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CustomApisListByResourceGroupOperationResponse struct { - HttpResponse *http.Response - Model *CustomApiDefinitionCollection -} - -type CustomApisListByResourceGroupOperationOptions struct { - Skiptoken *string - Top *int64 -} - -func DefaultCustomApisListByResourceGroupOperationOptions() CustomApisListByResourceGroupOperationOptions { - return CustomApisListByResourceGroupOperationOptions{} -} - -func (o CustomApisListByResourceGroupOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o CustomApisListByResourceGroupOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Skiptoken != nil { - out["skiptoken"] = *o.Skiptoken - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// CustomApisListByResourceGroup ... -func (c CustomAPIsClient) CustomApisListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId, options CustomApisListByResourceGroupOperationOptions) (result CustomApisListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForCustomApisListByResourceGroup(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "customapis.CustomAPIsClient", "CustomApisListByResourceGroup", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "customapis.CustomAPIsClient", "CustomApisListByResourceGroup", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCustomApisListByResourceGroup(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "customapis.CustomAPIsClient", "CustomApisListByResourceGroup", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCustomApisListByResourceGroup prepares the CustomApisListByResourceGroup request. -func (c CustomAPIsClient) preparerForCustomApisListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId, options CustomApisListByResourceGroupOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Web/customApis", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCustomApisListByResourceGroup handles the response to the CustomApisListByResourceGroup request. The method always -// closes the http.Response Body. -func (c CustomAPIsClient) responderForCustomApisListByResourceGroup(resp *http.Response) (result CustomApisListByResourceGroupOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2016-06-01/customapis/method_customapislistwsdlinterfaces.go b/resource-manager/web/2016-06-01/customapis/method_customapislistwsdlinterfaces.go new file mode 100644 index 00000000000..25e41759bb4 --- /dev/null +++ b/resource-manager/web/2016-06-01/customapis/method_customapislistwsdlinterfaces.go @@ -0,0 +1,56 @@ +package customapis + +import ( + "context" + "fmt" + "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 CustomApisListWsdlInterfacesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WsdlServiceCollection +} + +// CustomApisListWsdlInterfaces ... +func (c CustomAPIsClient) CustomApisListWsdlInterfaces(ctx context.Context, id LocationId, input WsdlDefinition) (result CustomApisListWsdlInterfacesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listWsdlInterfaces", 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 +} diff --git a/resource-manager/web/2016-06-01/customapis/method_customapislistwsdlinterfaces_autorest.go b/resource-manager/web/2016-06-01/customapis/method_customapislistwsdlinterfaces_autorest.go deleted file mode 100644 index 17331662cff..00000000000 --- a/resource-manager/web/2016-06-01/customapis/method_customapislistwsdlinterfaces_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package customapis - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CustomApisListWsdlInterfacesOperationResponse struct { - HttpResponse *http.Response - Model *WsdlServiceCollection -} - -// CustomApisListWsdlInterfaces ... -func (c CustomAPIsClient) CustomApisListWsdlInterfaces(ctx context.Context, id LocationId, input WsdlDefinition) (result CustomApisListWsdlInterfacesOperationResponse, err error) { - req, err := c.preparerForCustomApisListWsdlInterfaces(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "customapis.CustomAPIsClient", "CustomApisListWsdlInterfaces", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "customapis.CustomAPIsClient", "CustomApisListWsdlInterfaces", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCustomApisListWsdlInterfaces(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "customapis.CustomAPIsClient", "CustomApisListWsdlInterfaces", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCustomApisListWsdlInterfaces prepares the CustomApisListWsdlInterfaces request. -func (c CustomAPIsClient) preparerForCustomApisListWsdlInterfaces(ctx context.Context, id LocationId, input WsdlDefinition) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/listWsdlInterfaces", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCustomApisListWsdlInterfaces handles the response to the CustomApisListWsdlInterfaces request. The method always -// closes the http.Response Body. -func (c CustomAPIsClient) responderForCustomApisListWsdlInterfaces(resp *http.Response) (result CustomApisListWsdlInterfacesOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2016-06-01/customapis/method_customapismove.go b/resource-manager/web/2016-06-01/customapis/method_customapismove.go new file mode 100644 index 00000000000..bc099175f56 --- /dev/null +++ b/resource-manager/web/2016-06-01/customapis/method_customapismove.go @@ -0,0 +1,51 @@ +package customapis + +import ( + "context" + "fmt" + "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 CustomApisMoveOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// CustomApisMove ... +func (c CustomAPIsClient) CustomApisMove(ctx context.Context, id CustomApiId, input CustomApiReference) (result CustomApisMoveOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/move", 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 + } + + return +} diff --git a/resource-manager/web/2016-06-01/customapis/method_customapismove_autorest.go b/resource-manager/web/2016-06-01/customapis/method_customapismove_autorest.go deleted file mode 100644 index 822ed662265..00000000000 --- a/resource-manager/web/2016-06-01/customapis/method_customapismove_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package customapis - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CustomApisMoveOperationResponse struct { - HttpResponse *http.Response -} - -// CustomApisMove ... -func (c CustomAPIsClient) CustomApisMove(ctx context.Context, id CustomApiId, input CustomApiReference) (result CustomApisMoveOperationResponse, err error) { - req, err := c.preparerForCustomApisMove(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "customapis.CustomAPIsClient", "CustomApisMove", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "customapis.CustomAPIsClient", "CustomApisMove", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCustomApisMove(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "customapis.CustomAPIsClient", "CustomApisMove", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCustomApisMove prepares the CustomApisMove request. -func (c CustomAPIsClient) preparerForCustomApisMove(ctx context.Context, id CustomApiId, input CustomApiReference) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/move", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCustomApisMove handles the response to the CustomApisMove request. The method always -// closes the http.Response Body. -func (c CustomAPIsClient) responderForCustomApisMove(resp *http.Response) (result CustomApisMoveOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2016-06-01/customapis/method_customapisupdate.go b/resource-manager/web/2016-06-01/customapis/method_customapisupdate.go new file mode 100644 index 00000000000..a6a8e245379 --- /dev/null +++ b/resource-manager/web/2016-06-01/customapis/method_customapisupdate.go @@ -0,0 +1,55 @@ +package customapis + +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 CustomApisUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CustomApiDefinition +} + +// CustomApisUpdate ... +func (c CustomAPIsClient) CustomApisUpdate(ctx context.Context, id CustomApiId, input CustomApiDefinition) (result CustomApisUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + 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 +} diff --git a/resource-manager/web/2016-06-01/customapis/method_customapisupdate_autorest.go b/resource-manager/web/2016-06-01/customapis/method_customapisupdate_autorest.go deleted file mode 100644 index cf88b85b3e8..00000000000 --- a/resource-manager/web/2016-06-01/customapis/method_customapisupdate_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package customapis - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CustomApisUpdateOperationResponse struct { - HttpResponse *http.Response - Model *CustomApiDefinition -} - -// CustomApisUpdate ... -func (c CustomAPIsClient) CustomApisUpdate(ctx context.Context, id CustomApiId, input CustomApiDefinition) (result CustomApisUpdateOperationResponse, err error) { - req, err := c.preparerForCustomApisUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "customapis.CustomAPIsClient", "CustomApisUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "customapis.CustomAPIsClient", "CustomApisUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCustomApisUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "customapis.CustomAPIsClient", "CustomApisUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCustomApisUpdate prepares the CustomApisUpdate request. -func (c CustomAPIsClient) preparerForCustomApisUpdate(ctx context.Context, id CustomApiId, input CustomApiDefinition) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCustomApisUpdate handles the response to the CustomApisUpdate request. The method always -// closes the http.Response Body. -func (c CustomAPIsClient) responderForCustomApisUpdate(resp *http.Response) (result CustomApisUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2016-06-01/managedapis/client.go b/resource-manager/web/2016-06-01/managedapis/client.go index ecbd2e21b90..2b5aa451355 100644 --- a/resource-manager/web/2016-06-01/managedapis/client.go +++ b/resource-manager/web/2016-06-01/managedapis/client.go @@ -1,18 +1,26 @@ package managedapis -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 ManagedAPIsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewManagedAPIsClientWithBaseURI(endpoint string) ManagedAPIsClient { - return ManagedAPIsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewManagedAPIsClientWithBaseURI(api environments.Api) (*ManagedAPIsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "managedapis", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ManagedAPIsClient: %+v", err) } + + return &ManagedAPIsClient{ + Client: client, + }, nil } diff --git a/resource-manager/web/2016-06-01/managedapis/constants.go b/resource-manager/web/2016-06-01/managedapis/constants.go index d675883dcab..5da82fd391f 100644 --- a/resource-manager/web/2016-06-01/managedapis/constants.go +++ b/resource-manager/web/2016-06-01/managedapis/constants.go @@ -1,6 +1,10 @@ package managedapis -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. @@ -21,6 +25,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{ "notspecified": ApiTypeNotSpecified, @@ -64,6 +81,19 @@ func PossibleValuesForConnectionParameterType() []string { } } +func (s *ConnectionParameterType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConnectionParameterType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseConnectionParameterType(input string) (*ConnectionParameterType, error) { vals := map[string]ConnectionParameterType{ "array": ConnectionParameterTypeArray, @@ -101,6 +131,19 @@ func PossibleValuesForWsdlImportMethod() []string { } } +func (s *WsdlImportMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWsdlImportMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseWsdlImportMethod(input string) (*WsdlImportMethod, error) { vals := map[string]WsdlImportMethod{ "notspecified": WsdlImportMethodNotSpecified, diff --git a/resource-manager/web/2016-06-01/managedapis/method_managedapisget.go b/resource-manager/web/2016-06-01/managedapis/method_managedapisget.go new file mode 100644 index 00000000000..40557725125 --- /dev/null +++ b/resource-manager/web/2016-06-01/managedapis/method_managedapisget.go @@ -0,0 +1,51 @@ +package managedapis + +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 ManagedApisGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ManagedApiDefinition +} + +// ManagedApisGet ... +func (c ManagedAPIsClient) ManagedApisGet(ctx context.Context, id ManagedApiId) (result ManagedApisGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2016-06-01/managedapis/method_managedapisget_autorest.go b/resource-manager/web/2016-06-01/managedapis/method_managedapisget_autorest.go deleted file mode 100644 index 45728b10f99..00000000000 --- a/resource-manager/web/2016-06-01/managedapis/method_managedapisget_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package managedapis - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ManagedApisGetOperationResponse struct { - HttpResponse *http.Response - Model *ManagedApiDefinition -} - -// ManagedApisGet ... -func (c ManagedAPIsClient) ManagedApisGet(ctx context.Context, id ManagedApiId) (result ManagedApisGetOperationResponse, err error) { - req, err := c.preparerForManagedApisGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "managedapis.ManagedAPIsClient", "ManagedApisGet", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedapis.ManagedAPIsClient", "ManagedApisGet", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForManagedApisGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedapis.ManagedAPIsClient", "ManagedApisGet", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForManagedApisGet prepares the ManagedApisGet request. -func (c ManagedAPIsClient) preparerForManagedApisGet(ctx context.Context, id ManagedApiId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForManagedApisGet handles the response to the ManagedApisGet request. The method always -// closes the http.Response Body. -func (c ManagedAPIsClient) responderForManagedApisGet(resp *http.Response) (result ManagedApisGetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2016-06-01/managedapis/method_managedapislist.go b/resource-manager/web/2016-06-01/managedapis/method_managedapislist.go new file mode 100644 index 00000000000..2868ba36d7f --- /dev/null +++ b/resource-manager/web/2016-06-01/managedapis/method_managedapislist.go @@ -0,0 +1,52 @@ +package managedapis + +import ( + "context" + "fmt" + "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 ManagedApisListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ManagedApiDefinitionCollection +} + +// ManagedApisList ... +func (c ManagedAPIsClient) ManagedApisList(ctx context.Context, id LocationId) (result ManagedApisListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/managedApis", 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 +} diff --git a/resource-manager/web/2016-06-01/managedapis/method_managedapislist_autorest.go b/resource-manager/web/2016-06-01/managedapis/method_managedapislist_autorest.go deleted file mode 100644 index e1d2eea4aa1..00000000000 --- a/resource-manager/web/2016-06-01/managedapis/method_managedapislist_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package managedapis - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ManagedApisListOperationResponse struct { - HttpResponse *http.Response - Model *ManagedApiDefinitionCollection -} - -// ManagedApisList ... -func (c ManagedAPIsClient) ManagedApisList(ctx context.Context, id LocationId) (result ManagedApisListOperationResponse, err error) { - req, err := c.preparerForManagedApisList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "managedapis.ManagedAPIsClient", "ManagedApisList", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "managedapis.ManagedAPIsClient", "ManagedApisList", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForManagedApisList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "managedapis.ManagedAPIsClient", "ManagedApisList", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForManagedApisList prepares the ManagedApisList request. -func (c ManagedAPIsClient) preparerForManagedApisList(ctx context.Context, id LocationId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/managedApis", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForManagedApisList handles the response to the ManagedApisList request. The method always -// closes the http.Response Body. -func (c ManagedAPIsClient) responderForManagedApisList(resp *http.Response) (result ManagedApisListOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/appservicecertificateorders/client.go b/resource-manager/web/2022-09-01/appservicecertificateorders/client.go index 5de3cee3d96..a4d14f586ba 100644 --- a/resource-manager/web/2022-09-01/appservicecertificateorders/client.go +++ b/resource-manager/web/2022-09-01/appservicecertificateorders/client.go @@ -1,18 +1,26 @@ package appservicecertificateorders -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 AppServiceCertificateOrdersClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewAppServiceCertificateOrdersClientWithBaseURI(endpoint string) AppServiceCertificateOrdersClient { - return AppServiceCertificateOrdersClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewAppServiceCertificateOrdersClientWithBaseURI(api environments.Api) (*AppServiceCertificateOrdersClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "appservicecertificateorders", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AppServiceCertificateOrdersClient: %+v", err) } + + return &AppServiceCertificateOrdersClient{ + Client: client, + }, nil } diff --git a/resource-manager/web/2022-09-01/appservicecertificateorders/constants.go b/resource-manager/web/2022-09-01/appservicecertificateorders/constants.go index f72d40d980c..7fd04266697 100644 --- a/resource-manager/web/2022-09-01/appservicecertificateorders/constants.go +++ b/resource-manager/web/2022-09-01/appservicecertificateorders/constants.go @@ -1,6 +1,10 @@ package appservicecertificateorders -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. @@ -43,6 +47,19 @@ func PossibleValuesForCertificateOrderActionType() []string { } } +func (s *CertificateOrderActionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCertificateOrderActionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseCertificateOrderActionType(input string) (*CertificateOrderActionType, error) { vals := map[string]CertificateOrderActionType{ "certificateexpirationwarning": CertificateOrderActionTypeCertificateExpirationWarning, @@ -99,6 +116,19 @@ func PossibleValuesForCertificateOrderStatus() []string { } } +func (s *CertificateOrderStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCertificateOrderStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseCertificateOrderStatus(input string) (*CertificateOrderStatus, error) { vals := map[string]CertificateOrderStatus{ "canceled": CertificateOrderStatusCanceled, @@ -135,6 +165,19 @@ func PossibleValuesForCertificateProductType() []string { } } +func (s *CertificateProductType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCertificateProductType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseCertificateProductType(input string) (*CertificateProductType, error) { vals := map[string]CertificateProductType{ "standarddomainvalidatedssl": CertificateProductTypeStandardDomainValidatedSsl, @@ -181,6 +224,19 @@ func PossibleValuesForKeyVaultSecretStatus() []string { } } +func (s *KeyVaultSecretStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKeyVaultSecretStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseKeyVaultSecretStatus(input string) (*KeyVaultSecretStatus, error) { vals := map[string]KeyVaultSecretStatus{ "azureserviceunauthorizedtoaccesskeyvault": KeyVaultSecretStatusAzureServiceUnauthorizedToAccessKeyVault, @@ -224,6 +280,19 @@ func PossibleValuesForProvisioningState() []string { } } +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseProvisioningState(input string) (*ProvisioningState, error) { vals := map[string]ProvisioningState{ "canceled": ProvisioningStateCanceled, @@ -257,6 +326,19 @@ func PossibleValuesForResourceNotRenewableReason() []string { } } +func (s *ResourceNotRenewableReason) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResourceNotRenewableReason(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseResourceNotRenewableReason(input string) (*ResourceNotRenewableReason, error) { vals := map[string]ResourceNotRenewableReason{ "expirationnotinrenewaltimerange": ResourceNotRenewableReasonExpirationNotInRenewalTimeRange, diff --git a/resource-manager/web/2022-09-01/appservicecertificateorders/method_createorupdate.go b/resource-manager/web/2022-09-01/appservicecertificateorders/method_createorupdate.go new file mode 100644 index 00000000000..20bfda4a7cd --- /dev/null +++ b/resource-manager/web/2022-09-01/appservicecertificateorders/method_createorupdate.go @@ -0,0 +1,74 @@ +package appservicecertificateorders + +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 +} + +// CreateOrUpdate ... +func (c AppServiceCertificateOrdersClient) CreateOrUpdate(ctx context.Context, id CertificateOrderId, input AppServiceCertificateOrder) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 AppServiceCertificateOrdersClient) CreateOrUpdateThenPoll(ctx context.Context, id CertificateOrderId, input AppServiceCertificateOrder) 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 +} diff --git a/resource-manager/web/2022-09-01/appservicecertificateorders/method_createorupdate_autorest.go b/resource-manager/web/2022-09-01/appservicecertificateorders/method_createorupdate_autorest.go deleted file mode 100644 index 69e0f0020b9..00000000000 --- a/resource-manager/web/2022-09-01/appservicecertificateorders/method_createorupdate_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package appservicecertificateorders - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateOrUpdate ... -func (c AppServiceCertificateOrdersClient) CreateOrUpdate(ctx context.Context, id CertificateOrderId, input AppServiceCertificateOrder) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c AppServiceCertificateOrdersClient) CreateOrUpdateThenPoll(ctx context.Context, id CertificateOrderId, input AppServiceCertificateOrder) error { - result, err := c.CreateOrUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateOrUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateOrUpdate: %+v", err) - } - - return nil -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c AppServiceCertificateOrdersClient) preparerForCreateOrUpdate(ctx context.Context, id CertificateOrderId, input AppServiceCertificateOrder) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateOrUpdate sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c AppServiceCertificateOrdersClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/appservicecertificateorders/method_createorupdatecertificate.go b/resource-manager/web/2022-09-01/appservicecertificateorders/method_createorupdatecertificate.go new file mode 100644 index 00000000000..4ef184a8cc8 --- /dev/null +++ b/resource-manager/web/2022-09-01/appservicecertificateorders/method_createorupdatecertificate.go @@ -0,0 +1,74 @@ +package appservicecertificateorders + +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 CreateOrUpdateCertificateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// CreateOrUpdateCertificate ... +func (c AppServiceCertificateOrdersClient) CreateOrUpdateCertificate(ctx context.Context, id CertificateId, input AppServiceCertificateResource) (result CreateOrUpdateCertificateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 +} + +// CreateOrUpdateCertificateThenPoll performs CreateOrUpdateCertificate then polls until it's completed +func (c AppServiceCertificateOrdersClient) CreateOrUpdateCertificateThenPoll(ctx context.Context, id CertificateId, input AppServiceCertificateResource) error { + result, err := c.CreateOrUpdateCertificate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdateCertificate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdateCertificate: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/appservicecertificateorders/method_createorupdatecertificate_autorest.go b/resource-manager/web/2022-09-01/appservicecertificateorders/method_createorupdatecertificate_autorest.go deleted file mode 100644 index 6702422f722..00000000000 --- a/resource-manager/web/2022-09-01/appservicecertificateorders/method_createorupdatecertificate_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package appservicecertificateorders - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateCertificateOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateOrUpdateCertificate ... -func (c AppServiceCertificateOrdersClient) CreateOrUpdateCertificate(ctx context.Context, id CertificateId, input AppServiceCertificateResource) (result CreateOrUpdateCertificateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdateCertificate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "CreateOrUpdateCertificate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdateCertificate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "CreateOrUpdateCertificate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateCertificateThenPoll performs CreateOrUpdateCertificate then polls until it's completed -func (c AppServiceCertificateOrdersClient) CreateOrUpdateCertificateThenPoll(ctx context.Context, id CertificateId, input AppServiceCertificateResource) error { - result, err := c.CreateOrUpdateCertificate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateOrUpdateCertificate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateOrUpdateCertificate: %+v", err) - } - - return nil -} - -// preparerForCreateOrUpdateCertificate prepares the CreateOrUpdateCertificate request. -func (c AppServiceCertificateOrdersClient) preparerForCreateOrUpdateCertificate(ctx context.Context, id CertificateId, input AppServiceCertificateResource) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateOrUpdateCertificate sends the CreateOrUpdateCertificate request. The method will close the -// http.Response Body if it receives an error. -func (c AppServiceCertificateOrdersClient) senderForCreateOrUpdateCertificate(ctx context.Context, req *http.Request) (future CreateOrUpdateCertificateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/appservicecertificateorders/method_delete.go b/resource-manager/web/2022-09-01/appservicecertificateorders/method_delete.go new file mode 100644 index 00000000000..300b4706e2b --- /dev/null +++ b/resource-manager/web/2022-09-01/appservicecertificateorders/method_delete.go @@ -0,0 +1,47 @@ +package appservicecertificateorders + +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 +} + +// Delete ... +func (c AppServiceCertificateOrdersClient) Delete(ctx context.Context, id CertificateOrderId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/appservicecertificateorders/method_delete_autorest.go b/resource-manager/web/2022-09-01/appservicecertificateorders/method_delete_autorest.go deleted file mode 100644 index fcd048d53c2..00000000000 --- a/resource-manager/web/2022-09-01/appservicecertificateorders/method_delete_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package appservicecertificateorders - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// 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 -} - -// Delete ... -func (c AppServiceCertificateOrdersClient) Delete(ctx context.Context, id CertificateOrderId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c AppServiceCertificateOrdersClient) preparerForDelete(ctx context.Context, id CertificateOrderId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c AppServiceCertificateOrdersClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/appservicecertificateorders/method_deletecertificate.go b/resource-manager/web/2022-09-01/appservicecertificateorders/method_deletecertificate.go new file mode 100644 index 00000000000..270fabd617e --- /dev/null +++ b/resource-manager/web/2022-09-01/appservicecertificateorders/method_deletecertificate.go @@ -0,0 +1,47 @@ +package appservicecertificateorders + +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 DeleteCertificateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteCertificate ... +func (c AppServiceCertificateOrdersClient) DeleteCertificate(ctx context.Context, id CertificateId) (result DeleteCertificateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/appservicecertificateorders/method_deletecertificate_autorest.go b/resource-manager/web/2022-09-01/appservicecertificateorders/method_deletecertificate_autorest.go deleted file mode 100644 index e16299e0c9a..00000000000 --- a/resource-manager/web/2022-09-01/appservicecertificateorders/method_deletecertificate_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package appservicecertificateorders - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteCertificateOperationResponse struct { - HttpResponse *http.Response -} - -// DeleteCertificate ... -func (c AppServiceCertificateOrdersClient) DeleteCertificate(ctx context.Context, id CertificateId) (result DeleteCertificateOperationResponse, err error) { - req, err := c.preparerForDeleteCertificate(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "DeleteCertificate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "DeleteCertificate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeleteCertificate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "DeleteCertificate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeleteCertificate prepares the DeleteCertificate request. -func (c AppServiceCertificateOrdersClient) preparerForDeleteCertificate(ctx context.Context, id CertificateId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeleteCertificate handles the response to the DeleteCertificate request. The method always -// closes the http.Response Body. -func (c AppServiceCertificateOrdersClient) responderForDeleteCertificate(resp *http.Response) (result DeleteCertificateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/appservicecertificateorders/method_get.go b/resource-manager/web/2022-09-01/appservicecertificateorders/method_get.go new file mode 100644 index 00000000000..e5af33650e5 --- /dev/null +++ b/resource-manager/web/2022-09-01/appservicecertificateorders/method_get.go @@ -0,0 +1,51 @@ +package appservicecertificateorders + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AppServiceCertificateOrder +} + +// Get ... +func (c AppServiceCertificateOrdersClient) Get(ctx context.Context, id CertificateOrderId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/appservicecertificateorders/method_get_autorest.go b/resource-manager/web/2022-09-01/appservicecertificateorders/method_get_autorest.go deleted file mode 100644 index d369f14ce98..00000000000 --- a/resource-manager/web/2022-09-01/appservicecertificateorders/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package appservicecertificateorders - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *AppServiceCertificateOrder -} - -// Get ... -func (c AppServiceCertificateOrdersClient) Get(ctx context.Context, id CertificateOrderId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c AppServiceCertificateOrdersClient) preparerForGet(ctx context.Context, id CertificateOrderId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c AppServiceCertificateOrdersClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/appservicecertificateorders/method_getcertificate.go b/resource-manager/web/2022-09-01/appservicecertificateorders/method_getcertificate.go new file mode 100644 index 00000000000..c9d1b1bd78b --- /dev/null +++ b/resource-manager/web/2022-09-01/appservicecertificateorders/method_getcertificate.go @@ -0,0 +1,51 @@ +package appservicecertificateorders + +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 GetCertificateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AppServiceCertificateResource +} + +// GetCertificate ... +func (c AppServiceCertificateOrdersClient) GetCertificate(ctx context.Context, id CertificateId) (result GetCertificateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/appservicecertificateorders/method_getcertificate_autorest.go b/resource-manager/web/2022-09-01/appservicecertificateorders/method_getcertificate_autorest.go deleted file mode 100644 index 761b48784a9..00000000000 --- a/resource-manager/web/2022-09-01/appservicecertificateorders/method_getcertificate_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package appservicecertificateorders - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetCertificateOperationResponse struct { - HttpResponse *http.Response - Model *AppServiceCertificateResource -} - -// GetCertificate ... -func (c AppServiceCertificateOrdersClient) GetCertificate(ctx context.Context, id CertificateId) (result GetCertificateOperationResponse, err error) { - req, err := c.preparerForGetCertificate(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "GetCertificate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "GetCertificate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetCertificate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "GetCertificate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetCertificate prepares the GetCertificate request. -func (c AppServiceCertificateOrdersClient) preparerForGetCertificate(ctx context.Context, id CertificateId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetCertificate handles the response to the GetCertificate request. The method always -// closes the http.Response Body. -func (c AppServiceCertificateOrdersClient) responderForGetCertificate(resp *http.Response) (result GetCertificateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/appservicecertificateorders/method_list.go b/resource-manager/web/2022-09-01/appservicecertificateorders/method_list.go new file mode 100644 index 00000000000..dcd69fa858d --- /dev/null +++ b/resource-manager/web/2022-09-01/appservicecertificateorders/method_list.go @@ -0,0 +1,90 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AppServiceCertificateOrder +} + +type ListCompleteResult struct { + Items []AppServiceCertificateOrder +} + +// List ... +func (c AppServiceCertificateOrdersClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.CertificateRegistration/certificateOrders", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AppServiceCertificateOrder `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c AppServiceCertificateOrdersClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, AppServiceCertificateOrderOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceCertificateOrdersClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate AppServiceCertificateOrderOperationPredicate) (result ListCompleteResult, err error) { + items := make([]AppServiceCertificateOrder, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/appservicecertificateorders/method_list_autorest.go b/resource-manager/web/2022-09-01/appservicecertificateorders/method_list_autorest.go deleted file mode 100644 index e71fb9f155e..00000000000 --- a/resource-manager/web/2022-09-01/appservicecertificateorders/method_list_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package appservicecertificateorders - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListOperationResponse struct { - HttpResponse *http.Response - Model *[]AppServiceCertificateOrder - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []AppServiceCertificateOrder -} - -func (r ListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// List ... -func (c AppServiceCertificateOrdersClient) List(ctx context.Context, id commonids.SubscriptionId) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c AppServiceCertificateOrdersClient) preparerForList(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.CertificateRegistration/certificateOrders", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c AppServiceCertificateOrdersClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForList handles the response to the List request. The method always -// closes the http.Response Body. -func (c AppServiceCertificateOrdersClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []AppServiceCertificateOrder `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { - req, err := c.preparerForListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c AppServiceCertificateOrdersClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, AppServiceCertificateOrderOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c AppServiceCertificateOrdersClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate AppServiceCertificateOrderOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]AppServiceCertificateOrder, 0) - - page, err := c.List(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/appservicecertificateorders/method_listbyresourcegroup.go b/resource-manager/web/2022-09-01/appservicecertificateorders/method_listbyresourcegroup.go new file mode 100644 index 00000000000..af73bbea59c --- /dev/null +++ b/resource-manager/web/2022-09-01/appservicecertificateorders/method_listbyresourcegroup.go @@ -0,0 +1,90 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AppServiceCertificateOrder +} + +type ListByResourceGroupCompleteResult struct { + Items []AppServiceCertificateOrder +} + +// ListByResourceGroup ... +func (c AppServiceCertificateOrdersClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.CertificateRegistration/certificateOrders", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AppServiceCertificateOrder `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c AppServiceCertificateOrdersClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, AppServiceCertificateOrderOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceCertificateOrdersClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate AppServiceCertificateOrderOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]AppServiceCertificateOrder, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/appservicecertificateorders/method_listbyresourcegroup_autorest.go b/resource-manager/web/2022-09-01/appservicecertificateorders/method_listbyresourcegroup_autorest.go deleted file mode 100644 index fcb62b70769..00000000000 --- a/resource-manager/web/2022-09-01/appservicecertificateorders/method_listbyresourcegroup_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package appservicecertificateorders - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByResourceGroupOperationResponse struct { - HttpResponse *http.Response - Model *[]AppServiceCertificateOrder - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByResourceGroupOperationResponse, error) -} - -type ListByResourceGroupCompleteResult struct { - Items []AppServiceCertificateOrder -} - -func (r ListByResourceGroupOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByResourceGroupOperationResponse) LoadMore(ctx context.Context) (resp ListByResourceGroupOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByResourceGroup ... -func (c AppServiceCertificateOrdersClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (resp ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroup(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "ListByResourceGroup", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByResourceGroup(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "ListByResourceGroup", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByResourceGroup prepares the ListByResourceGroup request. -func (c AppServiceCertificateOrdersClient) preparerForListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.CertificateRegistration/certificateOrders", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByResourceGroupWithNextLink prepares the ListByResourceGroup request with the given nextLink token. -func (c AppServiceCertificateOrdersClient) preparerForListByResourceGroupWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByResourceGroup handles the response to the ListByResourceGroup request. The method always -// closes the http.Response Body. -func (c AppServiceCertificateOrdersClient) responderForListByResourceGroup(resp *http.Response) (result ListByResourceGroupOperationResponse, err error) { - type page struct { - Values []AppServiceCertificateOrder `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroupWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "ListByResourceGroup", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByResourceGroup(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "ListByResourceGroup", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByResourceGroupComplete retrieves all of the results into a single object -func (c AppServiceCertificateOrdersClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { - return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, AppServiceCertificateOrderOperationPredicate{}) -} - -// ListByResourceGroupCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c AppServiceCertificateOrdersClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate AppServiceCertificateOrderOperationPredicate) (resp ListByResourceGroupCompleteResult, err error) { - items := make([]AppServiceCertificateOrder, 0) - - page, err := c.ListByResourceGroup(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByResourceGroupCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/appservicecertificateorders/method_listcertificates.go b/resource-manager/web/2022-09-01/appservicecertificateorders/method_listcertificates.go new file mode 100644 index 00000000000..ac8ad11de69 --- /dev/null +++ b/resource-manager/web/2022-09-01/appservicecertificateorders/method_listcertificates.go @@ -0,0 +1,89 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "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 ListCertificatesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AppServiceCertificateResource +} + +type ListCertificatesCompleteResult struct { + Items []AppServiceCertificateResource +} + +// ListCertificates ... +func (c AppServiceCertificateOrdersClient) ListCertificates(ctx context.Context, id CertificateOrderId) (result ListCertificatesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/certificates", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AppServiceCertificateResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListCertificatesComplete retrieves all the results into a single object +func (c AppServiceCertificateOrdersClient) ListCertificatesComplete(ctx context.Context, id CertificateOrderId) (ListCertificatesCompleteResult, error) { + return c.ListCertificatesCompleteMatchingPredicate(ctx, id, AppServiceCertificateResourceOperationPredicate{}) +} + +// ListCertificatesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceCertificateOrdersClient) ListCertificatesCompleteMatchingPredicate(ctx context.Context, id CertificateOrderId, predicate AppServiceCertificateResourceOperationPredicate) (result ListCertificatesCompleteResult, err error) { + items := make([]AppServiceCertificateResource, 0) + + resp, err := c.ListCertificates(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCertificatesCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/appservicecertificateorders/method_listcertificates_autorest.go b/resource-manager/web/2022-09-01/appservicecertificateorders/method_listcertificates_autorest.go deleted file mode 100644 index 0d429415da1..00000000000 --- a/resource-manager/web/2022-09-01/appservicecertificateorders/method_listcertificates_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package appservicecertificateorders - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListCertificatesOperationResponse struct { - HttpResponse *http.Response - Model *[]AppServiceCertificateResource - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListCertificatesOperationResponse, error) -} - -type ListCertificatesCompleteResult struct { - Items []AppServiceCertificateResource -} - -func (r ListCertificatesOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListCertificatesOperationResponse) LoadMore(ctx context.Context) (resp ListCertificatesOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListCertificates ... -func (c AppServiceCertificateOrdersClient) ListCertificates(ctx context.Context, id CertificateOrderId) (resp ListCertificatesOperationResponse, err error) { - req, err := c.preparerForListCertificates(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "ListCertificates", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "ListCertificates", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListCertificates(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "ListCertificates", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListCertificates prepares the ListCertificates request. -func (c AppServiceCertificateOrdersClient) preparerForListCertificates(ctx context.Context, id CertificateOrderId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/certificates", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListCertificatesWithNextLink prepares the ListCertificates request with the given nextLink token. -func (c AppServiceCertificateOrdersClient) preparerForListCertificatesWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListCertificates handles the response to the ListCertificates request. The method always -// closes the http.Response Body. -func (c AppServiceCertificateOrdersClient) responderForListCertificates(resp *http.Response) (result ListCertificatesOperationResponse, err error) { - type page struct { - Values []AppServiceCertificateResource `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListCertificatesOperationResponse, err error) { - req, err := c.preparerForListCertificatesWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "ListCertificates", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "ListCertificates", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListCertificates(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "ListCertificates", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListCertificatesComplete retrieves all of the results into a single object -func (c AppServiceCertificateOrdersClient) ListCertificatesComplete(ctx context.Context, id CertificateOrderId) (ListCertificatesCompleteResult, error) { - return c.ListCertificatesCompleteMatchingPredicate(ctx, id, AppServiceCertificateResourceOperationPredicate{}) -} - -// ListCertificatesCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c AppServiceCertificateOrdersClient) ListCertificatesCompleteMatchingPredicate(ctx context.Context, id CertificateOrderId, predicate AppServiceCertificateResourceOperationPredicate) (resp ListCertificatesCompleteResult, err error) { - items := make([]AppServiceCertificateResource, 0) - - page, err := c.ListCertificates(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCertificatesCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/appservicecertificateorders/method_reissue.go b/resource-manager/web/2022-09-01/appservicecertificateorders/method_reissue.go new file mode 100644 index 00000000000..2d0338143c1 --- /dev/null +++ b/resource-manager/web/2022-09-01/appservicecertificateorders/method_reissue.go @@ -0,0 +1,51 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "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 ReissueOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Reissue ... +func (c AppServiceCertificateOrdersClient) Reissue(ctx context.Context, id CertificateOrderId, input ReissueCertificateOrderRequest) (result ReissueOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/reissue", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/appservicecertificateorders/method_reissue_autorest.go b/resource-manager/web/2022-09-01/appservicecertificateorders/method_reissue_autorest.go deleted file mode 100644 index 57d47ce85d9..00000000000 --- a/resource-manager/web/2022-09-01/appservicecertificateorders/method_reissue_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package appservicecertificateorders - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ReissueOperationResponse struct { - HttpResponse *http.Response -} - -// Reissue ... -func (c AppServiceCertificateOrdersClient) Reissue(ctx context.Context, id CertificateOrderId, input ReissueCertificateOrderRequest) (result ReissueOperationResponse, err error) { - req, err := c.preparerForReissue(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "Reissue", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "Reissue", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForReissue(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "Reissue", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForReissue prepares the Reissue request. -func (c AppServiceCertificateOrdersClient) preparerForReissue(ctx context.Context, id CertificateOrderId, input ReissueCertificateOrderRequest) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/reissue", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForReissue handles the response to the Reissue request. The method always -// closes the http.Response Body. -func (c AppServiceCertificateOrdersClient) responderForReissue(resp *http.Response) (result ReissueOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/appservicecertificateorders/method_renew.go b/resource-manager/web/2022-09-01/appservicecertificateorders/method_renew.go new file mode 100644 index 00000000000..80401890653 --- /dev/null +++ b/resource-manager/web/2022-09-01/appservicecertificateorders/method_renew.go @@ -0,0 +1,51 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "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 RenewOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Renew ... +func (c AppServiceCertificateOrdersClient) Renew(ctx context.Context, id CertificateOrderId, input RenewCertificateOrderRequest) (result RenewOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/renew", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/appservicecertificateorders/method_renew_autorest.go b/resource-manager/web/2022-09-01/appservicecertificateorders/method_renew_autorest.go deleted file mode 100644 index e0662b45717..00000000000 --- a/resource-manager/web/2022-09-01/appservicecertificateorders/method_renew_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package appservicecertificateorders - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type RenewOperationResponse struct { - HttpResponse *http.Response -} - -// Renew ... -func (c AppServiceCertificateOrdersClient) Renew(ctx context.Context, id CertificateOrderId, input RenewCertificateOrderRequest) (result RenewOperationResponse, err error) { - req, err := c.preparerForRenew(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "Renew", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "Renew", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForRenew(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "Renew", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForRenew prepares the Renew request. -func (c AppServiceCertificateOrdersClient) preparerForRenew(ctx context.Context, id CertificateOrderId, input RenewCertificateOrderRequest) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/renew", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForRenew handles the response to the Renew request. The method always -// closes the http.Response Body. -func (c AppServiceCertificateOrdersClient) responderForRenew(resp *http.Response) (result RenewOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/appservicecertificateorders/method_resendemail.go b/resource-manager/web/2022-09-01/appservicecertificateorders/method_resendemail.go new file mode 100644 index 00000000000..e30f6f6acf2 --- /dev/null +++ b/resource-manager/web/2022-09-01/appservicecertificateorders/method_resendemail.go @@ -0,0 +1,47 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "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 ResendEmailOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ResendEmail ... +func (c AppServiceCertificateOrdersClient) ResendEmail(ctx context.Context, id CertificateOrderId) (result ResendEmailOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resendEmail", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/appservicecertificateorders/method_resendemail_autorest.go b/resource-manager/web/2022-09-01/appservicecertificateorders/method_resendemail_autorest.go deleted file mode 100644 index ad3054bf475..00000000000 --- a/resource-manager/web/2022-09-01/appservicecertificateorders/method_resendemail_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package appservicecertificateorders - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ResendEmailOperationResponse struct { - HttpResponse *http.Response -} - -// ResendEmail ... -func (c AppServiceCertificateOrdersClient) ResendEmail(ctx context.Context, id CertificateOrderId) (result ResendEmailOperationResponse, err error) { - req, err := c.preparerForResendEmail(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "ResendEmail", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "ResendEmail", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForResendEmail(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "ResendEmail", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForResendEmail prepares the ResendEmail request. -func (c AppServiceCertificateOrdersClient) preparerForResendEmail(ctx context.Context, id CertificateOrderId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/resendEmail", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForResendEmail handles the response to the ResendEmail request. The method always -// closes the http.Response Body. -func (c AppServiceCertificateOrdersClient) responderForResendEmail(resp *http.Response) (result ResendEmailOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/appservicecertificateorders/method_resendrequestemails.go b/resource-manager/web/2022-09-01/appservicecertificateorders/method_resendrequestemails.go new file mode 100644 index 00000000000..3d1f23aa6ff --- /dev/null +++ b/resource-manager/web/2022-09-01/appservicecertificateorders/method_resendrequestemails.go @@ -0,0 +1,51 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "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 ResendRequestEmailsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ResendRequestEmails ... +func (c AppServiceCertificateOrdersClient) ResendRequestEmails(ctx context.Context, id CertificateOrderId, input NameIdentifier) (result ResendRequestEmailsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resendRequestEmails", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/appservicecertificateorders/method_resendrequestemails_autorest.go b/resource-manager/web/2022-09-01/appservicecertificateorders/method_resendrequestemails_autorest.go deleted file mode 100644 index 2635390e8aa..00000000000 --- a/resource-manager/web/2022-09-01/appservicecertificateorders/method_resendrequestemails_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package appservicecertificateorders - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ResendRequestEmailsOperationResponse struct { - HttpResponse *http.Response -} - -// ResendRequestEmails ... -func (c AppServiceCertificateOrdersClient) ResendRequestEmails(ctx context.Context, id CertificateOrderId, input NameIdentifier) (result ResendRequestEmailsOperationResponse, err error) { - req, err := c.preparerForResendRequestEmails(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "ResendRequestEmails", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "ResendRequestEmails", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForResendRequestEmails(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "ResendRequestEmails", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForResendRequestEmails prepares the ResendRequestEmails request. -func (c AppServiceCertificateOrdersClient) preparerForResendRequestEmails(ctx context.Context, id CertificateOrderId, input NameIdentifier) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/resendRequestEmails", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForResendRequestEmails handles the response to the ResendRequestEmails request. The method always -// closes the http.Response Body. -func (c AppServiceCertificateOrdersClient) responderForResendRequestEmails(resp *http.Response) (result ResendRequestEmailsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/appservicecertificateorders/method_retrievecertificateactions.go b/resource-manager/web/2022-09-01/appservicecertificateorders/method_retrievecertificateactions.go new file mode 100644 index 00000000000..493108c63f9 --- /dev/null +++ b/resource-manager/web/2022-09-01/appservicecertificateorders/method_retrievecertificateactions.go @@ -0,0 +1,52 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "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 RetrieveCertificateActionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CertificateOrderAction +} + +// RetrieveCertificateActions ... +func (c AppServiceCertificateOrdersClient) RetrieveCertificateActions(ctx context.Context, id CertificateOrderId) (result RetrieveCertificateActionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/retrieveCertificateActions", 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 +} diff --git a/resource-manager/web/2022-09-01/appservicecertificateorders/method_retrievecertificateactions_autorest.go b/resource-manager/web/2022-09-01/appservicecertificateorders/method_retrievecertificateactions_autorest.go deleted file mode 100644 index 353d6012714..00000000000 --- a/resource-manager/web/2022-09-01/appservicecertificateorders/method_retrievecertificateactions_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package appservicecertificateorders - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type RetrieveCertificateActionsOperationResponse struct { - HttpResponse *http.Response - Model *[]CertificateOrderAction -} - -// RetrieveCertificateActions ... -func (c AppServiceCertificateOrdersClient) RetrieveCertificateActions(ctx context.Context, id CertificateOrderId) (result RetrieveCertificateActionsOperationResponse, err error) { - req, err := c.preparerForRetrieveCertificateActions(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "RetrieveCertificateActions", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "RetrieveCertificateActions", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForRetrieveCertificateActions(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "RetrieveCertificateActions", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForRetrieveCertificateActions prepares the RetrieveCertificateActions request. -func (c AppServiceCertificateOrdersClient) preparerForRetrieveCertificateActions(ctx context.Context, id CertificateOrderId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/retrieveCertificateActions", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForRetrieveCertificateActions handles the response to the RetrieveCertificateActions request. The method always -// closes the http.Response Body. -func (c AppServiceCertificateOrdersClient) responderForRetrieveCertificateActions(resp *http.Response) (result RetrieveCertificateActionsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/appservicecertificateorders/method_retrievecertificateemailhistory.go b/resource-manager/web/2022-09-01/appservicecertificateorders/method_retrievecertificateemailhistory.go new file mode 100644 index 00000000000..8da4c212e57 --- /dev/null +++ b/resource-manager/web/2022-09-01/appservicecertificateorders/method_retrievecertificateemailhistory.go @@ -0,0 +1,52 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "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 RetrieveCertificateEmailHistoryOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CertificateEmail +} + +// RetrieveCertificateEmailHistory ... +func (c AppServiceCertificateOrdersClient) RetrieveCertificateEmailHistory(ctx context.Context, id CertificateOrderId) (result RetrieveCertificateEmailHistoryOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/retrieveEmailHistory", 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 +} diff --git a/resource-manager/web/2022-09-01/appservicecertificateorders/method_retrievecertificateemailhistory_autorest.go b/resource-manager/web/2022-09-01/appservicecertificateorders/method_retrievecertificateemailhistory_autorest.go deleted file mode 100644 index 27faa3ba49f..00000000000 --- a/resource-manager/web/2022-09-01/appservicecertificateorders/method_retrievecertificateemailhistory_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package appservicecertificateorders - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type RetrieveCertificateEmailHistoryOperationResponse struct { - HttpResponse *http.Response - Model *[]CertificateEmail -} - -// RetrieveCertificateEmailHistory ... -func (c AppServiceCertificateOrdersClient) RetrieveCertificateEmailHistory(ctx context.Context, id CertificateOrderId) (result RetrieveCertificateEmailHistoryOperationResponse, err error) { - req, err := c.preparerForRetrieveCertificateEmailHistory(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "RetrieveCertificateEmailHistory", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "RetrieveCertificateEmailHistory", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForRetrieveCertificateEmailHistory(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "RetrieveCertificateEmailHistory", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForRetrieveCertificateEmailHistory prepares the RetrieveCertificateEmailHistory request. -func (c AppServiceCertificateOrdersClient) preparerForRetrieveCertificateEmailHistory(ctx context.Context, id CertificateOrderId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/retrieveEmailHistory", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForRetrieveCertificateEmailHistory handles the response to the RetrieveCertificateEmailHistory request. The method always -// closes the http.Response Body. -func (c AppServiceCertificateOrdersClient) responderForRetrieveCertificateEmailHistory(resp *http.Response) (result RetrieveCertificateEmailHistoryOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/appservicecertificateorders/method_retrievesiteseal.go b/resource-manager/web/2022-09-01/appservicecertificateorders/method_retrievesiteseal.go new file mode 100644 index 00000000000..f7f78f33051 --- /dev/null +++ b/resource-manager/web/2022-09-01/appservicecertificateorders/method_retrievesiteseal.go @@ -0,0 +1,56 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "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 RetrieveSiteSealOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteSeal +} + +// RetrieveSiteSeal ... +func (c AppServiceCertificateOrdersClient) RetrieveSiteSeal(ctx context.Context, id CertificateOrderId, input SiteSealRequest) (result RetrieveSiteSealOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/retrieveSiteSeal", 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 +} diff --git a/resource-manager/web/2022-09-01/appservicecertificateorders/method_retrievesiteseal_autorest.go b/resource-manager/web/2022-09-01/appservicecertificateorders/method_retrievesiteseal_autorest.go deleted file mode 100644 index b5912d04479..00000000000 --- a/resource-manager/web/2022-09-01/appservicecertificateorders/method_retrievesiteseal_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package appservicecertificateorders - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type RetrieveSiteSealOperationResponse struct { - HttpResponse *http.Response - Model *SiteSeal -} - -// RetrieveSiteSeal ... -func (c AppServiceCertificateOrdersClient) RetrieveSiteSeal(ctx context.Context, id CertificateOrderId, input SiteSealRequest) (result RetrieveSiteSealOperationResponse, err error) { - req, err := c.preparerForRetrieveSiteSeal(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "RetrieveSiteSeal", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "RetrieveSiteSeal", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForRetrieveSiteSeal(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "RetrieveSiteSeal", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForRetrieveSiteSeal prepares the RetrieveSiteSeal request. -func (c AppServiceCertificateOrdersClient) preparerForRetrieveSiteSeal(ctx context.Context, id CertificateOrderId, input SiteSealRequest) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/retrieveSiteSeal", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForRetrieveSiteSeal handles the response to the RetrieveSiteSeal request. The method always -// closes the http.Response Body. -func (c AppServiceCertificateOrdersClient) responderForRetrieveSiteSeal(resp *http.Response) (result RetrieveSiteSealOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/appservicecertificateorders/method_update.go b/resource-manager/web/2022-09-01/appservicecertificateorders/method_update.go new file mode 100644 index 00000000000..d60930bc0f8 --- /dev/null +++ b/resource-manager/web/2022-09-01/appservicecertificateorders/method_update.go @@ -0,0 +1,55 @@ +package appservicecertificateorders + +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 UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AppServiceCertificateOrder +} + +// Update ... +func (c AppServiceCertificateOrdersClient) Update(ctx context.Context, id CertificateOrderId, input AppServiceCertificateOrderPatchResource) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + 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 +} diff --git a/resource-manager/web/2022-09-01/appservicecertificateorders/method_update_autorest.go b/resource-manager/web/2022-09-01/appservicecertificateorders/method_update_autorest.go deleted file mode 100644 index e29b4c02639..00000000000 --- a/resource-manager/web/2022-09-01/appservicecertificateorders/method_update_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package appservicecertificateorders - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateOperationResponse struct { - HttpResponse *http.Response - Model *AppServiceCertificateOrder -} - -// Update ... -func (c AppServiceCertificateOrdersClient) Update(ctx context.Context, id CertificateOrderId, input AppServiceCertificateOrderPatchResource) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c AppServiceCertificateOrdersClient) preparerForUpdate(ctx context.Context, id CertificateOrderId, input AppServiceCertificateOrderPatchResource) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdate handles the response to the Update request. The method always -// closes the http.Response Body. -func (c AppServiceCertificateOrdersClient) responderForUpdate(resp *http.Response) (result UpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/appservicecertificateorders/method_updatecertificate.go b/resource-manager/web/2022-09-01/appservicecertificateorders/method_updatecertificate.go new file mode 100644 index 00000000000..d64fb526b1c --- /dev/null +++ b/resource-manager/web/2022-09-01/appservicecertificateorders/method_updatecertificate.go @@ -0,0 +1,55 @@ +package appservicecertificateorders + +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 UpdateCertificateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AppServiceCertificateResource +} + +// UpdateCertificate ... +func (c AppServiceCertificateOrdersClient) UpdateCertificate(ctx context.Context, id CertificateId, input AppServiceCertificatePatchResource) (result UpdateCertificateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + 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 +} diff --git a/resource-manager/web/2022-09-01/appservicecertificateorders/method_updatecertificate_autorest.go b/resource-manager/web/2022-09-01/appservicecertificateorders/method_updatecertificate_autorest.go deleted file mode 100644 index 722e97129ee..00000000000 --- a/resource-manager/web/2022-09-01/appservicecertificateorders/method_updatecertificate_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package appservicecertificateorders - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateCertificateOperationResponse struct { - HttpResponse *http.Response - Model *AppServiceCertificateResource -} - -// UpdateCertificate ... -func (c AppServiceCertificateOrdersClient) UpdateCertificate(ctx context.Context, id CertificateId, input AppServiceCertificatePatchResource) (result UpdateCertificateOperationResponse, err error) { - req, err := c.preparerForUpdateCertificate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "UpdateCertificate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "UpdateCertificate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateCertificate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "UpdateCertificate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateCertificate prepares the UpdateCertificate request. -func (c AppServiceCertificateOrdersClient) preparerForUpdateCertificate(ctx context.Context, id CertificateId, input AppServiceCertificatePatchResource) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateCertificate handles the response to the UpdateCertificate request. The method always -// closes the http.Response Body. -func (c AppServiceCertificateOrdersClient) responderForUpdateCertificate(resp *http.Response) (result UpdateCertificateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/appservicecertificateorders/method_validatepurchaseinformation.go b/resource-manager/web/2022-09-01/appservicecertificateorders/method_validatepurchaseinformation.go new file mode 100644 index 00000000000..892b649302a --- /dev/null +++ b/resource-manager/web/2022-09-01/appservicecertificateorders/method_validatepurchaseinformation.go @@ -0,0 +1,52 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ValidatePurchaseInformationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ValidatePurchaseInformation ... +func (c AppServiceCertificateOrdersClient) ValidatePurchaseInformation(ctx context.Context, id commonids.SubscriptionId, input AppServiceCertificateOrder) (result ValidatePurchaseInformationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.CertificateRegistration/validateCertificateRegistrationInformation", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/appservicecertificateorders/method_validatepurchaseinformation_autorest.go b/resource-manager/web/2022-09-01/appservicecertificateorders/method_validatepurchaseinformation_autorest.go deleted file mode 100644 index 5f4be1ddf9c..00000000000 --- a/resource-manager/web/2022-09-01/appservicecertificateorders/method_validatepurchaseinformation_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package appservicecertificateorders - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ValidatePurchaseInformationOperationResponse struct { - HttpResponse *http.Response -} - -// ValidatePurchaseInformation ... -func (c AppServiceCertificateOrdersClient) ValidatePurchaseInformation(ctx context.Context, id commonids.SubscriptionId, input AppServiceCertificateOrder) (result ValidatePurchaseInformationOperationResponse, err error) { - req, err := c.preparerForValidatePurchaseInformation(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "ValidatePurchaseInformation", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "ValidatePurchaseInformation", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForValidatePurchaseInformation(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "ValidatePurchaseInformation", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForValidatePurchaseInformation prepares the ValidatePurchaseInformation request. -func (c AppServiceCertificateOrdersClient) preparerForValidatePurchaseInformation(ctx context.Context, id commonids.SubscriptionId, input AppServiceCertificateOrder) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.CertificateRegistration/validateCertificateRegistrationInformation", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForValidatePurchaseInformation handles the response to the ValidatePurchaseInformation request. The method always -// closes the http.Response Body. -func (c AppServiceCertificateOrdersClient) responderForValidatePurchaseInformation(resp *http.Response) (result ValidatePurchaseInformationOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/appservicecertificateorders/method_verifydomainownership.go b/resource-manager/web/2022-09-01/appservicecertificateorders/method_verifydomainownership.go new file mode 100644 index 00000000000..6ffc2fcef75 --- /dev/null +++ b/resource-manager/web/2022-09-01/appservicecertificateorders/method_verifydomainownership.go @@ -0,0 +1,47 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "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 VerifyDomainOwnershipOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// VerifyDomainOwnership ... +func (c AppServiceCertificateOrdersClient) VerifyDomainOwnership(ctx context.Context, id CertificateOrderId) (result VerifyDomainOwnershipOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/verifyDomainOwnership", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/appservicecertificateorders/method_verifydomainownership_autorest.go b/resource-manager/web/2022-09-01/appservicecertificateorders/method_verifydomainownership_autorest.go deleted file mode 100644 index a433d0a74ed..00000000000 --- a/resource-manager/web/2022-09-01/appservicecertificateorders/method_verifydomainownership_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package appservicecertificateorders - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type VerifyDomainOwnershipOperationResponse struct { - HttpResponse *http.Response -} - -// VerifyDomainOwnership ... -func (c AppServiceCertificateOrdersClient) VerifyDomainOwnership(ctx context.Context, id CertificateOrderId) (result VerifyDomainOwnershipOperationResponse, err error) { - req, err := c.preparerForVerifyDomainOwnership(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "VerifyDomainOwnership", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "VerifyDomainOwnership", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForVerifyDomainOwnership(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appservicecertificateorders.AppServiceCertificateOrdersClient", "VerifyDomainOwnership", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForVerifyDomainOwnership prepares the VerifyDomainOwnership request. -func (c AppServiceCertificateOrdersClient) preparerForVerifyDomainOwnership(ctx context.Context, id CertificateOrderId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/verifyDomainOwnership", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForVerifyDomainOwnership handles the response to the VerifyDomainOwnership request. The method always -// closes the http.Response Body. -func (c AppServiceCertificateOrdersClient) responderForVerifyDomainOwnership(resp *http.Response) (result VerifyDomainOwnershipOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/client.go b/resource-manager/web/2022-09-01/appserviceenvironments/client.go index c3cdcdefb95..b4293f8c768 100644 --- a/resource-manager/web/2022-09-01/appserviceenvironments/client.go +++ b/resource-manager/web/2022-09-01/appserviceenvironments/client.go @@ -1,18 +1,26 @@ package appserviceenvironments -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 AppServiceEnvironmentsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewAppServiceEnvironmentsClientWithBaseURI(endpoint string) AppServiceEnvironmentsClient { - return AppServiceEnvironmentsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewAppServiceEnvironmentsClientWithBaseURI(api environments.Api) (*AppServiceEnvironmentsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "appserviceenvironments", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AppServiceEnvironmentsClient: %+v", err) } + + return &AppServiceEnvironmentsClient{ + Client: client, + }, nil } diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/constants.go b/resource-manager/web/2022-09-01/appserviceenvironments/constants.go index 4294754bd94..75dd6b050d6 100644 --- a/resource-manager/web/2022-09-01/appserviceenvironments/constants.go +++ b/resource-manager/web/2022-09-01/appserviceenvironments/constants.go @@ -1,6 +1,10 @@ package appserviceenvironments -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. @@ -21,6 +25,19 @@ func PossibleValuesForAutoHealActionType() []string { } } +func (s *AutoHealActionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutoHealActionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAutoHealActionType(input string) (*AutoHealActionType, error) { vals := map[string]AutoHealActionType{ "customaction": AutoHealActionTypeCustomAction, @@ -54,6 +71,19 @@ func PossibleValuesForAzureStorageState() []string { } } +func (s *AzureStorageState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureStorageState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAzureStorageState(input string) (*AzureStorageState, error) { vals := map[string]AzureStorageState{ "invalidcredentials": AzureStorageStateInvalidCredentials, @@ -84,6 +114,19 @@ func PossibleValuesForAzureStorageType() []string { } } +func (s *AzureStorageType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureStorageType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAzureStorageType(input string) (*AzureStorageType, error) { vals := map[string]AzureStorageType{ "azureblob": AzureStorageTypeAzureBlob, @@ -114,6 +157,19 @@ func PossibleValuesForClientCertMode() []string { } } +func (s *ClientCertMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClientCertMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseClientCertMode(input string) (*ClientCertMode, error) { vals := map[string]ClientCertMode{ "optional": ClientCertModeOptional, @@ -145,6 +201,19 @@ func PossibleValuesForComputeModeOptions() []string { } } +func (s *ComputeModeOptions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseComputeModeOptions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseComputeModeOptions(input string) (*ComputeModeOptions, error) { vals := map[string]ComputeModeOptions{ "dedicated": ComputeModeOptionsDedicated, @@ -192,6 +261,19 @@ func PossibleValuesForConnectionStringType() []string { } } +func (s *ConnectionStringType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConnectionStringType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseConnectionStringType(input string) (*ConnectionStringType, error) { vals := map[string]ConnectionStringType{ "apihub": ConnectionStringTypeApiHub, @@ -233,6 +315,19 @@ func PossibleValuesForCustomDnsSuffixProvisioningState() []string { } } +func (s *CustomDnsSuffixProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCustomDnsSuffixProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseCustomDnsSuffixProvisioningState(input string) (*CustomDnsSuffixProvisioningState, error) { vals := map[string]CustomDnsSuffixProvisioningState{ "degraded": CustomDnsSuffixProvisioningStateDegraded, @@ -263,6 +358,19 @@ func PossibleValuesForDefaultAction() []string { } } +func (s *DefaultAction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDefaultAction(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseDefaultAction(input string) (*DefaultAction, error) { vals := map[string]DefaultAction{ "allow": DefaultActionAllow, @@ -293,6 +401,19 @@ func PossibleValuesForFtpsState() []string { } } +func (s *FtpsState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFtpsState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseFtpsState(input string) (*FtpsState, error) { vals := map[string]FtpsState{ "allallowed": FtpsStateAllAllowed, @@ -322,6 +443,19 @@ func PossibleValuesForHostType() []string { } } +func (s *HostType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHostType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseHostType(input string) (*HostType, error) { vals := map[string]HostType{ "repository": HostTypeRepository, @@ -354,6 +488,19 @@ func PossibleValuesForHostingEnvironmentStatus() []string { } } +func (s *HostingEnvironmentStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHostingEnvironmentStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseHostingEnvironmentStatus(input string) (*HostingEnvironmentStatus, error) { vals := map[string]HostingEnvironmentStatus{ "deleting": HostingEnvironmentStatusDeleting, @@ -386,6 +533,19 @@ func PossibleValuesForIPFilterTag() []string { } } +func (s *IPFilterTag) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPFilterTag(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseIPFilterTag(input string) (*IPFilterTag, error) { vals := map[string]IPFilterTag{ "default": IPFilterTagDefault, @@ -419,6 +579,19 @@ func PossibleValuesForLoadBalancingMode() []string { } } +func (s *LoadBalancingMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLoadBalancingMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseLoadBalancingMode(input string) (*LoadBalancingMode, error) { vals := map[string]LoadBalancingMode{ "none": LoadBalancingModeNone, @@ -449,6 +622,19 @@ func PossibleValuesForManagedPipelineMode() []string { } } +func (s *ManagedPipelineMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedPipelineMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseManagedPipelineMode(input string) (*ManagedPipelineMode, error) { vals := map[string]ManagedPipelineMode{ "classic": ManagedPipelineModeClassic, @@ -483,6 +669,19 @@ func PossibleValuesForOperationStatus() []string { } } +func (s *OperationStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOperationStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseOperationStatus(input string) (*OperationStatus, error) { vals := map[string]OperationStatus{ "created": OperationStatusCreated, @@ -520,6 +719,19 @@ func PossibleValuesForProvisioningState() []string { } } +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseProvisioningState(input string) (*ProvisioningState, error) { vals := map[string]ProvisioningState{ "canceled": ProvisioningStateCanceled, @@ -557,6 +769,19 @@ func PossibleValuesForRedundancyMode() []string { } } +func (s *RedundancyMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRedundancyMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseRedundancyMode(input string) (*RedundancyMode, error) { vals := map[string]RedundancyMode{ "activeactive": RedundancyModeActiveActive, @@ -612,6 +837,19 @@ func PossibleValuesForScmType() []string { } } +func (s *ScmType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseScmType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseScmType(input string) (*ScmType, error) { vals := map[string]ScmType{ "bitbucketgit": ScmTypeBitbucketGit, @@ -654,6 +892,19 @@ func PossibleValuesForSiteAvailabilityState() []string { } } +func (s *SiteAvailabilityState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSiteAvailabilityState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseSiteAvailabilityState(input string) (*SiteAvailabilityState, error) { vals := map[string]SiteAvailabilityState{ "disasterrecoverymode": SiteAvailabilityStateDisasterRecoveryMode, @@ -691,6 +942,19 @@ func PossibleValuesForSiteLoadBalancing() []string { } } +func (s *SiteLoadBalancing) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSiteLoadBalancing(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseSiteLoadBalancing(input string) (*SiteLoadBalancing, error) { vals := map[string]SiteLoadBalancing{ "leastrequests": SiteLoadBalancingLeastRequests, @@ -725,6 +989,19 @@ func PossibleValuesForSslState() []string { } } +func (s *SslState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSslState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseSslState(input string) (*SslState, error) { vals := map[string]SslState{ "disabled": SslStateDisabled, @@ -756,6 +1033,19 @@ func PossibleValuesForStatusOptions() []string { } } +func (s *StatusOptions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStatusOptions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseStatusOptions(input string) (*StatusOptions, error) { vals := map[string]StatusOptions{ "creating": StatusOptionsCreating, @@ -787,6 +1077,19 @@ func PossibleValuesForSupportedTlsVersions() []string { } } +func (s *SupportedTlsVersions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSupportedTlsVersions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseSupportedTlsVersions(input string) (*SupportedTlsVersions, error) { vals := map[string]SupportedTlsVersions{ "1.1": SupportedTlsVersionsOnePointOne, @@ -816,6 +1119,19 @@ func PossibleValuesForUpgradeAvailability() []string { } } +func (s *UpgradeAvailability) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUpgradeAvailability(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseUpgradeAvailability(input string) (*UpgradeAvailability, error) { vals := map[string]UpgradeAvailability{ "none": UpgradeAvailabilityNone, @@ -848,6 +1164,19 @@ func PossibleValuesForUpgradePreference() []string { } } +func (s *UpgradePreference) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUpgradePreference(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseUpgradePreference(input string) (*UpgradePreference, error) { vals := map[string]UpgradePreference{ "early": UpgradePreferenceEarly, @@ -878,6 +1207,19 @@ func PossibleValuesForUsageState() []string { } } +func (s *UsageState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUsageState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseUsageState(input string) (*UsageState, error) { vals := map[string]UsageState{ "exceeded": UsageStateExceeded, @@ -926,6 +1268,19 @@ func PossibleValuesForWorkerSizeOptions() []string { } } +func (s *WorkerSizeOptions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkerSizeOptions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseWorkerSizeOptions(input string) (*WorkerSizeOptions, error) { vals := map[string]WorkerSizeOptions{ "d1": WorkerSizeOptionsDOne, diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_approveorrejectprivateendpointconnection.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_approveorrejectprivateendpointconnection.go new file mode 100644 index 00000000000..75106f6df3b --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceenvironments/method_approveorrejectprivateendpointconnection.go @@ -0,0 +1,74 @@ +package appserviceenvironments + +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 ApproveOrRejectPrivateEndpointConnectionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ApproveOrRejectPrivateEndpointConnection ... +func (c AppServiceEnvironmentsClient) ApproveOrRejectPrivateEndpointConnection(ctx context.Context, id HostingEnvironmentPrivateEndpointConnectionId, input PrivateLinkConnectionApprovalRequestResource) (result ApproveOrRejectPrivateEndpointConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// ApproveOrRejectPrivateEndpointConnectionThenPoll performs ApproveOrRejectPrivateEndpointConnection then polls until it's completed +func (c AppServiceEnvironmentsClient) ApproveOrRejectPrivateEndpointConnectionThenPoll(ctx context.Context, id HostingEnvironmentPrivateEndpointConnectionId, input PrivateLinkConnectionApprovalRequestResource) error { + result, err := c.ApproveOrRejectPrivateEndpointConnection(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ApproveOrRejectPrivateEndpointConnection: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ApproveOrRejectPrivateEndpointConnection: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_approveorrejectprivateendpointconnection_autorest.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_approveorrejectprivateendpointconnection_autorest.go deleted file mode 100644 index ff4c22368b9..00000000000 --- a/resource-manager/web/2022-09-01/appserviceenvironments/method_approveorrejectprivateendpointconnection_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package appserviceenvironments - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ApproveOrRejectPrivateEndpointConnectionOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// ApproveOrRejectPrivateEndpointConnection ... -func (c AppServiceEnvironmentsClient) ApproveOrRejectPrivateEndpointConnection(ctx context.Context, id HostingEnvironmentPrivateEndpointConnectionId, input PrivateLinkConnectionApprovalRequestResource) (result ApproveOrRejectPrivateEndpointConnectionOperationResponse, err error) { - req, err := c.preparerForApproveOrRejectPrivateEndpointConnection(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ApproveOrRejectPrivateEndpointConnection", nil, "Failure preparing request") - return - } - - result, err = c.senderForApproveOrRejectPrivateEndpointConnection(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ApproveOrRejectPrivateEndpointConnection", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// ApproveOrRejectPrivateEndpointConnectionThenPoll performs ApproveOrRejectPrivateEndpointConnection then polls until it's completed -func (c AppServiceEnvironmentsClient) ApproveOrRejectPrivateEndpointConnectionThenPoll(ctx context.Context, id HostingEnvironmentPrivateEndpointConnectionId, input PrivateLinkConnectionApprovalRequestResource) error { - result, err := c.ApproveOrRejectPrivateEndpointConnection(ctx, id, input) - if err != nil { - return fmt.Errorf("performing ApproveOrRejectPrivateEndpointConnection: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after ApproveOrRejectPrivateEndpointConnection: %+v", err) - } - - return nil -} - -// preparerForApproveOrRejectPrivateEndpointConnection prepares the ApproveOrRejectPrivateEndpointConnection request. -func (c AppServiceEnvironmentsClient) preparerForApproveOrRejectPrivateEndpointConnection(ctx context.Context, id HostingEnvironmentPrivateEndpointConnectionId, input PrivateLinkConnectionApprovalRequestResource) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForApproveOrRejectPrivateEndpointConnection sends the ApproveOrRejectPrivateEndpointConnection request. The method will close the -// http.Response Body if it receives an error. -func (c AppServiceEnvironmentsClient) senderForApproveOrRejectPrivateEndpointConnection(ctx context.Context, req *http.Request) (future ApproveOrRejectPrivateEndpointConnectionOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_changevnet.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_changevnet.go new file mode 100644 index 00000000000..fad1e36d737 --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceenvironments/method_changevnet.go @@ -0,0 +1,88 @@ +package appserviceenvironments + +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 ChangeVnetOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *[]Site +} + +type ChangeVnetCompleteResult struct { + Items []Site +} + +// ChangeVnet ... +func (c AppServiceEnvironmentsClient) ChangeVnet(ctx context.Context, id HostingEnvironmentId, input VirtualNetworkProfile) (result ChangeVnetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/changeVirtualNetwork", 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 + } + + var values struct { + Values *[]Site `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ChangeVnetThenPoll performs ChangeVnet then polls until it's completed +func (c AppServiceEnvironmentsClient) ChangeVnetThenPoll(ctx context.Context, id HostingEnvironmentId, input VirtualNetworkProfile) error { + result, err := c.ChangeVnet(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ChangeVnet: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ChangeVnet: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_changevnet_autorest.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_changevnet_autorest.go deleted file mode 100644 index 8d1e8624d67..00000000000 --- a/resource-manager/web/2022-09-01/appserviceenvironments/method_changevnet_autorest.go +++ /dev/null @@ -1,125 +0,0 @@ -package appserviceenvironments - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ChangeVnetOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response - Model *[]Site - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ChangeVnetOperationResponse, error) -} - -type ChangeVnetCompleteResult struct { - Items []Site -} - -func (r ChangeVnetOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ChangeVnetOperationResponse) LoadMore(ctx context.Context) (resp ChangeVnetOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ChangeVnet ... -func (c AppServiceEnvironmentsClient) ChangeVnet(ctx context.Context, id HostingEnvironmentId, input VirtualNetworkProfile) (result ChangeVnetOperationResponse, err error) { - req, err := c.preparerForChangeVnet(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ChangeVnet", nil, "Failure preparing request") - return - } - - result, err = c.senderForChangeVnet(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ChangeVnet", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// ChangeVnetThenPoll performs ChangeVnet then polls until it's completed -func (c AppServiceEnvironmentsClient) ChangeVnetThenPoll(ctx context.Context, id HostingEnvironmentId, input VirtualNetworkProfile) error { - result, err := c.ChangeVnet(ctx, id, input) - if err != nil { - return fmt.Errorf("performing ChangeVnet: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after ChangeVnet: %+v", err) - } - - return nil -} - -// preparerForChangeVnet prepares the ChangeVnet request. -func (c AppServiceEnvironmentsClient) preparerForChangeVnet(ctx context.Context, id HostingEnvironmentId, input VirtualNetworkProfile) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/changeVirtualNetwork", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForChangeVnetWithNextLink prepares the ChangeVnet request with the given nextLink token. -func (c AppServiceEnvironmentsClient) preparerForChangeVnetWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForChangeVnet sends the ChangeVnet request. The method will close the -// http.Response Body if it receives an error. -func (c AppServiceEnvironmentsClient) senderForChangeVnet(ctx context.Context, req *http.Request) (future ChangeVnetOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_createorupdate.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_createorupdate.go new file mode 100644 index 00000000000..18603c474e3 --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceenvironments/method_createorupdate.go @@ -0,0 +1,75 @@ +package appserviceenvironments + +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 +} + +// CreateOrUpdate ... +func (c AppServiceEnvironmentsClient) CreateOrUpdate(ctx context.Context, id HostingEnvironmentId, input AppServiceEnvironmentResource) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 AppServiceEnvironmentsClient) CreateOrUpdateThenPoll(ctx context.Context, id HostingEnvironmentId, input AppServiceEnvironmentResource) 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 +} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_createorupdate_autorest.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_createorupdate_autorest.go deleted file mode 100644 index 83bde143516..00000000000 --- a/resource-manager/web/2022-09-01/appserviceenvironments/method_createorupdate_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package appserviceenvironments - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateOrUpdate ... -func (c AppServiceEnvironmentsClient) CreateOrUpdate(ctx context.Context, id HostingEnvironmentId, input AppServiceEnvironmentResource) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c AppServiceEnvironmentsClient) CreateOrUpdateThenPoll(ctx context.Context, id HostingEnvironmentId, input AppServiceEnvironmentResource) error { - result, err := c.CreateOrUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateOrUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateOrUpdate: %+v", err) - } - - return nil -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c AppServiceEnvironmentsClient) preparerForCreateOrUpdate(ctx context.Context, id HostingEnvironmentId, input AppServiceEnvironmentResource) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateOrUpdate sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c AppServiceEnvironmentsClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_createorupdatemultirolepool.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_createorupdatemultirolepool.go new file mode 100644 index 00000000000..9c605f0190d --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceenvironments/method_createorupdatemultirolepool.go @@ -0,0 +1,74 @@ +package appserviceenvironments + +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 CreateOrUpdateMultiRolePoolOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// CreateOrUpdateMultiRolePool ... +func (c AppServiceEnvironmentsClient) CreateOrUpdateMultiRolePool(ctx context.Context, id HostingEnvironmentId, input WorkerPoolResource) (result CreateOrUpdateMultiRolePoolOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/multiRolePools/default", 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 +} + +// CreateOrUpdateMultiRolePoolThenPoll performs CreateOrUpdateMultiRolePool then polls until it's completed +func (c AppServiceEnvironmentsClient) CreateOrUpdateMultiRolePoolThenPoll(ctx context.Context, id HostingEnvironmentId, input WorkerPoolResource) error { + result, err := c.CreateOrUpdateMultiRolePool(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdateMultiRolePool: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdateMultiRolePool: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_createorupdatemultirolepool_autorest.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_createorupdatemultirolepool_autorest.go deleted file mode 100644 index d23478a2534..00000000000 --- a/resource-manager/web/2022-09-01/appserviceenvironments/method_createorupdatemultirolepool_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package appserviceenvironments - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateMultiRolePoolOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateOrUpdateMultiRolePool ... -func (c AppServiceEnvironmentsClient) CreateOrUpdateMultiRolePool(ctx context.Context, id HostingEnvironmentId, input WorkerPoolResource) (result CreateOrUpdateMultiRolePoolOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdateMultiRolePool(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "CreateOrUpdateMultiRolePool", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdateMultiRolePool(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "CreateOrUpdateMultiRolePool", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateMultiRolePoolThenPoll performs CreateOrUpdateMultiRolePool then polls until it's completed -func (c AppServiceEnvironmentsClient) CreateOrUpdateMultiRolePoolThenPoll(ctx context.Context, id HostingEnvironmentId, input WorkerPoolResource) error { - result, err := c.CreateOrUpdateMultiRolePool(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateOrUpdateMultiRolePool: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateOrUpdateMultiRolePool: %+v", err) - } - - return nil -} - -// preparerForCreateOrUpdateMultiRolePool prepares the CreateOrUpdateMultiRolePool request. -func (c AppServiceEnvironmentsClient) preparerForCreateOrUpdateMultiRolePool(ctx context.Context, id HostingEnvironmentId, input WorkerPoolResource) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/multiRolePools/default", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateOrUpdateMultiRolePool sends the CreateOrUpdateMultiRolePool request. The method will close the -// http.Response Body if it receives an error. -func (c AppServiceEnvironmentsClient) senderForCreateOrUpdateMultiRolePool(ctx context.Context, req *http.Request) (future CreateOrUpdateMultiRolePoolOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_createorupdateworkerpool.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_createorupdateworkerpool.go new file mode 100644 index 00000000000..2dd7e542a5b --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceenvironments/method_createorupdateworkerpool.go @@ -0,0 +1,74 @@ +package appserviceenvironments + +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 CreateOrUpdateWorkerPoolOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// CreateOrUpdateWorkerPool ... +func (c AppServiceEnvironmentsClient) CreateOrUpdateWorkerPool(ctx context.Context, id WorkerPoolId, input WorkerPoolResource) (result CreateOrUpdateWorkerPoolOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// CreateOrUpdateWorkerPoolThenPoll performs CreateOrUpdateWorkerPool then polls until it's completed +func (c AppServiceEnvironmentsClient) CreateOrUpdateWorkerPoolThenPoll(ctx context.Context, id WorkerPoolId, input WorkerPoolResource) error { + result, err := c.CreateOrUpdateWorkerPool(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdateWorkerPool: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdateWorkerPool: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_createorupdateworkerpool_autorest.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_createorupdateworkerpool_autorest.go deleted file mode 100644 index 5b69f8e257b..00000000000 --- a/resource-manager/web/2022-09-01/appserviceenvironments/method_createorupdateworkerpool_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package appserviceenvironments - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateWorkerPoolOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateOrUpdateWorkerPool ... -func (c AppServiceEnvironmentsClient) CreateOrUpdateWorkerPool(ctx context.Context, id WorkerPoolId, input WorkerPoolResource) (result CreateOrUpdateWorkerPoolOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdateWorkerPool(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "CreateOrUpdateWorkerPool", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdateWorkerPool(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "CreateOrUpdateWorkerPool", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateWorkerPoolThenPoll performs CreateOrUpdateWorkerPool then polls until it's completed -func (c AppServiceEnvironmentsClient) CreateOrUpdateWorkerPoolThenPoll(ctx context.Context, id WorkerPoolId, input WorkerPoolResource) error { - result, err := c.CreateOrUpdateWorkerPool(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateOrUpdateWorkerPool: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateOrUpdateWorkerPool: %+v", err) - } - - return nil -} - -// preparerForCreateOrUpdateWorkerPool prepares the CreateOrUpdateWorkerPool request. -func (c AppServiceEnvironmentsClient) preparerForCreateOrUpdateWorkerPool(ctx context.Context, id WorkerPoolId, input WorkerPoolResource) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateOrUpdateWorkerPool sends the CreateOrUpdateWorkerPool request. The method will close the -// http.Response Body if it receives an error. -func (c AppServiceEnvironmentsClient) senderForCreateOrUpdateWorkerPool(ctx context.Context, req *http.Request) (future CreateOrUpdateWorkerPoolOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_delete.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_delete.go new file mode 100644 index 00000000000..f36f302948c --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceenvironments/method_delete.go @@ -0,0 +1,98 @@ +package appserviceenvironments + +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 +} + +type DeleteOperationOptions struct { + ForceDelete *bool +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.ForceDelete != nil { + out.Append("forceDelete", fmt.Sprintf("%v", *o.ForceDelete)) + } + return &out +} + +// Delete ... +func (c AppServiceEnvironmentsClient) Delete(ctx context.Context, id HostingEnvironmentId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + 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 AppServiceEnvironmentsClient) DeleteThenPoll(ctx context.Context, id HostingEnvironmentId, options DeleteOperationOptions) error { + result, err := c.Delete(ctx, id, options) + 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 +} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_delete_autorest.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_delete_autorest.go deleted file mode 100644 index 3ea8b3628ba..00000000000 --- a/resource-manager/web/2022-09-01/appserviceenvironments/method_delete_autorest.go +++ /dev/null @@ -1,107 +0,0 @@ -package appserviceenvironments - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -type DeleteOperationOptions struct { - ForceDelete *bool -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.ForceDelete != nil { - out["forceDelete"] = *o.ForceDelete - } - - return out -} - -// Delete ... -func (c AppServiceEnvironmentsClient) Delete(ctx context.Context, id HostingEnvironmentId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c AppServiceEnvironmentsClient) DeleteThenPoll(ctx context.Context, id HostingEnvironmentId, options DeleteOperationOptions) error { - result, err := c.Delete(ctx, id, options) - if err != nil { - return fmt.Errorf("performing Delete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Delete: %+v", err) - } - - return nil -} - -// preparerForDelete prepares the Delete request. -func (c AppServiceEnvironmentsClient) preparerForDelete(ctx context.Context, id HostingEnvironmentId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDelete sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (c AppServiceEnvironmentsClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_deleteasecustomdnssuffixconfiguration.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_deleteasecustomdnssuffixconfiguration.go new file mode 100644 index 00000000000..d21b6513cea --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceenvironments/method_deleteasecustomdnssuffixconfiguration.go @@ -0,0 +1,53 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "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 DeleteAseCustomDnsSuffixConfigurationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *interface{} +} + +// DeleteAseCustomDnsSuffixConfiguration ... +func (c AppServiceEnvironmentsClient) DeleteAseCustomDnsSuffixConfiguration(ctx context.Context, id HostingEnvironmentId) (result DeleteAseCustomDnsSuffixConfigurationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: fmt.Sprintf("%s/configurations/customdnssuffix", 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 +} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_deleteasecustomdnssuffixconfiguration_autorest.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_deleteasecustomdnssuffixconfiguration_autorest.go deleted file mode 100644 index 3807b6ff8a5..00000000000 --- a/resource-manager/web/2022-09-01/appserviceenvironments/method_deleteasecustomdnssuffixconfiguration_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package appserviceenvironments - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteAseCustomDnsSuffixConfigurationOperationResponse struct { - HttpResponse *http.Response - Model *interface{} -} - -// DeleteAseCustomDnsSuffixConfiguration ... -func (c AppServiceEnvironmentsClient) DeleteAseCustomDnsSuffixConfiguration(ctx context.Context, id HostingEnvironmentId) (result DeleteAseCustomDnsSuffixConfigurationOperationResponse, err error) { - req, err := c.preparerForDeleteAseCustomDnsSuffixConfiguration(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "DeleteAseCustomDnsSuffixConfiguration", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "DeleteAseCustomDnsSuffixConfiguration", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeleteAseCustomDnsSuffixConfiguration(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "DeleteAseCustomDnsSuffixConfiguration", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeleteAseCustomDnsSuffixConfiguration prepares the DeleteAseCustomDnsSuffixConfiguration request. -func (c AppServiceEnvironmentsClient) preparerForDeleteAseCustomDnsSuffixConfiguration(ctx context.Context, id HostingEnvironmentId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/configurations/customdnssuffix", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeleteAseCustomDnsSuffixConfiguration handles the response to the DeleteAseCustomDnsSuffixConfiguration request. The method always -// closes the http.Response Body. -func (c AppServiceEnvironmentsClient) responderForDeleteAseCustomDnsSuffixConfiguration(resp *http.Response) (result DeleteAseCustomDnsSuffixConfigurationOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_deleteprivateendpointconnection.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_deleteprivateendpointconnection.go new file mode 100644 index 00000000000..2ea20c2aff3 --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceenvironments/method_deleteprivateendpointconnection.go @@ -0,0 +1,71 @@ +package appserviceenvironments + +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 DeletePrivateEndpointConnectionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// DeletePrivateEndpointConnection ... +func (c AppServiceEnvironmentsClient) DeletePrivateEndpointConnection(ctx context.Context, id HostingEnvironmentPrivateEndpointConnectionId) (result DeletePrivateEndpointConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 +} + +// DeletePrivateEndpointConnectionThenPoll performs DeletePrivateEndpointConnection then polls until it's completed +func (c AppServiceEnvironmentsClient) DeletePrivateEndpointConnectionThenPoll(ctx context.Context, id HostingEnvironmentPrivateEndpointConnectionId) error { + result, err := c.DeletePrivateEndpointConnection(ctx, id) + if err != nil { + return fmt.Errorf("performing DeletePrivateEndpointConnection: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DeletePrivateEndpointConnection: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_deleteprivateendpointconnection_autorest.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_deleteprivateendpointconnection_autorest.go deleted file mode 100644 index bf17005552a..00000000000 --- a/resource-manager/web/2022-09-01/appserviceenvironments/method_deleteprivateendpointconnection_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package appserviceenvironments - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeletePrivateEndpointConnectionOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// DeletePrivateEndpointConnection ... -func (c AppServiceEnvironmentsClient) DeletePrivateEndpointConnection(ctx context.Context, id HostingEnvironmentPrivateEndpointConnectionId) (result DeletePrivateEndpointConnectionOperationResponse, err error) { - req, err := c.preparerForDeletePrivateEndpointConnection(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "DeletePrivateEndpointConnection", nil, "Failure preparing request") - return - } - - result, err = c.senderForDeletePrivateEndpointConnection(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "DeletePrivateEndpointConnection", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeletePrivateEndpointConnectionThenPoll performs DeletePrivateEndpointConnection then polls until it's completed -func (c AppServiceEnvironmentsClient) DeletePrivateEndpointConnectionThenPoll(ctx context.Context, id HostingEnvironmentPrivateEndpointConnectionId) error { - result, err := c.DeletePrivateEndpointConnection(ctx, id) - if err != nil { - return fmt.Errorf("performing DeletePrivateEndpointConnection: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after DeletePrivateEndpointConnection: %+v", err) - } - - return nil -} - -// preparerForDeletePrivateEndpointConnection prepares the DeletePrivateEndpointConnection request. -func (c AppServiceEnvironmentsClient) preparerForDeletePrivateEndpointConnection(ctx context.Context, id HostingEnvironmentPrivateEndpointConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDeletePrivateEndpointConnection sends the DeletePrivateEndpointConnection request. The method will close the -// http.Response Body if it receives an error. -func (c AppServiceEnvironmentsClient) senderForDeletePrivateEndpointConnection(ctx context.Context, req *http.Request) (future DeletePrivateEndpointConnectionOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_get.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_get.go new file mode 100644 index 00000000000..fc34fa13b31 --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceenvironments/method_get.go @@ -0,0 +1,51 @@ +package appserviceenvironments + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AppServiceEnvironmentResource +} + +// Get ... +func (c AppServiceEnvironmentsClient) Get(ctx context.Context, id HostingEnvironmentId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_get_autorest.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_get_autorest.go deleted file mode 100644 index 4f2f0c75a8f..00000000000 --- a/resource-manager/web/2022-09-01/appserviceenvironments/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package appserviceenvironments - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *AppServiceEnvironmentResource -} - -// Get ... -func (c AppServiceEnvironmentsClient) Get(ctx context.Context, id HostingEnvironmentId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c AppServiceEnvironmentsClient) preparerForGet(ctx context.Context, id HostingEnvironmentId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c AppServiceEnvironmentsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_getasecustomdnssuffixconfiguration.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_getasecustomdnssuffixconfiguration.go new file mode 100644 index 00000000000..fb05308f5f2 --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceenvironments/method_getasecustomdnssuffixconfiguration.go @@ -0,0 +1,52 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "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 GetAseCustomDnsSuffixConfigurationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CustomDnsSuffixConfiguration +} + +// GetAseCustomDnsSuffixConfiguration ... +func (c AppServiceEnvironmentsClient) GetAseCustomDnsSuffixConfiguration(ctx context.Context, id HostingEnvironmentId) (result GetAseCustomDnsSuffixConfigurationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/configurations/customdnssuffix", 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 +} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_getasecustomdnssuffixconfiguration_autorest.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_getasecustomdnssuffixconfiguration_autorest.go deleted file mode 100644 index 19c55d7ab39..00000000000 --- a/resource-manager/web/2022-09-01/appserviceenvironments/method_getasecustomdnssuffixconfiguration_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package appserviceenvironments - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetAseCustomDnsSuffixConfigurationOperationResponse struct { - HttpResponse *http.Response - Model *CustomDnsSuffixConfiguration -} - -// GetAseCustomDnsSuffixConfiguration ... -func (c AppServiceEnvironmentsClient) GetAseCustomDnsSuffixConfiguration(ctx context.Context, id HostingEnvironmentId) (result GetAseCustomDnsSuffixConfigurationOperationResponse, err error) { - req, err := c.preparerForGetAseCustomDnsSuffixConfiguration(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "GetAseCustomDnsSuffixConfiguration", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "GetAseCustomDnsSuffixConfiguration", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetAseCustomDnsSuffixConfiguration(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "GetAseCustomDnsSuffixConfiguration", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetAseCustomDnsSuffixConfiguration prepares the GetAseCustomDnsSuffixConfiguration request. -func (c AppServiceEnvironmentsClient) preparerForGetAseCustomDnsSuffixConfiguration(ctx context.Context, id HostingEnvironmentId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/configurations/customdnssuffix", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetAseCustomDnsSuffixConfiguration handles the response to the GetAseCustomDnsSuffixConfiguration request. The method always -// closes the http.Response Body. -func (c AppServiceEnvironmentsClient) responderForGetAseCustomDnsSuffixConfiguration(resp *http.Response) (result GetAseCustomDnsSuffixConfigurationOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_getasev3networkingconfiguration.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_getasev3networkingconfiguration.go new file mode 100644 index 00000000000..3a1581eae95 --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceenvironments/method_getasev3networkingconfiguration.go @@ -0,0 +1,52 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "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 GetAseV3NetworkingConfigurationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AseV3NetworkingConfiguration +} + +// GetAseV3NetworkingConfiguration ... +func (c AppServiceEnvironmentsClient) GetAseV3NetworkingConfiguration(ctx context.Context, id HostingEnvironmentId) (result GetAseV3NetworkingConfigurationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/configurations/networking", 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 +} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_getasev3networkingconfiguration_autorest.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_getasev3networkingconfiguration_autorest.go deleted file mode 100644 index 6e568c3b542..00000000000 --- a/resource-manager/web/2022-09-01/appserviceenvironments/method_getasev3networkingconfiguration_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package appserviceenvironments - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetAseV3NetworkingConfigurationOperationResponse struct { - HttpResponse *http.Response - Model *AseV3NetworkingConfiguration -} - -// GetAseV3NetworkingConfiguration ... -func (c AppServiceEnvironmentsClient) GetAseV3NetworkingConfiguration(ctx context.Context, id HostingEnvironmentId) (result GetAseV3NetworkingConfigurationOperationResponse, err error) { - req, err := c.preparerForGetAseV3NetworkingConfiguration(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "GetAseV3NetworkingConfiguration", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "GetAseV3NetworkingConfiguration", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetAseV3NetworkingConfiguration(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "GetAseV3NetworkingConfiguration", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetAseV3NetworkingConfiguration prepares the GetAseV3NetworkingConfiguration request. -func (c AppServiceEnvironmentsClient) preparerForGetAseV3NetworkingConfiguration(ctx context.Context, id HostingEnvironmentId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/configurations/networking", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetAseV3NetworkingConfiguration handles the response to the GetAseV3NetworkingConfiguration request. The method always -// closes the http.Response Body. -func (c AppServiceEnvironmentsClient) responderForGetAseV3NetworkingConfiguration(resp *http.Response) (result GetAseV3NetworkingConfigurationOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_getdiagnosticsitem.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_getdiagnosticsitem.go new file mode 100644 index 00000000000..39d06614606 --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceenvironments/method_getdiagnosticsitem.go @@ -0,0 +1,51 @@ +package appserviceenvironments + +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 GetDiagnosticsItemOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HostingEnvironmentDiagnostics +} + +// GetDiagnosticsItem ... +func (c AppServiceEnvironmentsClient) GetDiagnosticsItem(ctx context.Context, id HostingEnvironmentDiagnosticId) (result GetDiagnosticsItemOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_getdiagnosticsitem_autorest.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_getdiagnosticsitem_autorest.go deleted file mode 100644 index 3462171e41d..00000000000 --- a/resource-manager/web/2022-09-01/appserviceenvironments/method_getdiagnosticsitem_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package appserviceenvironments - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetDiagnosticsItemOperationResponse struct { - HttpResponse *http.Response - Model *HostingEnvironmentDiagnostics -} - -// GetDiagnosticsItem ... -func (c AppServiceEnvironmentsClient) GetDiagnosticsItem(ctx context.Context, id HostingEnvironmentDiagnosticId) (result GetDiagnosticsItemOperationResponse, err error) { - req, err := c.preparerForGetDiagnosticsItem(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "GetDiagnosticsItem", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "GetDiagnosticsItem", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetDiagnosticsItem(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "GetDiagnosticsItem", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetDiagnosticsItem prepares the GetDiagnosticsItem request. -func (c AppServiceEnvironmentsClient) preparerForGetDiagnosticsItem(ctx context.Context, id HostingEnvironmentDiagnosticId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetDiagnosticsItem handles the response to the GetDiagnosticsItem request. The method always -// closes the http.Response Body. -func (c AppServiceEnvironmentsClient) responderForGetDiagnosticsItem(resp *http.Response) (result GetDiagnosticsItemOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_getinboundnetworkdependenciesendpoints.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_getinboundnetworkdependenciesendpoints.go new file mode 100644 index 00000000000..fbaad7a04b2 --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceenvironments/method_getinboundnetworkdependenciesendpoints.go @@ -0,0 +1,89 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "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 GetInboundNetworkDependenciesEndpointsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]InboundEnvironmentEndpoint +} + +type GetInboundNetworkDependenciesEndpointsCompleteResult struct { + Items []InboundEnvironmentEndpoint +} + +// GetInboundNetworkDependenciesEndpoints ... +func (c AppServiceEnvironmentsClient) GetInboundNetworkDependenciesEndpoints(ctx context.Context, id HostingEnvironmentId) (result GetInboundNetworkDependenciesEndpointsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/inboundNetworkDependenciesEndpoints", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]InboundEnvironmentEndpoint `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetInboundNetworkDependenciesEndpointsComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) GetInboundNetworkDependenciesEndpointsComplete(ctx context.Context, id HostingEnvironmentId) (GetInboundNetworkDependenciesEndpointsCompleteResult, error) { + return c.GetInboundNetworkDependenciesEndpointsCompleteMatchingPredicate(ctx, id, InboundEnvironmentEndpointOperationPredicate{}) +} + +// GetInboundNetworkDependenciesEndpointsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) GetInboundNetworkDependenciesEndpointsCompleteMatchingPredicate(ctx context.Context, id HostingEnvironmentId, predicate InboundEnvironmentEndpointOperationPredicate) (result GetInboundNetworkDependenciesEndpointsCompleteResult, err error) { + items := make([]InboundEnvironmentEndpoint, 0) + + resp, err := c.GetInboundNetworkDependenciesEndpoints(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetInboundNetworkDependenciesEndpointsCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_getinboundnetworkdependenciesendpoints_autorest.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_getinboundnetworkdependenciesendpoints_autorest.go deleted file mode 100644 index 1fd989d985b..00000000000 --- a/resource-manager/web/2022-09-01/appserviceenvironments/method_getinboundnetworkdependenciesendpoints_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package appserviceenvironments - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetInboundNetworkDependenciesEndpointsOperationResponse struct { - HttpResponse *http.Response - Model *[]InboundEnvironmentEndpoint - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (GetInboundNetworkDependenciesEndpointsOperationResponse, error) -} - -type GetInboundNetworkDependenciesEndpointsCompleteResult struct { - Items []InboundEnvironmentEndpoint -} - -func (r GetInboundNetworkDependenciesEndpointsOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r GetInboundNetworkDependenciesEndpointsOperationResponse) LoadMore(ctx context.Context) (resp GetInboundNetworkDependenciesEndpointsOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// GetInboundNetworkDependenciesEndpoints ... -func (c AppServiceEnvironmentsClient) GetInboundNetworkDependenciesEndpoints(ctx context.Context, id HostingEnvironmentId) (resp GetInboundNetworkDependenciesEndpointsOperationResponse, err error) { - req, err := c.preparerForGetInboundNetworkDependenciesEndpoints(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "GetInboundNetworkDependenciesEndpoints", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "GetInboundNetworkDependenciesEndpoints", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForGetInboundNetworkDependenciesEndpoints(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "GetInboundNetworkDependenciesEndpoints", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForGetInboundNetworkDependenciesEndpoints prepares the GetInboundNetworkDependenciesEndpoints request. -func (c AppServiceEnvironmentsClient) preparerForGetInboundNetworkDependenciesEndpoints(ctx context.Context, id HostingEnvironmentId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/inboundNetworkDependenciesEndpoints", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForGetInboundNetworkDependenciesEndpointsWithNextLink prepares the GetInboundNetworkDependenciesEndpoints request with the given nextLink token. -func (c AppServiceEnvironmentsClient) preparerForGetInboundNetworkDependenciesEndpointsWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetInboundNetworkDependenciesEndpoints handles the response to the GetInboundNetworkDependenciesEndpoints request. The method always -// closes the http.Response Body. -func (c AppServiceEnvironmentsClient) responderForGetInboundNetworkDependenciesEndpoints(resp *http.Response) (result GetInboundNetworkDependenciesEndpointsOperationResponse, err error) { - type page struct { - Values []InboundEnvironmentEndpoint `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result GetInboundNetworkDependenciesEndpointsOperationResponse, err error) { - req, err := c.preparerForGetInboundNetworkDependenciesEndpointsWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "GetInboundNetworkDependenciesEndpoints", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "GetInboundNetworkDependenciesEndpoints", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetInboundNetworkDependenciesEndpoints(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "GetInboundNetworkDependenciesEndpoints", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// GetInboundNetworkDependenciesEndpointsComplete retrieves all of the results into a single object -func (c AppServiceEnvironmentsClient) GetInboundNetworkDependenciesEndpointsComplete(ctx context.Context, id HostingEnvironmentId) (GetInboundNetworkDependenciesEndpointsCompleteResult, error) { - return c.GetInboundNetworkDependenciesEndpointsCompleteMatchingPredicate(ctx, id, InboundEnvironmentEndpointOperationPredicate{}) -} - -// GetInboundNetworkDependenciesEndpointsCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c AppServiceEnvironmentsClient) GetInboundNetworkDependenciesEndpointsCompleteMatchingPredicate(ctx context.Context, id HostingEnvironmentId, predicate InboundEnvironmentEndpointOperationPredicate) (resp GetInboundNetworkDependenciesEndpointsCompleteResult, err error) { - items := make([]InboundEnvironmentEndpoint, 0) - - page, err := c.GetInboundNetworkDependenciesEndpoints(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := GetInboundNetworkDependenciesEndpointsCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_getmultirolepool.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_getmultirolepool.go new file mode 100644 index 00000000000..439573c1fe7 --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceenvironments/method_getmultirolepool.go @@ -0,0 +1,52 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "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 GetMultiRolePoolOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkerPoolResource +} + +// GetMultiRolePool ... +func (c AppServiceEnvironmentsClient) GetMultiRolePool(ctx context.Context, id HostingEnvironmentId) (result GetMultiRolePoolOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/multiRolePools/default", 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 +} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_getmultirolepool_autorest.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_getmultirolepool_autorest.go deleted file mode 100644 index 7769e7a4dd3..00000000000 --- a/resource-manager/web/2022-09-01/appserviceenvironments/method_getmultirolepool_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package appserviceenvironments - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetMultiRolePoolOperationResponse struct { - HttpResponse *http.Response - Model *WorkerPoolResource -} - -// GetMultiRolePool ... -func (c AppServiceEnvironmentsClient) GetMultiRolePool(ctx context.Context, id HostingEnvironmentId) (result GetMultiRolePoolOperationResponse, err error) { - req, err := c.preparerForGetMultiRolePool(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "GetMultiRolePool", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "GetMultiRolePool", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetMultiRolePool(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "GetMultiRolePool", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetMultiRolePool prepares the GetMultiRolePool request. -func (c AppServiceEnvironmentsClient) preparerForGetMultiRolePool(ctx context.Context, id HostingEnvironmentId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/multiRolePools/default", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetMultiRolePool handles the response to the GetMultiRolePool request. The method always -// closes the http.Response Body. -func (c AppServiceEnvironmentsClient) responderForGetMultiRolePool(resp *http.Response) (result GetMultiRolePoolOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_getoutboundnetworkdependenciesendpoints.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_getoutboundnetworkdependenciesendpoints.go new file mode 100644 index 00000000000..a61669e4717 --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceenvironments/method_getoutboundnetworkdependenciesendpoints.go @@ -0,0 +1,89 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "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 GetOutboundNetworkDependenciesEndpointsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]OutboundEnvironmentEndpoint +} + +type GetOutboundNetworkDependenciesEndpointsCompleteResult struct { + Items []OutboundEnvironmentEndpoint +} + +// GetOutboundNetworkDependenciesEndpoints ... +func (c AppServiceEnvironmentsClient) GetOutboundNetworkDependenciesEndpoints(ctx context.Context, id HostingEnvironmentId) (result GetOutboundNetworkDependenciesEndpointsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/outboundNetworkDependenciesEndpoints", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]OutboundEnvironmentEndpoint `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetOutboundNetworkDependenciesEndpointsComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) GetOutboundNetworkDependenciesEndpointsComplete(ctx context.Context, id HostingEnvironmentId) (GetOutboundNetworkDependenciesEndpointsCompleteResult, error) { + return c.GetOutboundNetworkDependenciesEndpointsCompleteMatchingPredicate(ctx, id, OutboundEnvironmentEndpointOperationPredicate{}) +} + +// GetOutboundNetworkDependenciesEndpointsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) GetOutboundNetworkDependenciesEndpointsCompleteMatchingPredicate(ctx context.Context, id HostingEnvironmentId, predicate OutboundEnvironmentEndpointOperationPredicate) (result GetOutboundNetworkDependenciesEndpointsCompleteResult, err error) { + items := make([]OutboundEnvironmentEndpoint, 0) + + resp, err := c.GetOutboundNetworkDependenciesEndpoints(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetOutboundNetworkDependenciesEndpointsCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_getoutboundnetworkdependenciesendpoints_autorest.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_getoutboundnetworkdependenciesendpoints_autorest.go deleted file mode 100644 index 68cf2c466be..00000000000 --- a/resource-manager/web/2022-09-01/appserviceenvironments/method_getoutboundnetworkdependenciesendpoints_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package appserviceenvironments - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOutboundNetworkDependenciesEndpointsOperationResponse struct { - HttpResponse *http.Response - Model *[]OutboundEnvironmentEndpoint - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (GetOutboundNetworkDependenciesEndpointsOperationResponse, error) -} - -type GetOutboundNetworkDependenciesEndpointsCompleteResult struct { - Items []OutboundEnvironmentEndpoint -} - -func (r GetOutboundNetworkDependenciesEndpointsOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r GetOutboundNetworkDependenciesEndpointsOperationResponse) LoadMore(ctx context.Context) (resp GetOutboundNetworkDependenciesEndpointsOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// GetOutboundNetworkDependenciesEndpoints ... -func (c AppServiceEnvironmentsClient) GetOutboundNetworkDependenciesEndpoints(ctx context.Context, id HostingEnvironmentId) (resp GetOutboundNetworkDependenciesEndpointsOperationResponse, err error) { - req, err := c.preparerForGetOutboundNetworkDependenciesEndpoints(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "GetOutboundNetworkDependenciesEndpoints", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "GetOutboundNetworkDependenciesEndpoints", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForGetOutboundNetworkDependenciesEndpoints(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "GetOutboundNetworkDependenciesEndpoints", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForGetOutboundNetworkDependenciesEndpoints prepares the GetOutboundNetworkDependenciesEndpoints request. -func (c AppServiceEnvironmentsClient) preparerForGetOutboundNetworkDependenciesEndpoints(ctx context.Context, id HostingEnvironmentId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/outboundNetworkDependenciesEndpoints", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForGetOutboundNetworkDependenciesEndpointsWithNextLink prepares the GetOutboundNetworkDependenciesEndpoints request with the given nextLink token. -func (c AppServiceEnvironmentsClient) preparerForGetOutboundNetworkDependenciesEndpointsWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetOutboundNetworkDependenciesEndpoints handles the response to the GetOutboundNetworkDependenciesEndpoints request. The method always -// closes the http.Response Body. -func (c AppServiceEnvironmentsClient) responderForGetOutboundNetworkDependenciesEndpoints(resp *http.Response) (result GetOutboundNetworkDependenciesEndpointsOperationResponse, err error) { - type page struct { - Values []OutboundEnvironmentEndpoint `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result GetOutboundNetworkDependenciesEndpointsOperationResponse, err error) { - req, err := c.preparerForGetOutboundNetworkDependenciesEndpointsWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "GetOutboundNetworkDependenciesEndpoints", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "GetOutboundNetworkDependenciesEndpoints", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetOutboundNetworkDependenciesEndpoints(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "GetOutboundNetworkDependenciesEndpoints", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// GetOutboundNetworkDependenciesEndpointsComplete retrieves all of the results into a single object -func (c AppServiceEnvironmentsClient) GetOutboundNetworkDependenciesEndpointsComplete(ctx context.Context, id HostingEnvironmentId) (GetOutboundNetworkDependenciesEndpointsCompleteResult, error) { - return c.GetOutboundNetworkDependenciesEndpointsCompleteMatchingPredicate(ctx, id, OutboundEnvironmentEndpointOperationPredicate{}) -} - -// GetOutboundNetworkDependenciesEndpointsCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c AppServiceEnvironmentsClient) GetOutboundNetworkDependenciesEndpointsCompleteMatchingPredicate(ctx context.Context, id HostingEnvironmentId, predicate OutboundEnvironmentEndpointOperationPredicate) (resp GetOutboundNetworkDependenciesEndpointsCompleteResult, err error) { - items := make([]OutboundEnvironmentEndpoint, 0) - - page, err := c.GetOutboundNetworkDependenciesEndpoints(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := GetOutboundNetworkDependenciesEndpointsCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_getprivateendpointconnection.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_getprivateendpointconnection.go new file mode 100644 index 00000000000..a00a3db13de --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceenvironments/method_getprivateendpointconnection.go @@ -0,0 +1,51 @@ +package appserviceenvironments + +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 GetPrivateEndpointConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RemotePrivateEndpointConnectionARMResource +} + +// GetPrivateEndpointConnection ... +func (c AppServiceEnvironmentsClient) GetPrivateEndpointConnection(ctx context.Context, id HostingEnvironmentPrivateEndpointConnectionId) (result GetPrivateEndpointConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_getprivateendpointconnection_autorest.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_getprivateendpointconnection_autorest.go deleted file mode 100644 index 05ea97e5f96..00000000000 --- a/resource-manager/web/2022-09-01/appserviceenvironments/method_getprivateendpointconnection_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package appserviceenvironments - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetPrivateEndpointConnectionOperationResponse struct { - HttpResponse *http.Response - Model *RemotePrivateEndpointConnectionARMResource -} - -// GetPrivateEndpointConnection ... -func (c AppServiceEnvironmentsClient) GetPrivateEndpointConnection(ctx context.Context, id HostingEnvironmentPrivateEndpointConnectionId) (result GetPrivateEndpointConnectionOperationResponse, err error) { - req, err := c.preparerForGetPrivateEndpointConnection(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "GetPrivateEndpointConnection", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "GetPrivateEndpointConnection", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetPrivateEndpointConnection(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "GetPrivateEndpointConnection", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetPrivateEndpointConnection prepares the GetPrivateEndpointConnection request. -func (c AppServiceEnvironmentsClient) preparerForGetPrivateEndpointConnection(ctx context.Context, id HostingEnvironmentPrivateEndpointConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetPrivateEndpointConnection handles the response to the GetPrivateEndpointConnection request. The method always -// closes the http.Response Body. -func (c AppServiceEnvironmentsClient) responderForGetPrivateEndpointConnection(resp *http.Response) (result GetPrivateEndpointConnectionOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_getprivateendpointconnectionlist.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_getprivateendpointconnectionlist.go new file mode 100644 index 00000000000..5a6eb2deb38 --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceenvironments/method_getprivateendpointconnectionlist.go @@ -0,0 +1,89 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "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 GetPrivateEndpointConnectionListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RemotePrivateEndpointConnectionARMResource +} + +type GetPrivateEndpointConnectionListCompleteResult struct { + Items []RemotePrivateEndpointConnectionARMResource +} + +// GetPrivateEndpointConnectionList ... +func (c AppServiceEnvironmentsClient) GetPrivateEndpointConnectionList(ctx context.Context, id HostingEnvironmentId) (result GetPrivateEndpointConnectionListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateEndpointConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]RemotePrivateEndpointConnectionARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetPrivateEndpointConnectionListComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) GetPrivateEndpointConnectionListComplete(ctx context.Context, id HostingEnvironmentId) (GetPrivateEndpointConnectionListCompleteResult, error) { + return c.GetPrivateEndpointConnectionListCompleteMatchingPredicate(ctx, id, RemotePrivateEndpointConnectionARMResourceOperationPredicate{}) +} + +// GetPrivateEndpointConnectionListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) GetPrivateEndpointConnectionListCompleteMatchingPredicate(ctx context.Context, id HostingEnvironmentId, predicate RemotePrivateEndpointConnectionARMResourceOperationPredicate) (result GetPrivateEndpointConnectionListCompleteResult, err error) { + items := make([]RemotePrivateEndpointConnectionARMResource, 0) + + resp, err := c.GetPrivateEndpointConnectionList(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetPrivateEndpointConnectionListCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_getprivateendpointconnectionlist_autorest.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_getprivateendpointconnectionlist_autorest.go deleted file mode 100644 index 2a05d2deb0a..00000000000 --- a/resource-manager/web/2022-09-01/appserviceenvironments/method_getprivateendpointconnectionlist_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package appserviceenvironments - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetPrivateEndpointConnectionListOperationResponse struct { - HttpResponse *http.Response - Model *[]RemotePrivateEndpointConnectionARMResource - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (GetPrivateEndpointConnectionListOperationResponse, error) -} - -type GetPrivateEndpointConnectionListCompleteResult struct { - Items []RemotePrivateEndpointConnectionARMResource -} - -func (r GetPrivateEndpointConnectionListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r GetPrivateEndpointConnectionListOperationResponse) LoadMore(ctx context.Context) (resp GetPrivateEndpointConnectionListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// GetPrivateEndpointConnectionList ... -func (c AppServiceEnvironmentsClient) GetPrivateEndpointConnectionList(ctx context.Context, id HostingEnvironmentId) (resp GetPrivateEndpointConnectionListOperationResponse, err error) { - req, err := c.preparerForGetPrivateEndpointConnectionList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "GetPrivateEndpointConnectionList", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "GetPrivateEndpointConnectionList", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForGetPrivateEndpointConnectionList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "GetPrivateEndpointConnectionList", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForGetPrivateEndpointConnectionList prepares the GetPrivateEndpointConnectionList request. -func (c AppServiceEnvironmentsClient) preparerForGetPrivateEndpointConnectionList(ctx context.Context, id HostingEnvironmentId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/privateEndpointConnections", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForGetPrivateEndpointConnectionListWithNextLink prepares the GetPrivateEndpointConnectionList request with the given nextLink token. -func (c AppServiceEnvironmentsClient) preparerForGetPrivateEndpointConnectionListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetPrivateEndpointConnectionList handles the response to the GetPrivateEndpointConnectionList request. The method always -// closes the http.Response Body. -func (c AppServiceEnvironmentsClient) responderForGetPrivateEndpointConnectionList(resp *http.Response) (result GetPrivateEndpointConnectionListOperationResponse, err error) { - type page struct { - Values []RemotePrivateEndpointConnectionARMResource `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result GetPrivateEndpointConnectionListOperationResponse, err error) { - req, err := c.preparerForGetPrivateEndpointConnectionListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "GetPrivateEndpointConnectionList", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "GetPrivateEndpointConnectionList", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetPrivateEndpointConnectionList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "GetPrivateEndpointConnectionList", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// GetPrivateEndpointConnectionListComplete retrieves all of the results into a single object -func (c AppServiceEnvironmentsClient) GetPrivateEndpointConnectionListComplete(ctx context.Context, id HostingEnvironmentId) (GetPrivateEndpointConnectionListCompleteResult, error) { - return c.GetPrivateEndpointConnectionListCompleteMatchingPredicate(ctx, id, RemotePrivateEndpointConnectionARMResourceOperationPredicate{}) -} - -// GetPrivateEndpointConnectionListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c AppServiceEnvironmentsClient) GetPrivateEndpointConnectionListCompleteMatchingPredicate(ctx context.Context, id HostingEnvironmentId, predicate RemotePrivateEndpointConnectionARMResourceOperationPredicate) (resp GetPrivateEndpointConnectionListCompleteResult, err error) { - items := make([]RemotePrivateEndpointConnectionARMResource, 0) - - page, err := c.GetPrivateEndpointConnectionList(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := GetPrivateEndpointConnectionListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_getprivatelinkresources.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_getprivatelinkresources.go new file mode 100644 index 00000000000..65c3c6b8264 --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceenvironments/method_getprivatelinkresources.go @@ -0,0 +1,52 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "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 GetPrivateLinkResourcesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateLinkResourcesWrapper +} + +// GetPrivateLinkResources ... +func (c AppServiceEnvironmentsClient) GetPrivateLinkResources(ctx context.Context, id HostingEnvironmentId) (result GetPrivateLinkResourcesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateLinkResources", 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 +} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_getprivatelinkresources_autorest.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_getprivatelinkresources_autorest.go deleted file mode 100644 index 60a80c11a10..00000000000 --- a/resource-manager/web/2022-09-01/appserviceenvironments/method_getprivatelinkresources_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package appserviceenvironments - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetPrivateLinkResourcesOperationResponse struct { - HttpResponse *http.Response - Model *PrivateLinkResourcesWrapper -} - -// GetPrivateLinkResources ... -func (c AppServiceEnvironmentsClient) GetPrivateLinkResources(ctx context.Context, id HostingEnvironmentId) (result GetPrivateLinkResourcesOperationResponse, err error) { - req, err := c.preparerForGetPrivateLinkResources(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "GetPrivateLinkResources", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "GetPrivateLinkResources", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetPrivateLinkResources(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "GetPrivateLinkResources", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetPrivateLinkResources prepares the GetPrivateLinkResources request. -func (c AppServiceEnvironmentsClient) preparerForGetPrivateLinkResources(ctx context.Context, id HostingEnvironmentId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/privateLinkResources", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetPrivateLinkResources handles the response to the GetPrivateLinkResources request. The method always -// closes the http.Response Body. -func (c AppServiceEnvironmentsClient) responderForGetPrivateLinkResources(resp *http.Response) (result GetPrivateLinkResourcesOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_getvipinfo.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_getvipinfo.go new file mode 100644 index 00000000000..651fe6f4533 --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceenvironments/method_getvipinfo.go @@ -0,0 +1,52 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "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 GetVipInfoOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AddressResponse +} + +// GetVipInfo ... +func (c AppServiceEnvironmentsClient) GetVipInfo(ctx context.Context, id HostingEnvironmentId) (result GetVipInfoOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/capacities/virtualip", 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 +} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_getvipinfo_autorest.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_getvipinfo_autorest.go deleted file mode 100644 index f54c4b49b15..00000000000 --- a/resource-manager/web/2022-09-01/appserviceenvironments/method_getvipinfo_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package appserviceenvironments - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetVipInfoOperationResponse struct { - HttpResponse *http.Response - Model *AddressResponse -} - -// GetVipInfo ... -func (c AppServiceEnvironmentsClient) GetVipInfo(ctx context.Context, id HostingEnvironmentId) (result GetVipInfoOperationResponse, err error) { - req, err := c.preparerForGetVipInfo(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "GetVipInfo", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "GetVipInfo", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetVipInfo(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "GetVipInfo", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetVipInfo prepares the GetVipInfo request. -func (c AppServiceEnvironmentsClient) preparerForGetVipInfo(ctx context.Context, id HostingEnvironmentId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/capacities/virtualip", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetVipInfo handles the response to the GetVipInfo request. The method always -// closes the http.Response Body. -func (c AppServiceEnvironmentsClient) responderForGetVipInfo(resp *http.Response) (result GetVipInfoOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_getworkerpool.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_getworkerpool.go new file mode 100644 index 00000000000..b44f4d218dc --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceenvironments/method_getworkerpool.go @@ -0,0 +1,51 @@ +package appserviceenvironments + +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 GetWorkerPoolOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkerPoolResource +} + +// GetWorkerPool ... +func (c AppServiceEnvironmentsClient) GetWorkerPool(ctx context.Context, id WorkerPoolId) (result GetWorkerPoolOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_getworkerpool_autorest.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_getworkerpool_autorest.go deleted file mode 100644 index 29ce9e0c230..00000000000 --- a/resource-manager/web/2022-09-01/appserviceenvironments/method_getworkerpool_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package appserviceenvironments - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetWorkerPoolOperationResponse struct { - HttpResponse *http.Response - Model *WorkerPoolResource -} - -// GetWorkerPool ... -func (c AppServiceEnvironmentsClient) GetWorkerPool(ctx context.Context, id WorkerPoolId) (result GetWorkerPoolOperationResponse, err error) { - req, err := c.preparerForGetWorkerPool(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "GetWorkerPool", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "GetWorkerPool", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetWorkerPool(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "GetWorkerPool", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetWorkerPool prepares the GetWorkerPool request. -func (c AppServiceEnvironmentsClient) preparerForGetWorkerPool(ctx context.Context, id WorkerPoolId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetWorkerPool handles the response to the GetWorkerPool request. The method always -// closes the http.Response Body. -func (c AppServiceEnvironmentsClient) responderForGetWorkerPool(resp *http.Response) (result GetWorkerPoolOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_list.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_list.go new file mode 100644 index 00000000000..a45191ba905 --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceenvironments/method_list.go @@ -0,0 +1,90 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AppServiceEnvironmentResource +} + +type ListCompleteResult struct { + Items []AppServiceEnvironmentResource +} + +// List ... +func (c AppServiceEnvironmentsClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/hostingEnvironments", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AppServiceEnvironmentResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, AppServiceEnvironmentResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate AppServiceEnvironmentResourceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]AppServiceEnvironmentResource, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_list_autorest.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_list_autorest.go deleted file mode 100644 index f04dd883449..00000000000 --- a/resource-manager/web/2022-09-01/appserviceenvironments/method_list_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package appserviceenvironments - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListOperationResponse struct { - HttpResponse *http.Response - Model *[]AppServiceEnvironmentResource - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []AppServiceEnvironmentResource -} - -func (r ListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// List ... -func (c AppServiceEnvironmentsClient) List(ctx context.Context, id commonids.SubscriptionId) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c AppServiceEnvironmentsClient) preparerForList(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Web/hostingEnvironments", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c AppServiceEnvironmentsClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForList handles the response to the List request. The method always -// closes the http.Response Body. -func (c AppServiceEnvironmentsClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []AppServiceEnvironmentResource `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { - req, err := c.preparerForListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c AppServiceEnvironmentsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, AppServiceEnvironmentResourceOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c AppServiceEnvironmentsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate AppServiceEnvironmentResourceOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]AppServiceEnvironmentResource, 0) - - page, err := c.List(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_listappserviceplans.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_listappserviceplans.go new file mode 100644 index 00000000000..697770c0bba --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceenvironments/method_listappserviceplans.go @@ -0,0 +1,89 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "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 ListAppServicePlansOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AppServicePlan +} + +type ListAppServicePlansCompleteResult struct { + Items []AppServicePlan +} + +// ListAppServicePlans ... +func (c AppServiceEnvironmentsClient) ListAppServicePlans(ctx context.Context, id HostingEnvironmentId) (result ListAppServicePlansOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/serverFarms", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AppServicePlan `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAppServicePlansComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListAppServicePlansComplete(ctx context.Context, id HostingEnvironmentId) (ListAppServicePlansCompleteResult, error) { + return c.ListAppServicePlansCompleteMatchingPredicate(ctx, id, AppServicePlanOperationPredicate{}) +} + +// ListAppServicePlansCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListAppServicePlansCompleteMatchingPredicate(ctx context.Context, id HostingEnvironmentId, predicate AppServicePlanOperationPredicate) (result ListAppServicePlansCompleteResult, err error) { + items := make([]AppServicePlan, 0) + + resp, err := c.ListAppServicePlans(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListAppServicePlansCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_listappserviceplans_autorest.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_listappserviceplans_autorest.go deleted file mode 100644 index 0d92afe8489..00000000000 --- a/resource-manager/web/2022-09-01/appserviceenvironments/method_listappserviceplans_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package appserviceenvironments - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListAppServicePlansOperationResponse struct { - HttpResponse *http.Response - Model *[]AppServicePlan - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListAppServicePlansOperationResponse, error) -} - -type ListAppServicePlansCompleteResult struct { - Items []AppServicePlan -} - -func (r ListAppServicePlansOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListAppServicePlansOperationResponse) LoadMore(ctx context.Context) (resp ListAppServicePlansOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListAppServicePlans ... -func (c AppServiceEnvironmentsClient) ListAppServicePlans(ctx context.Context, id HostingEnvironmentId) (resp ListAppServicePlansOperationResponse, err error) { - req, err := c.preparerForListAppServicePlans(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListAppServicePlans", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListAppServicePlans", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListAppServicePlans(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListAppServicePlans", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListAppServicePlans prepares the ListAppServicePlans request. -func (c AppServiceEnvironmentsClient) preparerForListAppServicePlans(ctx context.Context, id HostingEnvironmentId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/serverFarms", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListAppServicePlansWithNextLink prepares the ListAppServicePlans request with the given nextLink token. -func (c AppServiceEnvironmentsClient) preparerForListAppServicePlansWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListAppServicePlans handles the response to the ListAppServicePlans request. The method always -// closes the http.Response Body. -func (c AppServiceEnvironmentsClient) responderForListAppServicePlans(resp *http.Response) (result ListAppServicePlansOperationResponse, err error) { - type page struct { - Values []AppServicePlan `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListAppServicePlansOperationResponse, err error) { - req, err := c.preparerForListAppServicePlansWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListAppServicePlans", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListAppServicePlans", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListAppServicePlans(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListAppServicePlans", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListAppServicePlansComplete retrieves all of the results into a single object -func (c AppServiceEnvironmentsClient) ListAppServicePlansComplete(ctx context.Context, id HostingEnvironmentId) (ListAppServicePlansCompleteResult, error) { - return c.ListAppServicePlansCompleteMatchingPredicate(ctx, id, AppServicePlanOperationPredicate{}) -} - -// ListAppServicePlansCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c AppServiceEnvironmentsClient) ListAppServicePlansCompleteMatchingPredicate(ctx context.Context, id HostingEnvironmentId, predicate AppServicePlanOperationPredicate) (resp ListAppServicePlansCompleteResult, err error) { - items := make([]AppServicePlan, 0) - - page, err := c.ListAppServicePlans(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListAppServicePlansCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_listbyresourcegroup.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_listbyresourcegroup.go new file mode 100644 index 00000000000..1f51baac9e0 --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceenvironments/method_listbyresourcegroup.go @@ -0,0 +1,90 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AppServiceEnvironmentResource +} + +type ListByResourceGroupCompleteResult struct { + Items []AppServiceEnvironmentResource +} + +// ListByResourceGroup ... +func (c AppServiceEnvironmentsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/hostingEnvironments", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AppServiceEnvironmentResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, AppServiceEnvironmentResourceOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate AppServiceEnvironmentResourceOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]AppServiceEnvironmentResource, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_listbyresourcegroup_autorest.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_listbyresourcegroup_autorest.go deleted file mode 100644 index a7bf05ab52f..00000000000 --- a/resource-manager/web/2022-09-01/appserviceenvironments/method_listbyresourcegroup_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package appserviceenvironments - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByResourceGroupOperationResponse struct { - HttpResponse *http.Response - Model *[]AppServiceEnvironmentResource - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByResourceGroupOperationResponse, error) -} - -type ListByResourceGroupCompleteResult struct { - Items []AppServiceEnvironmentResource -} - -func (r ListByResourceGroupOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByResourceGroupOperationResponse) LoadMore(ctx context.Context) (resp ListByResourceGroupOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByResourceGroup ... -func (c AppServiceEnvironmentsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (resp ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroup(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListByResourceGroup", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByResourceGroup(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListByResourceGroup", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByResourceGroup prepares the ListByResourceGroup request. -func (c AppServiceEnvironmentsClient) preparerForListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Web/hostingEnvironments", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByResourceGroupWithNextLink prepares the ListByResourceGroup request with the given nextLink token. -func (c AppServiceEnvironmentsClient) preparerForListByResourceGroupWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByResourceGroup handles the response to the ListByResourceGroup request. The method always -// closes the http.Response Body. -func (c AppServiceEnvironmentsClient) responderForListByResourceGroup(resp *http.Response) (result ListByResourceGroupOperationResponse, err error) { - type page struct { - Values []AppServiceEnvironmentResource `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroupWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListByResourceGroup", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByResourceGroup(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListByResourceGroup", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByResourceGroupComplete retrieves all of the results into a single object -func (c AppServiceEnvironmentsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { - return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, AppServiceEnvironmentResourceOperationPredicate{}) -} - -// ListByResourceGroupCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c AppServiceEnvironmentsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate AppServiceEnvironmentResourceOperationPredicate) (resp ListByResourceGroupCompleteResult, err error) { - items := make([]AppServiceEnvironmentResource, 0) - - page, err := c.ListByResourceGroup(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByResourceGroupCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_listcapacities.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_listcapacities.go new file mode 100644 index 00000000000..dc1aab75146 --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceenvironments/method_listcapacities.go @@ -0,0 +1,89 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "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 ListCapacitiesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StampCapacity +} + +type ListCapacitiesCompleteResult struct { + Items []StampCapacity +} + +// ListCapacities ... +func (c AppServiceEnvironmentsClient) ListCapacities(ctx context.Context, id HostingEnvironmentId) (result ListCapacitiesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/capacities/compute", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]StampCapacity `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListCapacitiesComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListCapacitiesComplete(ctx context.Context, id HostingEnvironmentId) (ListCapacitiesCompleteResult, error) { + return c.ListCapacitiesCompleteMatchingPredicate(ctx, id, StampCapacityOperationPredicate{}) +} + +// ListCapacitiesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListCapacitiesCompleteMatchingPredicate(ctx context.Context, id HostingEnvironmentId, predicate StampCapacityOperationPredicate) (result ListCapacitiesCompleteResult, err error) { + items := make([]StampCapacity, 0) + + resp, err := c.ListCapacities(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCapacitiesCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_listcapacities_autorest.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_listcapacities_autorest.go deleted file mode 100644 index 1e5afe61a2e..00000000000 --- a/resource-manager/web/2022-09-01/appserviceenvironments/method_listcapacities_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package appserviceenvironments - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListCapacitiesOperationResponse struct { - HttpResponse *http.Response - Model *[]StampCapacity - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListCapacitiesOperationResponse, error) -} - -type ListCapacitiesCompleteResult struct { - Items []StampCapacity -} - -func (r ListCapacitiesOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListCapacitiesOperationResponse) LoadMore(ctx context.Context) (resp ListCapacitiesOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListCapacities ... -func (c AppServiceEnvironmentsClient) ListCapacities(ctx context.Context, id HostingEnvironmentId) (resp ListCapacitiesOperationResponse, err error) { - req, err := c.preparerForListCapacities(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListCapacities", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListCapacities", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListCapacities(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListCapacities", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListCapacities prepares the ListCapacities request. -func (c AppServiceEnvironmentsClient) preparerForListCapacities(ctx context.Context, id HostingEnvironmentId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/capacities/compute", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListCapacitiesWithNextLink prepares the ListCapacities request with the given nextLink token. -func (c AppServiceEnvironmentsClient) preparerForListCapacitiesWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListCapacities handles the response to the ListCapacities request. The method always -// closes the http.Response Body. -func (c AppServiceEnvironmentsClient) responderForListCapacities(resp *http.Response) (result ListCapacitiesOperationResponse, err error) { - type page struct { - Values []StampCapacity `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListCapacitiesOperationResponse, err error) { - req, err := c.preparerForListCapacitiesWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListCapacities", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListCapacities", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListCapacities(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListCapacities", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListCapacitiesComplete retrieves all of the results into a single object -func (c AppServiceEnvironmentsClient) ListCapacitiesComplete(ctx context.Context, id HostingEnvironmentId) (ListCapacitiesCompleteResult, error) { - return c.ListCapacitiesCompleteMatchingPredicate(ctx, id, StampCapacityOperationPredicate{}) -} - -// ListCapacitiesCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c AppServiceEnvironmentsClient) ListCapacitiesCompleteMatchingPredicate(ctx context.Context, id HostingEnvironmentId, predicate StampCapacityOperationPredicate) (resp ListCapacitiesCompleteResult, err error) { - items := make([]StampCapacity, 0) - - page, err := c.ListCapacities(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCapacitiesCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_listdiagnostics.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_listdiagnostics.go new file mode 100644 index 00000000000..9dab6bc2dd6 --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceenvironments/method_listdiagnostics.go @@ -0,0 +1,52 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "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 ListDiagnosticsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]HostingEnvironmentDiagnostics +} + +// ListDiagnostics ... +func (c AppServiceEnvironmentsClient) ListDiagnostics(ctx context.Context, id HostingEnvironmentId) (result ListDiagnosticsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/diagnostics", 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 +} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_listdiagnostics_autorest.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_listdiagnostics_autorest.go deleted file mode 100644 index 833223ab10b..00000000000 --- a/resource-manager/web/2022-09-01/appserviceenvironments/method_listdiagnostics_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package appserviceenvironments - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListDiagnosticsOperationResponse struct { - HttpResponse *http.Response - Model *[]HostingEnvironmentDiagnostics -} - -// ListDiagnostics ... -func (c AppServiceEnvironmentsClient) ListDiagnostics(ctx context.Context, id HostingEnvironmentId) (result ListDiagnosticsOperationResponse, err error) { - req, err := c.preparerForListDiagnostics(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListDiagnostics", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListDiagnostics", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListDiagnostics(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListDiagnostics", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListDiagnostics prepares the ListDiagnostics request. -func (c AppServiceEnvironmentsClient) preparerForListDiagnostics(ctx context.Context, id HostingEnvironmentId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/diagnostics", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListDiagnostics handles the response to the ListDiagnostics request. The method always -// closes the http.Response Body. -func (c AppServiceEnvironmentsClient) responderForListDiagnostics(resp *http.Response) (result ListDiagnosticsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_listmultirolemetricdefinitions.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_listmultirolemetricdefinitions.go new file mode 100644 index 00000000000..28057056229 --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceenvironments/method_listmultirolemetricdefinitions.go @@ -0,0 +1,89 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "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 ListMultiRoleMetricDefinitionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ResourceMetricDefinition +} + +type ListMultiRoleMetricDefinitionsCompleteResult struct { + Items []ResourceMetricDefinition +} + +// ListMultiRoleMetricDefinitions ... +func (c AppServiceEnvironmentsClient) ListMultiRoleMetricDefinitions(ctx context.Context, id HostingEnvironmentId) (result ListMultiRoleMetricDefinitionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/multiRolePools/default/metricdefinitions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ResourceMetricDefinition `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListMultiRoleMetricDefinitionsComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListMultiRoleMetricDefinitionsComplete(ctx context.Context, id HostingEnvironmentId) (ListMultiRoleMetricDefinitionsCompleteResult, error) { + return c.ListMultiRoleMetricDefinitionsCompleteMatchingPredicate(ctx, id, ResourceMetricDefinitionOperationPredicate{}) +} + +// ListMultiRoleMetricDefinitionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListMultiRoleMetricDefinitionsCompleteMatchingPredicate(ctx context.Context, id HostingEnvironmentId, predicate ResourceMetricDefinitionOperationPredicate) (result ListMultiRoleMetricDefinitionsCompleteResult, err error) { + items := make([]ResourceMetricDefinition, 0) + + resp, err := c.ListMultiRoleMetricDefinitions(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListMultiRoleMetricDefinitionsCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_listmultirolemetricdefinitions_autorest.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_listmultirolemetricdefinitions_autorest.go deleted file mode 100644 index 6fecbb2ff9d..00000000000 --- a/resource-manager/web/2022-09-01/appserviceenvironments/method_listmultirolemetricdefinitions_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package appserviceenvironments - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListMultiRoleMetricDefinitionsOperationResponse struct { - HttpResponse *http.Response - Model *[]ResourceMetricDefinition - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListMultiRoleMetricDefinitionsOperationResponse, error) -} - -type ListMultiRoleMetricDefinitionsCompleteResult struct { - Items []ResourceMetricDefinition -} - -func (r ListMultiRoleMetricDefinitionsOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListMultiRoleMetricDefinitionsOperationResponse) LoadMore(ctx context.Context) (resp ListMultiRoleMetricDefinitionsOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListMultiRoleMetricDefinitions ... -func (c AppServiceEnvironmentsClient) ListMultiRoleMetricDefinitions(ctx context.Context, id HostingEnvironmentId) (resp ListMultiRoleMetricDefinitionsOperationResponse, err error) { - req, err := c.preparerForListMultiRoleMetricDefinitions(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListMultiRoleMetricDefinitions", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListMultiRoleMetricDefinitions", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListMultiRoleMetricDefinitions(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListMultiRoleMetricDefinitions", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListMultiRoleMetricDefinitions prepares the ListMultiRoleMetricDefinitions request. -func (c AppServiceEnvironmentsClient) preparerForListMultiRoleMetricDefinitions(ctx context.Context, id HostingEnvironmentId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/multiRolePools/default/metricdefinitions", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListMultiRoleMetricDefinitionsWithNextLink prepares the ListMultiRoleMetricDefinitions request with the given nextLink token. -func (c AppServiceEnvironmentsClient) preparerForListMultiRoleMetricDefinitionsWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListMultiRoleMetricDefinitions handles the response to the ListMultiRoleMetricDefinitions request. The method always -// closes the http.Response Body. -func (c AppServiceEnvironmentsClient) responderForListMultiRoleMetricDefinitions(resp *http.Response) (result ListMultiRoleMetricDefinitionsOperationResponse, err error) { - type page struct { - Values []ResourceMetricDefinition `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListMultiRoleMetricDefinitionsOperationResponse, err error) { - req, err := c.preparerForListMultiRoleMetricDefinitionsWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListMultiRoleMetricDefinitions", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListMultiRoleMetricDefinitions", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListMultiRoleMetricDefinitions(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListMultiRoleMetricDefinitions", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListMultiRoleMetricDefinitionsComplete retrieves all of the results into a single object -func (c AppServiceEnvironmentsClient) ListMultiRoleMetricDefinitionsComplete(ctx context.Context, id HostingEnvironmentId) (ListMultiRoleMetricDefinitionsCompleteResult, error) { - return c.ListMultiRoleMetricDefinitionsCompleteMatchingPredicate(ctx, id, ResourceMetricDefinitionOperationPredicate{}) -} - -// ListMultiRoleMetricDefinitionsCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c AppServiceEnvironmentsClient) ListMultiRoleMetricDefinitionsCompleteMatchingPredicate(ctx context.Context, id HostingEnvironmentId, predicate ResourceMetricDefinitionOperationPredicate) (resp ListMultiRoleMetricDefinitionsCompleteResult, err error) { - items := make([]ResourceMetricDefinition, 0) - - page, err := c.ListMultiRoleMetricDefinitions(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListMultiRoleMetricDefinitionsCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_listmultirolepoolinstancemetricdefinitions.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_listmultirolepoolinstancemetricdefinitions.go new file mode 100644 index 00000000000..a3487d8f12d --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceenvironments/method_listmultirolepoolinstancemetricdefinitions.go @@ -0,0 +1,89 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "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 ListMultiRolePoolInstanceMetricDefinitionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ResourceMetricDefinition +} + +type ListMultiRolePoolInstanceMetricDefinitionsCompleteResult struct { + Items []ResourceMetricDefinition +} + +// ListMultiRolePoolInstanceMetricDefinitions ... +func (c AppServiceEnvironmentsClient) ListMultiRolePoolInstanceMetricDefinitions(ctx context.Context, id DefaultInstanceId) (result ListMultiRolePoolInstanceMetricDefinitionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/metricdefinitions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ResourceMetricDefinition `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListMultiRolePoolInstanceMetricDefinitionsComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListMultiRolePoolInstanceMetricDefinitionsComplete(ctx context.Context, id DefaultInstanceId) (ListMultiRolePoolInstanceMetricDefinitionsCompleteResult, error) { + return c.ListMultiRolePoolInstanceMetricDefinitionsCompleteMatchingPredicate(ctx, id, ResourceMetricDefinitionOperationPredicate{}) +} + +// ListMultiRolePoolInstanceMetricDefinitionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListMultiRolePoolInstanceMetricDefinitionsCompleteMatchingPredicate(ctx context.Context, id DefaultInstanceId, predicate ResourceMetricDefinitionOperationPredicate) (result ListMultiRolePoolInstanceMetricDefinitionsCompleteResult, err error) { + items := make([]ResourceMetricDefinition, 0) + + resp, err := c.ListMultiRolePoolInstanceMetricDefinitions(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListMultiRolePoolInstanceMetricDefinitionsCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_listmultirolepoolinstancemetricdefinitions_autorest.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_listmultirolepoolinstancemetricdefinitions_autorest.go deleted file mode 100644 index 98f4d4f262d..00000000000 --- a/resource-manager/web/2022-09-01/appserviceenvironments/method_listmultirolepoolinstancemetricdefinitions_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package appserviceenvironments - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListMultiRolePoolInstanceMetricDefinitionsOperationResponse struct { - HttpResponse *http.Response - Model *[]ResourceMetricDefinition - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListMultiRolePoolInstanceMetricDefinitionsOperationResponse, error) -} - -type ListMultiRolePoolInstanceMetricDefinitionsCompleteResult struct { - Items []ResourceMetricDefinition -} - -func (r ListMultiRolePoolInstanceMetricDefinitionsOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListMultiRolePoolInstanceMetricDefinitionsOperationResponse) LoadMore(ctx context.Context) (resp ListMultiRolePoolInstanceMetricDefinitionsOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListMultiRolePoolInstanceMetricDefinitions ... -func (c AppServiceEnvironmentsClient) ListMultiRolePoolInstanceMetricDefinitions(ctx context.Context, id DefaultInstanceId) (resp ListMultiRolePoolInstanceMetricDefinitionsOperationResponse, err error) { - req, err := c.preparerForListMultiRolePoolInstanceMetricDefinitions(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListMultiRolePoolInstanceMetricDefinitions", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListMultiRolePoolInstanceMetricDefinitions", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListMultiRolePoolInstanceMetricDefinitions(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListMultiRolePoolInstanceMetricDefinitions", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListMultiRolePoolInstanceMetricDefinitions prepares the ListMultiRolePoolInstanceMetricDefinitions request. -func (c AppServiceEnvironmentsClient) preparerForListMultiRolePoolInstanceMetricDefinitions(ctx context.Context, id DefaultInstanceId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/metricdefinitions", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListMultiRolePoolInstanceMetricDefinitionsWithNextLink prepares the ListMultiRolePoolInstanceMetricDefinitions request with the given nextLink token. -func (c AppServiceEnvironmentsClient) preparerForListMultiRolePoolInstanceMetricDefinitionsWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListMultiRolePoolInstanceMetricDefinitions handles the response to the ListMultiRolePoolInstanceMetricDefinitions request. The method always -// closes the http.Response Body. -func (c AppServiceEnvironmentsClient) responderForListMultiRolePoolInstanceMetricDefinitions(resp *http.Response) (result ListMultiRolePoolInstanceMetricDefinitionsOperationResponse, err error) { - type page struct { - Values []ResourceMetricDefinition `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListMultiRolePoolInstanceMetricDefinitionsOperationResponse, err error) { - req, err := c.preparerForListMultiRolePoolInstanceMetricDefinitionsWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListMultiRolePoolInstanceMetricDefinitions", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListMultiRolePoolInstanceMetricDefinitions", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListMultiRolePoolInstanceMetricDefinitions(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListMultiRolePoolInstanceMetricDefinitions", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListMultiRolePoolInstanceMetricDefinitionsComplete retrieves all of the results into a single object -func (c AppServiceEnvironmentsClient) ListMultiRolePoolInstanceMetricDefinitionsComplete(ctx context.Context, id DefaultInstanceId) (ListMultiRolePoolInstanceMetricDefinitionsCompleteResult, error) { - return c.ListMultiRolePoolInstanceMetricDefinitionsCompleteMatchingPredicate(ctx, id, ResourceMetricDefinitionOperationPredicate{}) -} - -// ListMultiRolePoolInstanceMetricDefinitionsCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c AppServiceEnvironmentsClient) ListMultiRolePoolInstanceMetricDefinitionsCompleteMatchingPredicate(ctx context.Context, id DefaultInstanceId, predicate ResourceMetricDefinitionOperationPredicate) (resp ListMultiRolePoolInstanceMetricDefinitionsCompleteResult, err error) { - items := make([]ResourceMetricDefinition, 0) - - page, err := c.ListMultiRolePoolInstanceMetricDefinitions(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListMultiRolePoolInstanceMetricDefinitionsCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_listmultirolepools.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_listmultirolepools.go new file mode 100644 index 00000000000..29a745cb551 --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceenvironments/method_listmultirolepools.go @@ -0,0 +1,89 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "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 ListMultiRolePoolsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WorkerPoolResource +} + +type ListMultiRolePoolsCompleteResult struct { + Items []WorkerPoolResource +} + +// ListMultiRolePools ... +func (c AppServiceEnvironmentsClient) ListMultiRolePools(ctx context.Context, id HostingEnvironmentId) (result ListMultiRolePoolsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/multiRolePools", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]WorkerPoolResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListMultiRolePoolsComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListMultiRolePoolsComplete(ctx context.Context, id HostingEnvironmentId) (ListMultiRolePoolsCompleteResult, error) { + return c.ListMultiRolePoolsCompleteMatchingPredicate(ctx, id, WorkerPoolResourceOperationPredicate{}) +} + +// ListMultiRolePoolsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListMultiRolePoolsCompleteMatchingPredicate(ctx context.Context, id HostingEnvironmentId, predicate WorkerPoolResourceOperationPredicate) (result ListMultiRolePoolsCompleteResult, err error) { + items := make([]WorkerPoolResource, 0) + + resp, err := c.ListMultiRolePools(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListMultiRolePoolsCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_listmultirolepools_autorest.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_listmultirolepools_autorest.go deleted file mode 100644 index 50422f440f4..00000000000 --- a/resource-manager/web/2022-09-01/appserviceenvironments/method_listmultirolepools_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package appserviceenvironments - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListMultiRolePoolsOperationResponse struct { - HttpResponse *http.Response - Model *[]WorkerPoolResource - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListMultiRolePoolsOperationResponse, error) -} - -type ListMultiRolePoolsCompleteResult struct { - Items []WorkerPoolResource -} - -func (r ListMultiRolePoolsOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListMultiRolePoolsOperationResponse) LoadMore(ctx context.Context) (resp ListMultiRolePoolsOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListMultiRolePools ... -func (c AppServiceEnvironmentsClient) ListMultiRolePools(ctx context.Context, id HostingEnvironmentId) (resp ListMultiRolePoolsOperationResponse, err error) { - req, err := c.preparerForListMultiRolePools(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListMultiRolePools", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListMultiRolePools", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListMultiRolePools(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListMultiRolePools", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListMultiRolePools prepares the ListMultiRolePools request. -func (c AppServiceEnvironmentsClient) preparerForListMultiRolePools(ctx context.Context, id HostingEnvironmentId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/multiRolePools", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListMultiRolePoolsWithNextLink prepares the ListMultiRolePools request with the given nextLink token. -func (c AppServiceEnvironmentsClient) preparerForListMultiRolePoolsWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListMultiRolePools handles the response to the ListMultiRolePools request. The method always -// closes the http.Response Body. -func (c AppServiceEnvironmentsClient) responderForListMultiRolePools(resp *http.Response) (result ListMultiRolePoolsOperationResponse, err error) { - type page struct { - Values []WorkerPoolResource `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListMultiRolePoolsOperationResponse, err error) { - req, err := c.preparerForListMultiRolePoolsWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListMultiRolePools", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListMultiRolePools", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListMultiRolePools(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListMultiRolePools", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListMultiRolePoolsComplete retrieves all of the results into a single object -func (c AppServiceEnvironmentsClient) ListMultiRolePoolsComplete(ctx context.Context, id HostingEnvironmentId) (ListMultiRolePoolsCompleteResult, error) { - return c.ListMultiRolePoolsCompleteMatchingPredicate(ctx, id, WorkerPoolResourceOperationPredicate{}) -} - -// ListMultiRolePoolsCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c AppServiceEnvironmentsClient) ListMultiRolePoolsCompleteMatchingPredicate(ctx context.Context, id HostingEnvironmentId, predicate WorkerPoolResourceOperationPredicate) (resp ListMultiRolePoolsCompleteResult, err error) { - items := make([]WorkerPoolResource, 0) - - page, err := c.ListMultiRolePools(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListMultiRolePoolsCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_listmultirolepoolskus.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_listmultirolepoolskus.go new file mode 100644 index 00000000000..ad7f0fb27ad --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceenvironments/method_listmultirolepoolskus.go @@ -0,0 +1,89 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "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 ListMultiRolePoolSkusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SkuInfo +} + +type ListMultiRolePoolSkusCompleteResult struct { + Items []SkuInfo +} + +// ListMultiRolePoolSkus ... +func (c AppServiceEnvironmentsClient) ListMultiRolePoolSkus(ctx context.Context, id HostingEnvironmentId) (result ListMultiRolePoolSkusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/multiRolePools/default/skus", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]SkuInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListMultiRolePoolSkusComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListMultiRolePoolSkusComplete(ctx context.Context, id HostingEnvironmentId) (ListMultiRolePoolSkusCompleteResult, error) { + return c.ListMultiRolePoolSkusCompleteMatchingPredicate(ctx, id, SkuInfoOperationPredicate{}) +} + +// ListMultiRolePoolSkusCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListMultiRolePoolSkusCompleteMatchingPredicate(ctx context.Context, id HostingEnvironmentId, predicate SkuInfoOperationPredicate) (result ListMultiRolePoolSkusCompleteResult, err error) { + items := make([]SkuInfo, 0) + + resp, err := c.ListMultiRolePoolSkus(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListMultiRolePoolSkusCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_listmultirolepoolskus_autorest.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_listmultirolepoolskus_autorest.go deleted file mode 100644 index 7d13aa0aab9..00000000000 --- a/resource-manager/web/2022-09-01/appserviceenvironments/method_listmultirolepoolskus_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package appserviceenvironments - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListMultiRolePoolSkusOperationResponse struct { - HttpResponse *http.Response - Model *[]SkuInfo - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListMultiRolePoolSkusOperationResponse, error) -} - -type ListMultiRolePoolSkusCompleteResult struct { - Items []SkuInfo -} - -func (r ListMultiRolePoolSkusOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListMultiRolePoolSkusOperationResponse) LoadMore(ctx context.Context) (resp ListMultiRolePoolSkusOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListMultiRolePoolSkus ... -func (c AppServiceEnvironmentsClient) ListMultiRolePoolSkus(ctx context.Context, id HostingEnvironmentId) (resp ListMultiRolePoolSkusOperationResponse, err error) { - req, err := c.preparerForListMultiRolePoolSkus(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListMultiRolePoolSkus", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListMultiRolePoolSkus", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListMultiRolePoolSkus(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListMultiRolePoolSkus", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListMultiRolePoolSkus prepares the ListMultiRolePoolSkus request. -func (c AppServiceEnvironmentsClient) preparerForListMultiRolePoolSkus(ctx context.Context, id HostingEnvironmentId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/multiRolePools/default/skus", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListMultiRolePoolSkusWithNextLink prepares the ListMultiRolePoolSkus request with the given nextLink token. -func (c AppServiceEnvironmentsClient) preparerForListMultiRolePoolSkusWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListMultiRolePoolSkus handles the response to the ListMultiRolePoolSkus request. The method always -// closes the http.Response Body. -func (c AppServiceEnvironmentsClient) responderForListMultiRolePoolSkus(resp *http.Response) (result ListMultiRolePoolSkusOperationResponse, err error) { - type page struct { - Values []SkuInfo `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListMultiRolePoolSkusOperationResponse, err error) { - req, err := c.preparerForListMultiRolePoolSkusWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListMultiRolePoolSkus", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListMultiRolePoolSkus", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListMultiRolePoolSkus(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListMultiRolePoolSkus", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListMultiRolePoolSkusComplete retrieves all of the results into a single object -func (c AppServiceEnvironmentsClient) ListMultiRolePoolSkusComplete(ctx context.Context, id HostingEnvironmentId) (ListMultiRolePoolSkusCompleteResult, error) { - return c.ListMultiRolePoolSkusCompleteMatchingPredicate(ctx, id, SkuInfoOperationPredicate{}) -} - -// ListMultiRolePoolSkusCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c AppServiceEnvironmentsClient) ListMultiRolePoolSkusCompleteMatchingPredicate(ctx context.Context, id HostingEnvironmentId, predicate SkuInfoOperationPredicate) (resp ListMultiRolePoolSkusCompleteResult, err error) { - items := make([]SkuInfo, 0) - - page, err := c.ListMultiRolePoolSkus(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListMultiRolePoolSkusCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_listmultiroleusages.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_listmultiroleusages.go new file mode 100644 index 00000000000..463988745de --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceenvironments/method_listmultiroleusages.go @@ -0,0 +1,89 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "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 ListMultiRoleUsagesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Usage +} + +type ListMultiRoleUsagesCompleteResult struct { + Items []Usage +} + +// ListMultiRoleUsages ... +func (c AppServiceEnvironmentsClient) ListMultiRoleUsages(ctx context.Context, id HostingEnvironmentId) (result ListMultiRoleUsagesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/multiRolePools/default/usages", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Usage `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListMultiRoleUsagesComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListMultiRoleUsagesComplete(ctx context.Context, id HostingEnvironmentId) (ListMultiRoleUsagesCompleteResult, error) { + return c.ListMultiRoleUsagesCompleteMatchingPredicate(ctx, id, UsageOperationPredicate{}) +} + +// ListMultiRoleUsagesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListMultiRoleUsagesCompleteMatchingPredicate(ctx context.Context, id HostingEnvironmentId, predicate UsageOperationPredicate) (result ListMultiRoleUsagesCompleteResult, err error) { + items := make([]Usage, 0) + + resp, err := c.ListMultiRoleUsages(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListMultiRoleUsagesCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_listmultiroleusages_autorest.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_listmultiroleusages_autorest.go deleted file mode 100644 index 0eb842630ab..00000000000 --- a/resource-manager/web/2022-09-01/appserviceenvironments/method_listmultiroleusages_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package appserviceenvironments - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListMultiRoleUsagesOperationResponse struct { - HttpResponse *http.Response - Model *[]Usage - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListMultiRoleUsagesOperationResponse, error) -} - -type ListMultiRoleUsagesCompleteResult struct { - Items []Usage -} - -func (r ListMultiRoleUsagesOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListMultiRoleUsagesOperationResponse) LoadMore(ctx context.Context) (resp ListMultiRoleUsagesOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListMultiRoleUsages ... -func (c AppServiceEnvironmentsClient) ListMultiRoleUsages(ctx context.Context, id HostingEnvironmentId) (resp ListMultiRoleUsagesOperationResponse, err error) { - req, err := c.preparerForListMultiRoleUsages(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListMultiRoleUsages", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListMultiRoleUsages", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListMultiRoleUsages(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListMultiRoleUsages", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListMultiRoleUsages prepares the ListMultiRoleUsages request. -func (c AppServiceEnvironmentsClient) preparerForListMultiRoleUsages(ctx context.Context, id HostingEnvironmentId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/multiRolePools/default/usages", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListMultiRoleUsagesWithNextLink prepares the ListMultiRoleUsages request with the given nextLink token. -func (c AppServiceEnvironmentsClient) preparerForListMultiRoleUsagesWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListMultiRoleUsages handles the response to the ListMultiRoleUsages request. The method always -// closes the http.Response Body. -func (c AppServiceEnvironmentsClient) responderForListMultiRoleUsages(resp *http.Response) (result ListMultiRoleUsagesOperationResponse, err error) { - type page struct { - Values []Usage `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListMultiRoleUsagesOperationResponse, err error) { - req, err := c.preparerForListMultiRoleUsagesWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListMultiRoleUsages", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListMultiRoleUsages", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListMultiRoleUsages(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListMultiRoleUsages", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListMultiRoleUsagesComplete retrieves all of the results into a single object -func (c AppServiceEnvironmentsClient) ListMultiRoleUsagesComplete(ctx context.Context, id HostingEnvironmentId) (ListMultiRoleUsagesCompleteResult, error) { - return c.ListMultiRoleUsagesCompleteMatchingPredicate(ctx, id, UsageOperationPredicate{}) -} - -// ListMultiRoleUsagesCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c AppServiceEnvironmentsClient) ListMultiRoleUsagesCompleteMatchingPredicate(ctx context.Context, id HostingEnvironmentId, predicate UsageOperationPredicate) (resp ListMultiRoleUsagesCompleteResult, err error) { - items := make([]Usage, 0) - - page, err := c.ListMultiRoleUsages(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListMultiRoleUsagesCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_listoperations.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_listoperations.go new file mode 100644 index 00000000000..83f4e7688ce --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceenvironments/method_listoperations.go @@ -0,0 +1,52 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "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 ListOperationsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Operation +} + +// ListOperations ... +func (c AppServiceEnvironmentsClient) ListOperations(ctx context.Context, id HostingEnvironmentId) (result ListOperationsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/operations", 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 +} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_listoperations_autorest.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_listoperations_autorest.go deleted file mode 100644 index 4fe49db9fef..00000000000 --- a/resource-manager/web/2022-09-01/appserviceenvironments/method_listoperations_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package appserviceenvironments - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListOperationsOperationResponse struct { - HttpResponse *http.Response - Model *[]Operation -} - -// ListOperations ... -func (c AppServiceEnvironmentsClient) ListOperations(ctx context.Context, id HostingEnvironmentId) (result ListOperationsOperationResponse, err error) { - req, err := c.preparerForListOperations(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListOperations", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListOperations", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListOperations(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListOperations", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListOperations prepares the ListOperations request. -func (c AppServiceEnvironmentsClient) preparerForListOperations(ctx context.Context, id HostingEnvironmentId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/operations", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListOperations handles the response to the ListOperations request. The method always -// closes the http.Response Body. -func (c AppServiceEnvironmentsClient) responderForListOperations(resp *http.Response) (result ListOperationsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_listusages.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_listusages.go new file mode 100644 index 00000000000..5921345c285 --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceenvironments/method_listusages.go @@ -0,0 +1,117 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "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 ListUsagesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CsmUsageQuota +} + +type ListUsagesCompleteResult struct { + Items []CsmUsageQuota +} + +type ListUsagesOperationOptions struct { + Filter *string +} + +func DefaultListUsagesOperationOptions() ListUsagesOperationOptions { + return ListUsagesOperationOptions{} +} + +func (o ListUsagesOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListUsagesOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListUsagesOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +// ListUsages ... +func (c AppServiceEnvironmentsClient) ListUsages(ctx context.Context, id HostingEnvironmentId, options ListUsagesOperationOptions) (result ListUsagesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/usages", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]CsmUsageQuota `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListUsagesComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListUsagesComplete(ctx context.Context, id HostingEnvironmentId, options ListUsagesOperationOptions) (ListUsagesCompleteResult, error) { + return c.ListUsagesCompleteMatchingPredicate(ctx, id, options, CsmUsageQuotaOperationPredicate{}) +} + +// ListUsagesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListUsagesCompleteMatchingPredicate(ctx context.Context, id HostingEnvironmentId, options ListUsagesOperationOptions, predicate CsmUsageQuotaOperationPredicate) (result ListUsagesCompleteResult, err error) { + items := make([]CsmUsageQuota, 0) + + resp, err := c.ListUsages(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListUsagesCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_listusages_autorest.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_listusages_autorest.go deleted file mode 100644 index 41e3074d9b6..00000000000 --- a/resource-manager/web/2022-09-01/appserviceenvironments/method_listusages_autorest.go +++ /dev/null @@ -1,215 +0,0 @@ -package appserviceenvironments - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListUsagesOperationResponse struct { - HttpResponse *http.Response - Model *[]CsmUsageQuota - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListUsagesOperationResponse, error) -} - -type ListUsagesCompleteResult struct { - Items []CsmUsageQuota -} - -func (r ListUsagesOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListUsagesOperationResponse) LoadMore(ctx context.Context) (resp ListUsagesOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListUsagesOperationOptions struct { - Filter *string -} - -func DefaultListUsagesOperationOptions() ListUsagesOperationOptions { - return ListUsagesOperationOptions{} -} - -func (o ListUsagesOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListUsagesOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - return out -} - -// ListUsages ... -func (c AppServiceEnvironmentsClient) ListUsages(ctx context.Context, id HostingEnvironmentId, options ListUsagesOperationOptions) (resp ListUsagesOperationResponse, err error) { - req, err := c.preparerForListUsages(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListUsages", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListUsages", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListUsages(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListUsages", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListUsages prepares the ListUsages request. -func (c AppServiceEnvironmentsClient) preparerForListUsages(ctx context.Context, id HostingEnvironmentId, options ListUsagesOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/usages", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListUsagesWithNextLink prepares the ListUsages request with the given nextLink token. -func (c AppServiceEnvironmentsClient) preparerForListUsagesWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListUsages handles the response to the ListUsages request. The method always -// closes the http.Response Body. -func (c AppServiceEnvironmentsClient) responderForListUsages(resp *http.Response) (result ListUsagesOperationResponse, err error) { - type page struct { - Values []CsmUsageQuota `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListUsagesOperationResponse, err error) { - req, err := c.preparerForListUsagesWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListUsages", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListUsages", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListUsages(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListUsages", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListUsagesComplete retrieves all of the results into a single object -func (c AppServiceEnvironmentsClient) ListUsagesComplete(ctx context.Context, id HostingEnvironmentId, options ListUsagesOperationOptions) (ListUsagesCompleteResult, error) { - return c.ListUsagesCompleteMatchingPredicate(ctx, id, options, CsmUsageQuotaOperationPredicate{}) -} - -// ListUsagesCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c AppServiceEnvironmentsClient) ListUsagesCompleteMatchingPredicate(ctx context.Context, id HostingEnvironmentId, options ListUsagesOperationOptions, predicate CsmUsageQuotaOperationPredicate) (resp ListUsagesCompleteResult, err error) { - items := make([]CsmUsageQuota, 0) - - page, err := c.ListUsages(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListUsagesCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_listwebapps.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_listwebapps.go new file mode 100644 index 00000000000..635fe0dbb9d --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceenvironments/method_listwebapps.go @@ -0,0 +1,117 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "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 ListWebAppsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Site +} + +type ListWebAppsCompleteResult struct { + Items []Site +} + +type ListWebAppsOperationOptions struct { + PropertiesToInclude *string +} + +func DefaultListWebAppsOperationOptions() ListWebAppsOperationOptions { + return ListWebAppsOperationOptions{} +} + +func (o ListWebAppsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListWebAppsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListWebAppsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.PropertiesToInclude != nil { + out.Append("propertiesToInclude", fmt.Sprintf("%v", *o.PropertiesToInclude)) + } + return &out +} + +// ListWebApps ... +func (c AppServiceEnvironmentsClient) ListWebApps(ctx context.Context, id HostingEnvironmentId, options ListWebAppsOperationOptions) (result ListWebAppsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/sites", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Site `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListWebAppsComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListWebAppsComplete(ctx context.Context, id HostingEnvironmentId, options ListWebAppsOperationOptions) (ListWebAppsCompleteResult, error) { + return c.ListWebAppsCompleteMatchingPredicate(ctx, id, options, SiteOperationPredicate{}) +} + +// ListWebAppsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListWebAppsCompleteMatchingPredicate(ctx context.Context, id HostingEnvironmentId, options ListWebAppsOperationOptions, predicate SiteOperationPredicate) (result ListWebAppsCompleteResult, err error) { + items := make([]Site, 0) + + resp, err := c.ListWebApps(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListWebAppsCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_listwebapps_autorest.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_listwebapps_autorest.go deleted file mode 100644 index 7990d59c631..00000000000 --- a/resource-manager/web/2022-09-01/appserviceenvironments/method_listwebapps_autorest.go +++ /dev/null @@ -1,215 +0,0 @@ -package appserviceenvironments - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListWebAppsOperationResponse struct { - HttpResponse *http.Response - Model *[]Site - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListWebAppsOperationResponse, error) -} - -type ListWebAppsCompleteResult struct { - Items []Site -} - -func (r ListWebAppsOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListWebAppsOperationResponse) LoadMore(ctx context.Context) (resp ListWebAppsOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListWebAppsOperationOptions struct { - PropertiesToInclude *string -} - -func DefaultListWebAppsOperationOptions() ListWebAppsOperationOptions { - return ListWebAppsOperationOptions{} -} - -func (o ListWebAppsOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListWebAppsOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.PropertiesToInclude != nil { - out["propertiesToInclude"] = *o.PropertiesToInclude - } - - return out -} - -// ListWebApps ... -func (c AppServiceEnvironmentsClient) ListWebApps(ctx context.Context, id HostingEnvironmentId, options ListWebAppsOperationOptions) (resp ListWebAppsOperationResponse, err error) { - req, err := c.preparerForListWebApps(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListWebApps", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListWebApps", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListWebApps(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListWebApps", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListWebApps prepares the ListWebApps request. -func (c AppServiceEnvironmentsClient) preparerForListWebApps(ctx context.Context, id HostingEnvironmentId, options ListWebAppsOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/sites", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWebAppsWithNextLink prepares the ListWebApps request with the given nextLink token. -func (c AppServiceEnvironmentsClient) preparerForListWebAppsWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListWebApps handles the response to the ListWebApps request. The method always -// closes the http.Response Body. -func (c AppServiceEnvironmentsClient) responderForListWebApps(resp *http.Response) (result ListWebAppsOperationResponse, err error) { - type page struct { - Values []Site `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListWebAppsOperationResponse, err error) { - req, err := c.preparerForListWebAppsWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListWebApps", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListWebApps", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListWebApps(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListWebApps", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListWebAppsComplete retrieves all of the results into a single object -func (c AppServiceEnvironmentsClient) ListWebAppsComplete(ctx context.Context, id HostingEnvironmentId, options ListWebAppsOperationOptions) (ListWebAppsCompleteResult, error) { - return c.ListWebAppsCompleteMatchingPredicate(ctx, id, options, SiteOperationPredicate{}) -} - -// ListWebAppsCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c AppServiceEnvironmentsClient) ListWebAppsCompleteMatchingPredicate(ctx context.Context, id HostingEnvironmentId, options ListWebAppsOperationOptions, predicate SiteOperationPredicate) (resp ListWebAppsCompleteResult, err error) { - items := make([]Site, 0) - - page, err := c.ListWebApps(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListWebAppsCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_listwebworkermetricdefinitions.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_listwebworkermetricdefinitions.go new file mode 100644 index 00000000000..fc8db692691 --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceenvironments/method_listwebworkermetricdefinitions.go @@ -0,0 +1,89 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "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 ListWebWorkerMetricDefinitionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ResourceMetricDefinition +} + +type ListWebWorkerMetricDefinitionsCompleteResult struct { + Items []ResourceMetricDefinition +} + +// ListWebWorkerMetricDefinitions ... +func (c AppServiceEnvironmentsClient) ListWebWorkerMetricDefinitions(ctx context.Context, id WorkerPoolId) (result ListWebWorkerMetricDefinitionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/metricdefinitions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ResourceMetricDefinition `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListWebWorkerMetricDefinitionsComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListWebWorkerMetricDefinitionsComplete(ctx context.Context, id WorkerPoolId) (ListWebWorkerMetricDefinitionsCompleteResult, error) { + return c.ListWebWorkerMetricDefinitionsCompleteMatchingPredicate(ctx, id, ResourceMetricDefinitionOperationPredicate{}) +} + +// ListWebWorkerMetricDefinitionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListWebWorkerMetricDefinitionsCompleteMatchingPredicate(ctx context.Context, id WorkerPoolId, predicate ResourceMetricDefinitionOperationPredicate) (result ListWebWorkerMetricDefinitionsCompleteResult, err error) { + items := make([]ResourceMetricDefinition, 0) + + resp, err := c.ListWebWorkerMetricDefinitions(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListWebWorkerMetricDefinitionsCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_listwebworkermetricdefinitions_autorest.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_listwebworkermetricdefinitions_autorest.go deleted file mode 100644 index a43ea0f9b6f..00000000000 --- a/resource-manager/web/2022-09-01/appserviceenvironments/method_listwebworkermetricdefinitions_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package appserviceenvironments - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListWebWorkerMetricDefinitionsOperationResponse struct { - HttpResponse *http.Response - Model *[]ResourceMetricDefinition - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListWebWorkerMetricDefinitionsOperationResponse, error) -} - -type ListWebWorkerMetricDefinitionsCompleteResult struct { - Items []ResourceMetricDefinition -} - -func (r ListWebWorkerMetricDefinitionsOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListWebWorkerMetricDefinitionsOperationResponse) LoadMore(ctx context.Context) (resp ListWebWorkerMetricDefinitionsOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListWebWorkerMetricDefinitions ... -func (c AppServiceEnvironmentsClient) ListWebWorkerMetricDefinitions(ctx context.Context, id WorkerPoolId) (resp ListWebWorkerMetricDefinitionsOperationResponse, err error) { - req, err := c.preparerForListWebWorkerMetricDefinitions(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListWebWorkerMetricDefinitions", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListWebWorkerMetricDefinitions", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListWebWorkerMetricDefinitions(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListWebWorkerMetricDefinitions", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListWebWorkerMetricDefinitions prepares the ListWebWorkerMetricDefinitions request. -func (c AppServiceEnvironmentsClient) preparerForListWebWorkerMetricDefinitions(ctx context.Context, id WorkerPoolId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/metricdefinitions", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWebWorkerMetricDefinitionsWithNextLink prepares the ListWebWorkerMetricDefinitions request with the given nextLink token. -func (c AppServiceEnvironmentsClient) preparerForListWebWorkerMetricDefinitionsWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListWebWorkerMetricDefinitions handles the response to the ListWebWorkerMetricDefinitions request. The method always -// closes the http.Response Body. -func (c AppServiceEnvironmentsClient) responderForListWebWorkerMetricDefinitions(resp *http.Response) (result ListWebWorkerMetricDefinitionsOperationResponse, err error) { - type page struct { - Values []ResourceMetricDefinition `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListWebWorkerMetricDefinitionsOperationResponse, err error) { - req, err := c.preparerForListWebWorkerMetricDefinitionsWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListWebWorkerMetricDefinitions", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListWebWorkerMetricDefinitions", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListWebWorkerMetricDefinitions(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListWebWorkerMetricDefinitions", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListWebWorkerMetricDefinitionsComplete retrieves all of the results into a single object -func (c AppServiceEnvironmentsClient) ListWebWorkerMetricDefinitionsComplete(ctx context.Context, id WorkerPoolId) (ListWebWorkerMetricDefinitionsCompleteResult, error) { - return c.ListWebWorkerMetricDefinitionsCompleteMatchingPredicate(ctx, id, ResourceMetricDefinitionOperationPredicate{}) -} - -// ListWebWorkerMetricDefinitionsCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c AppServiceEnvironmentsClient) ListWebWorkerMetricDefinitionsCompleteMatchingPredicate(ctx context.Context, id WorkerPoolId, predicate ResourceMetricDefinitionOperationPredicate) (resp ListWebWorkerMetricDefinitionsCompleteResult, err error) { - items := make([]ResourceMetricDefinition, 0) - - page, err := c.ListWebWorkerMetricDefinitions(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListWebWorkerMetricDefinitionsCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_listwebworkerusages.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_listwebworkerusages.go new file mode 100644 index 00000000000..ff3ea7a31dd --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceenvironments/method_listwebworkerusages.go @@ -0,0 +1,89 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "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 ListWebWorkerUsagesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Usage +} + +type ListWebWorkerUsagesCompleteResult struct { + Items []Usage +} + +// ListWebWorkerUsages ... +func (c AppServiceEnvironmentsClient) ListWebWorkerUsages(ctx context.Context, id WorkerPoolId) (result ListWebWorkerUsagesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/usages", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Usage `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListWebWorkerUsagesComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListWebWorkerUsagesComplete(ctx context.Context, id WorkerPoolId) (ListWebWorkerUsagesCompleteResult, error) { + return c.ListWebWorkerUsagesCompleteMatchingPredicate(ctx, id, UsageOperationPredicate{}) +} + +// ListWebWorkerUsagesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListWebWorkerUsagesCompleteMatchingPredicate(ctx context.Context, id WorkerPoolId, predicate UsageOperationPredicate) (result ListWebWorkerUsagesCompleteResult, err error) { + items := make([]Usage, 0) + + resp, err := c.ListWebWorkerUsages(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListWebWorkerUsagesCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_listwebworkerusages_autorest.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_listwebworkerusages_autorest.go deleted file mode 100644 index 8811c7f4077..00000000000 --- a/resource-manager/web/2022-09-01/appserviceenvironments/method_listwebworkerusages_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package appserviceenvironments - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListWebWorkerUsagesOperationResponse struct { - HttpResponse *http.Response - Model *[]Usage - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListWebWorkerUsagesOperationResponse, error) -} - -type ListWebWorkerUsagesCompleteResult struct { - Items []Usage -} - -func (r ListWebWorkerUsagesOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListWebWorkerUsagesOperationResponse) LoadMore(ctx context.Context) (resp ListWebWorkerUsagesOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListWebWorkerUsages ... -func (c AppServiceEnvironmentsClient) ListWebWorkerUsages(ctx context.Context, id WorkerPoolId) (resp ListWebWorkerUsagesOperationResponse, err error) { - req, err := c.preparerForListWebWorkerUsages(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListWebWorkerUsages", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListWebWorkerUsages", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListWebWorkerUsages(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListWebWorkerUsages", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListWebWorkerUsages prepares the ListWebWorkerUsages request. -func (c AppServiceEnvironmentsClient) preparerForListWebWorkerUsages(ctx context.Context, id WorkerPoolId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/usages", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWebWorkerUsagesWithNextLink prepares the ListWebWorkerUsages request with the given nextLink token. -func (c AppServiceEnvironmentsClient) preparerForListWebWorkerUsagesWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListWebWorkerUsages handles the response to the ListWebWorkerUsages request. The method always -// closes the http.Response Body. -func (c AppServiceEnvironmentsClient) responderForListWebWorkerUsages(resp *http.Response) (result ListWebWorkerUsagesOperationResponse, err error) { - type page struct { - Values []Usage `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListWebWorkerUsagesOperationResponse, err error) { - req, err := c.preparerForListWebWorkerUsagesWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListWebWorkerUsages", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListWebWorkerUsages", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListWebWorkerUsages(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListWebWorkerUsages", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListWebWorkerUsagesComplete retrieves all of the results into a single object -func (c AppServiceEnvironmentsClient) ListWebWorkerUsagesComplete(ctx context.Context, id WorkerPoolId) (ListWebWorkerUsagesCompleteResult, error) { - return c.ListWebWorkerUsagesCompleteMatchingPredicate(ctx, id, UsageOperationPredicate{}) -} - -// ListWebWorkerUsagesCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c AppServiceEnvironmentsClient) ListWebWorkerUsagesCompleteMatchingPredicate(ctx context.Context, id WorkerPoolId, predicate UsageOperationPredicate) (resp ListWebWorkerUsagesCompleteResult, err error) { - items := make([]Usage, 0) - - page, err := c.ListWebWorkerUsages(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListWebWorkerUsagesCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_listworkerpoolinstancemetricdefinitions.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_listworkerpoolinstancemetricdefinitions.go new file mode 100644 index 00000000000..403bf595686 --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceenvironments/method_listworkerpoolinstancemetricdefinitions.go @@ -0,0 +1,89 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "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 ListWorkerPoolInstanceMetricDefinitionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ResourceMetricDefinition +} + +type ListWorkerPoolInstanceMetricDefinitionsCompleteResult struct { + Items []ResourceMetricDefinition +} + +// ListWorkerPoolInstanceMetricDefinitions ... +func (c AppServiceEnvironmentsClient) ListWorkerPoolInstanceMetricDefinitions(ctx context.Context, id WorkerPoolInstanceId) (result ListWorkerPoolInstanceMetricDefinitionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/metricdefinitions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ResourceMetricDefinition `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListWorkerPoolInstanceMetricDefinitionsComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListWorkerPoolInstanceMetricDefinitionsComplete(ctx context.Context, id WorkerPoolInstanceId) (ListWorkerPoolInstanceMetricDefinitionsCompleteResult, error) { + return c.ListWorkerPoolInstanceMetricDefinitionsCompleteMatchingPredicate(ctx, id, ResourceMetricDefinitionOperationPredicate{}) +} + +// ListWorkerPoolInstanceMetricDefinitionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListWorkerPoolInstanceMetricDefinitionsCompleteMatchingPredicate(ctx context.Context, id WorkerPoolInstanceId, predicate ResourceMetricDefinitionOperationPredicate) (result ListWorkerPoolInstanceMetricDefinitionsCompleteResult, err error) { + items := make([]ResourceMetricDefinition, 0) + + resp, err := c.ListWorkerPoolInstanceMetricDefinitions(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListWorkerPoolInstanceMetricDefinitionsCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_listworkerpoolinstancemetricdefinitions_autorest.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_listworkerpoolinstancemetricdefinitions_autorest.go deleted file mode 100644 index a3bb68116cc..00000000000 --- a/resource-manager/web/2022-09-01/appserviceenvironments/method_listworkerpoolinstancemetricdefinitions_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package appserviceenvironments - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListWorkerPoolInstanceMetricDefinitionsOperationResponse struct { - HttpResponse *http.Response - Model *[]ResourceMetricDefinition - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListWorkerPoolInstanceMetricDefinitionsOperationResponse, error) -} - -type ListWorkerPoolInstanceMetricDefinitionsCompleteResult struct { - Items []ResourceMetricDefinition -} - -func (r ListWorkerPoolInstanceMetricDefinitionsOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListWorkerPoolInstanceMetricDefinitionsOperationResponse) LoadMore(ctx context.Context) (resp ListWorkerPoolInstanceMetricDefinitionsOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListWorkerPoolInstanceMetricDefinitions ... -func (c AppServiceEnvironmentsClient) ListWorkerPoolInstanceMetricDefinitions(ctx context.Context, id WorkerPoolInstanceId) (resp ListWorkerPoolInstanceMetricDefinitionsOperationResponse, err error) { - req, err := c.preparerForListWorkerPoolInstanceMetricDefinitions(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListWorkerPoolInstanceMetricDefinitions", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListWorkerPoolInstanceMetricDefinitions", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListWorkerPoolInstanceMetricDefinitions(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListWorkerPoolInstanceMetricDefinitions", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListWorkerPoolInstanceMetricDefinitions prepares the ListWorkerPoolInstanceMetricDefinitions request. -func (c AppServiceEnvironmentsClient) preparerForListWorkerPoolInstanceMetricDefinitions(ctx context.Context, id WorkerPoolInstanceId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/metricdefinitions", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWorkerPoolInstanceMetricDefinitionsWithNextLink prepares the ListWorkerPoolInstanceMetricDefinitions request with the given nextLink token. -func (c AppServiceEnvironmentsClient) preparerForListWorkerPoolInstanceMetricDefinitionsWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListWorkerPoolInstanceMetricDefinitions handles the response to the ListWorkerPoolInstanceMetricDefinitions request. The method always -// closes the http.Response Body. -func (c AppServiceEnvironmentsClient) responderForListWorkerPoolInstanceMetricDefinitions(resp *http.Response) (result ListWorkerPoolInstanceMetricDefinitionsOperationResponse, err error) { - type page struct { - Values []ResourceMetricDefinition `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListWorkerPoolInstanceMetricDefinitionsOperationResponse, err error) { - req, err := c.preparerForListWorkerPoolInstanceMetricDefinitionsWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListWorkerPoolInstanceMetricDefinitions", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListWorkerPoolInstanceMetricDefinitions", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListWorkerPoolInstanceMetricDefinitions(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListWorkerPoolInstanceMetricDefinitions", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListWorkerPoolInstanceMetricDefinitionsComplete retrieves all of the results into a single object -func (c AppServiceEnvironmentsClient) ListWorkerPoolInstanceMetricDefinitionsComplete(ctx context.Context, id WorkerPoolInstanceId) (ListWorkerPoolInstanceMetricDefinitionsCompleteResult, error) { - return c.ListWorkerPoolInstanceMetricDefinitionsCompleteMatchingPredicate(ctx, id, ResourceMetricDefinitionOperationPredicate{}) -} - -// ListWorkerPoolInstanceMetricDefinitionsCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c AppServiceEnvironmentsClient) ListWorkerPoolInstanceMetricDefinitionsCompleteMatchingPredicate(ctx context.Context, id WorkerPoolInstanceId, predicate ResourceMetricDefinitionOperationPredicate) (resp ListWorkerPoolInstanceMetricDefinitionsCompleteResult, err error) { - items := make([]ResourceMetricDefinition, 0) - - page, err := c.ListWorkerPoolInstanceMetricDefinitions(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListWorkerPoolInstanceMetricDefinitionsCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_listworkerpools.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_listworkerpools.go new file mode 100644 index 00000000000..535804e50ef --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceenvironments/method_listworkerpools.go @@ -0,0 +1,89 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "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 ListWorkerPoolsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WorkerPoolResource +} + +type ListWorkerPoolsCompleteResult struct { + Items []WorkerPoolResource +} + +// ListWorkerPools ... +func (c AppServiceEnvironmentsClient) ListWorkerPools(ctx context.Context, id HostingEnvironmentId) (result ListWorkerPoolsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/workerPools", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]WorkerPoolResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListWorkerPoolsComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListWorkerPoolsComplete(ctx context.Context, id HostingEnvironmentId) (ListWorkerPoolsCompleteResult, error) { + return c.ListWorkerPoolsCompleteMatchingPredicate(ctx, id, WorkerPoolResourceOperationPredicate{}) +} + +// ListWorkerPoolsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListWorkerPoolsCompleteMatchingPredicate(ctx context.Context, id HostingEnvironmentId, predicate WorkerPoolResourceOperationPredicate) (result ListWorkerPoolsCompleteResult, err error) { + items := make([]WorkerPoolResource, 0) + + resp, err := c.ListWorkerPools(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListWorkerPoolsCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_listworkerpools_autorest.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_listworkerpools_autorest.go deleted file mode 100644 index 382a0681472..00000000000 --- a/resource-manager/web/2022-09-01/appserviceenvironments/method_listworkerpools_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package appserviceenvironments - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListWorkerPoolsOperationResponse struct { - HttpResponse *http.Response - Model *[]WorkerPoolResource - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListWorkerPoolsOperationResponse, error) -} - -type ListWorkerPoolsCompleteResult struct { - Items []WorkerPoolResource -} - -func (r ListWorkerPoolsOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListWorkerPoolsOperationResponse) LoadMore(ctx context.Context) (resp ListWorkerPoolsOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListWorkerPools ... -func (c AppServiceEnvironmentsClient) ListWorkerPools(ctx context.Context, id HostingEnvironmentId) (resp ListWorkerPoolsOperationResponse, err error) { - req, err := c.preparerForListWorkerPools(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListWorkerPools", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListWorkerPools", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListWorkerPools(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListWorkerPools", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListWorkerPools prepares the ListWorkerPools request. -func (c AppServiceEnvironmentsClient) preparerForListWorkerPools(ctx context.Context, id HostingEnvironmentId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/workerPools", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWorkerPoolsWithNextLink prepares the ListWorkerPools request with the given nextLink token. -func (c AppServiceEnvironmentsClient) preparerForListWorkerPoolsWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListWorkerPools handles the response to the ListWorkerPools request. The method always -// closes the http.Response Body. -func (c AppServiceEnvironmentsClient) responderForListWorkerPools(resp *http.Response) (result ListWorkerPoolsOperationResponse, err error) { - type page struct { - Values []WorkerPoolResource `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListWorkerPoolsOperationResponse, err error) { - req, err := c.preparerForListWorkerPoolsWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListWorkerPools", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListWorkerPools", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListWorkerPools(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListWorkerPools", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListWorkerPoolsComplete retrieves all of the results into a single object -func (c AppServiceEnvironmentsClient) ListWorkerPoolsComplete(ctx context.Context, id HostingEnvironmentId) (ListWorkerPoolsCompleteResult, error) { - return c.ListWorkerPoolsCompleteMatchingPredicate(ctx, id, WorkerPoolResourceOperationPredicate{}) -} - -// ListWorkerPoolsCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c AppServiceEnvironmentsClient) ListWorkerPoolsCompleteMatchingPredicate(ctx context.Context, id HostingEnvironmentId, predicate WorkerPoolResourceOperationPredicate) (resp ListWorkerPoolsCompleteResult, err error) { - items := make([]WorkerPoolResource, 0) - - page, err := c.ListWorkerPools(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListWorkerPoolsCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_listworkerpoolskus.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_listworkerpoolskus.go new file mode 100644 index 00000000000..35f340e977f --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceenvironments/method_listworkerpoolskus.go @@ -0,0 +1,89 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "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 ListWorkerPoolSkusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SkuInfo +} + +type ListWorkerPoolSkusCompleteResult struct { + Items []SkuInfo +} + +// ListWorkerPoolSkus ... +func (c AppServiceEnvironmentsClient) ListWorkerPoolSkus(ctx context.Context, id WorkerPoolId) (result ListWorkerPoolSkusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/skus", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]SkuInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListWorkerPoolSkusComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListWorkerPoolSkusComplete(ctx context.Context, id WorkerPoolId) (ListWorkerPoolSkusCompleteResult, error) { + return c.ListWorkerPoolSkusCompleteMatchingPredicate(ctx, id, SkuInfoOperationPredicate{}) +} + +// ListWorkerPoolSkusCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListWorkerPoolSkusCompleteMatchingPredicate(ctx context.Context, id WorkerPoolId, predicate SkuInfoOperationPredicate) (result ListWorkerPoolSkusCompleteResult, err error) { + items := make([]SkuInfo, 0) + + resp, err := c.ListWorkerPoolSkus(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListWorkerPoolSkusCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_listworkerpoolskus_autorest.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_listworkerpoolskus_autorest.go deleted file mode 100644 index c66cd0a1b16..00000000000 --- a/resource-manager/web/2022-09-01/appserviceenvironments/method_listworkerpoolskus_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package appserviceenvironments - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListWorkerPoolSkusOperationResponse struct { - HttpResponse *http.Response - Model *[]SkuInfo - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListWorkerPoolSkusOperationResponse, error) -} - -type ListWorkerPoolSkusCompleteResult struct { - Items []SkuInfo -} - -func (r ListWorkerPoolSkusOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListWorkerPoolSkusOperationResponse) LoadMore(ctx context.Context) (resp ListWorkerPoolSkusOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListWorkerPoolSkus ... -func (c AppServiceEnvironmentsClient) ListWorkerPoolSkus(ctx context.Context, id WorkerPoolId) (resp ListWorkerPoolSkusOperationResponse, err error) { - req, err := c.preparerForListWorkerPoolSkus(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListWorkerPoolSkus", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListWorkerPoolSkus", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListWorkerPoolSkus(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListWorkerPoolSkus", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListWorkerPoolSkus prepares the ListWorkerPoolSkus request. -func (c AppServiceEnvironmentsClient) preparerForListWorkerPoolSkus(ctx context.Context, id WorkerPoolId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/skus", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWorkerPoolSkusWithNextLink prepares the ListWorkerPoolSkus request with the given nextLink token. -func (c AppServiceEnvironmentsClient) preparerForListWorkerPoolSkusWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListWorkerPoolSkus handles the response to the ListWorkerPoolSkus request. The method always -// closes the http.Response Body. -func (c AppServiceEnvironmentsClient) responderForListWorkerPoolSkus(resp *http.Response) (result ListWorkerPoolSkusOperationResponse, err error) { - type page struct { - Values []SkuInfo `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListWorkerPoolSkusOperationResponse, err error) { - req, err := c.preparerForListWorkerPoolSkusWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListWorkerPoolSkus", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListWorkerPoolSkus", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListWorkerPoolSkus(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "ListWorkerPoolSkus", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListWorkerPoolSkusComplete retrieves all of the results into a single object -func (c AppServiceEnvironmentsClient) ListWorkerPoolSkusComplete(ctx context.Context, id WorkerPoolId) (ListWorkerPoolSkusCompleteResult, error) { - return c.ListWorkerPoolSkusCompleteMatchingPredicate(ctx, id, SkuInfoOperationPredicate{}) -} - -// ListWorkerPoolSkusCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c AppServiceEnvironmentsClient) ListWorkerPoolSkusCompleteMatchingPredicate(ctx context.Context, id WorkerPoolId, predicate SkuInfoOperationPredicate) (resp ListWorkerPoolSkusCompleteResult, err error) { - items := make([]SkuInfo, 0) - - page, err := c.ListWorkerPoolSkus(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListWorkerPoolSkusCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_reboot.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_reboot.go new file mode 100644 index 00000000000..bdcb3ee521b --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceenvironments/method_reboot.go @@ -0,0 +1,47 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "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 RebootOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Reboot ... +func (c AppServiceEnvironmentsClient) Reboot(ctx context.Context, id HostingEnvironmentId) (result RebootOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/reboot", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_reboot_autorest.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_reboot_autorest.go deleted file mode 100644 index 6883f95948f..00000000000 --- a/resource-manager/web/2022-09-01/appserviceenvironments/method_reboot_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package appserviceenvironments - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type RebootOperationResponse struct { - HttpResponse *http.Response -} - -// Reboot ... -func (c AppServiceEnvironmentsClient) Reboot(ctx context.Context, id HostingEnvironmentId) (result RebootOperationResponse, err error) { - req, err := c.preparerForReboot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "Reboot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "Reboot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForReboot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "Reboot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForReboot prepares the Reboot request. -func (c AppServiceEnvironmentsClient) preparerForReboot(ctx context.Context, id HostingEnvironmentId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/reboot", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForReboot handles the response to the Reboot request. The method always -// closes the http.Response Body. -func (c AppServiceEnvironmentsClient) responderForReboot(resp *http.Response) (result RebootOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusAccepted), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_resume.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_resume.go new file mode 100644 index 00000000000..059b034c213 --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceenvironments/method_resume.go @@ -0,0 +1,84 @@ +package appserviceenvironments + +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 ResumeOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *[]Site +} + +type ResumeCompleteResult struct { + Items []Site +} + +// Resume ... +func (c AppServiceEnvironmentsClient) Resume(ctx context.Context, id HostingEnvironmentId) (result ResumeOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resume", 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 + } + + var values struct { + Values *[]Site `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ResumeThenPoll performs Resume then polls until it's completed +func (c AppServiceEnvironmentsClient) ResumeThenPoll(ctx context.Context, id HostingEnvironmentId) error { + result, err := c.Resume(ctx, id) + if err != nil { + return fmt.Errorf("performing Resume: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Resume: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_resume_autorest.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_resume_autorest.go deleted file mode 100644 index d4dfa016513..00000000000 --- a/resource-manager/web/2022-09-01/appserviceenvironments/method_resume_autorest.go +++ /dev/null @@ -1,124 +0,0 @@ -package appserviceenvironments - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ResumeOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response - Model *[]Site - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ResumeOperationResponse, error) -} - -type ResumeCompleteResult struct { - Items []Site -} - -func (r ResumeOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ResumeOperationResponse) LoadMore(ctx context.Context) (resp ResumeOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// Resume ... -func (c AppServiceEnvironmentsClient) Resume(ctx context.Context, id HostingEnvironmentId) (result ResumeOperationResponse, err error) { - req, err := c.preparerForResume(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "Resume", nil, "Failure preparing request") - return - } - - result, err = c.senderForResume(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "Resume", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// ResumeThenPoll performs Resume then polls until it's completed -func (c AppServiceEnvironmentsClient) ResumeThenPoll(ctx context.Context, id HostingEnvironmentId) error { - result, err := c.Resume(ctx, id) - if err != nil { - return fmt.Errorf("performing Resume: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Resume: %+v", err) - } - - return nil -} - -// preparerForResume prepares the Resume request. -func (c AppServiceEnvironmentsClient) preparerForResume(ctx context.Context, id HostingEnvironmentId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/resume", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForResumeWithNextLink prepares the Resume request with the given nextLink token. -func (c AppServiceEnvironmentsClient) preparerForResumeWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForResume sends the Resume request. The method will close the -// http.Response Body if it receives an error. -func (c AppServiceEnvironmentsClient) senderForResume(ctx context.Context, req *http.Request) (future ResumeOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_suspend.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_suspend.go new file mode 100644 index 00000000000..437d00435e2 --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceenvironments/method_suspend.go @@ -0,0 +1,84 @@ +package appserviceenvironments + +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 SuspendOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *[]Site +} + +type SuspendCompleteResult struct { + Items []Site +} + +// Suspend ... +func (c AppServiceEnvironmentsClient) Suspend(ctx context.Context, id HostingEnvironmentId) (result SuspendOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/suspend", 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 + } + + var values struct { + Values *[]Site `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// SuspendThenPoll performs Suspend then polls until it's completed +func (c AppServiceEnvironmentsClient) SuspendThenPoll(ctx context.Context, id HostingEnvironmentId) error { + result, err := c.Suspend(ctx, id) + if err != nil { + return fmt.Errorf("performing Suspend: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Suspend: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_suspend_autorest.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_suspend_autorest.go deleted file mode 100644 index 9b8c6dbaf3e..00000000000 --- a/resource-manager/web/2022-09-01/appserviceenvironments/method_suspend_autorest.go +++ /dev/null @@ -1,124 +0,0 @@ -package appserviceenvironments - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type SuspendOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response - Model *[]Site - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (SuspendOperationResponse, error) -} - -type SuspendCompleteResult struct { - Items []Site -} - -func (r SuspendOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r SuspendOperationResponse) LoadMore(ctx context.Context) (resp SuspendOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// Suspend ... -func (c AppServiceEnvironmentsClient) Suspend(ctx context.Context, id HostingEnvironmentId) (result SuspendOperationResponse, err error) { - req, err := c.preparerForSuspend(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "Suspend", nil, "Failure preparing request") - return - } - - result, err = c.senderForSuspend(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "Suspend", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// SuspendThenPoll performs Suspend then polls until it's completed -func (c AppServiceEnvironmentsClient) SuspendThenPoll(ctx context.Context, id HostingEnvironmentId) error { - result, err := c.Suspend(ctx, id) - if err != nil { - return fmt.Errorf("performing Suspend: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Suspend: %+v", err) - } - - return nil -} - -// preparerForSuspend prepares the Suspend request. -func (c AppServiceEnvironmentsClient) preparerForSuspend(ctx context.Context, id HostingEnvironmentId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/suspend", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForSuspendWithNextLink prepares the Suspend request with the given nextLink token. -func (c AppServiceEnvironmentsClient) preparerForSuspendWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForSuspend sends the Suspend request. The method will close the -// http.Response Body if it receives an error. -func (c AppServiceEnvironmentsClient) senderForSuspend(ctx context.Context, req *http.Request) (future SuspendOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_testupgradeavailablenotification.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_testupgradeavailablenotification.go new file mode 100644 index 00000000000..132cf286221 --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceenvironments/method_testupgradeavailablenotification.go @@ -0,0 +1,47 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "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 TestUpgradeAvailableNotificationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// TestUpgradeAvailableNotification ... +func (c AppServiceEnvironmentsClient) TestUpgradeAvailableNotification(ctx context.Context, id HostingEnvironmentId) (result TestUpgradeAvailableNotificationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/testUpgradeAvailableNotification", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_testupgradeavailablenotification_autorest.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_testupgradeavailablenotification_autorest.go deleted file mode 100644 index c7c5dda7958..00000000000 --- a/resource-manager/web/2022-09-01/appserviceenvironments/method_testupgradeavailablenotification_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package appserviceenvironments - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type TestUpgradeAvailableNotificationOperationResponse struct { - HttpResponse *http.Response -} - -// TestUpgradeAvailableNotification ... -func (c AppServiceEnvironmentsClient) TestUpgradeAvailableNotification(ctx context.Context, id HostingEnvironmentId) (result TestUpgradeAvailableNotificationOperationResponse, err error) { - req, err := c.preparerForTestUpgradeAvailableNotification(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "TestUpgradeAvailableNotification", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "TestUpgradeAvailableNotification", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForTestUpgradeAvailableNotification(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "TestUpgradeAvailableNotification", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForTestUpgradeAvailableNotification prepares the TestUpgradeAvailableNotification request. -func (c AppServiceEnvironmentsClient) preparerForTestUpgradeAvailableNotification(ctx context.Context, id HostingEnvironmentId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/testUpgradeAvailableNotification", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForTestUpgradeAvailableNotification handles the response to the TestUpgradeAvailableNotification request. The method always -// closes the http.Response Body. -func (c AppServiceEnvironmentsClient) responderForTestUpgradeAvailableNotification(resp *http.Response) (result TestUpgradeAvailableNotificationOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_update.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_update.go new file mode 100644 index 00000000000..864fb2aab8d --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceenvironments/method_update.go @@ -0,0 +1,57 @@ +package appserviceenvironments + +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 UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AppServiceEnvironmentResource +} + +// Update ... +func (c AppServiceEnvironmentsClient) Update(ctx context.Context, id HostingEnvironmentId, input AppServiceEnvironmentPatchResource) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + 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 +} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_update_autorest.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_update_autorest.go deleted file mode 100644 index 0743072faf9..00000000000 --- a/resource-manager/web/2022-09-01/appserviceenvironments/method_update_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package appserviceenvironments - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateOperationResponse struct { - HttpResponse *http.Response - Model *AppServiceEnvironmentResource -} - -// Update ... -func (c AppServiceEnvironmentsClient) Update(ctx context.Context, id HostingEnvironmentId, input AppServiceEnvironmentPatchResource) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c AppServiceEnvironmentsClient) preparerForUpdate(ctx context.Context, id HostingEnvironmentId, input AppServiceEnvironmentPatchResource) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdate handles the response to the Update request. The method always -// closes the http.Response Body. -func (c AppServiceEnvironmentsClient) responderForUpdate(resp *http.Response) (result UpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_updateasecustomdnssuffixconfiguration.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_updateasecustomdnssuffixconfiguration.go new file mode 100644 index 00000000000..a60e69452b7 --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceenvironments/method_updateasecustomdnssuffixconfiguration.go @@ -0,0 +1,56 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "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 UpdateAseCustomDnsSuffixConfigurationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CustomDnsSuffixConfiguration +} + +// UpdateAseCustomDnsSuffixConfiguration ... +func (c AppServiceEnvironmentsClient) UpdateAseCustomDnsSuffixConfiguration(ctx context.Context, id HostingEnvironmentId, input CustomDnsSuffixConfiguration) (result UpdateAseCustomDnsSuffixConfigurationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/configurations/customdnssuffix", 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 +} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_updateasecustomdnssuffixconfiguration_autorest.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_updateasecustomdnssuffixconfiguration_autorest.go deleted file mode 100644 index 591d0e8159e..00000000000 --- a/resource-manager/web/2022-09-01/appserviceenvironments/method_updateasecustomdnssuffixconfiguration_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package appserviceenvironments - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateAseCustomDnsSuffixConfigurationOperationResponse struct { - HttpResponse *http.Response - Model *CustomDnsSuffixConfiguration -} - -// UpdateAseCustomDnsSuffixConfiguration ... -func (c AppServiceEnvironmentsClient) UpdateAseCustomDnsSuffixConfiguration(ctx context.Context, id HostingEnvironmentId, input CustomDnsSuffixConfiguration) (result UpdateAseCustomDnsSuffixConfigurationOperationResponse, err error) { - req, err := c.preparerForUpdateAseCustomDnsSuffixConfiguration(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "UpdateAseCustomDnsSuffixConfiguration", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "UpdateAseCustomDnsSuffixConfiguration", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateAseCustomDnsSuffixConfiguration(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "UpdateAseCustomDnsSuffixConfiguration", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateAseCustomDnsSuffixConfiguration prepares the UpdateAseCustomDnsSuffixConfiguration request. -func (c AppServiceEnvironmentsClient) preparerForUpdateAseCustomDnsSuffixConfiguration(ctx context.Context, id HostingEnvironmentId, input CustomDnsSuffixConfiguration) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/configurations/customdnssuffix", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateAseCustomDnsSuffixConfiguration handles the response to the UpdateAseCustomDnsSuffixConfiguration request. The method always -// closes the http.Response Body. -func (c AppServiceEnvironmentsClient) responderForUpdateAseCustomDnsSuffixConfiguration(resp *http.Response) (result UpdateAseCustomDnsSuffixConfigurationOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_updateasenetworkingconfiguration.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_updateasenetworkingconfiguration.go new file mode 100644 index 00000000000..aa904c4fee0 --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceenvironments/method_updateasenetworkingconfiguration.go @@ -0,0 +1,56 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "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 UpdateAseNetworkingConfigurationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AseV3NetworkingConfiguration +} + +// UpdateAseNetworkingConfiguration ... +func (c AppServiceEnvironmentsClient) UpdateAseNetworkingConfiguration(ctx context.Context, id HostingEnvironmentId, input AseV3NetworkingConfiguration) (result UpdateAseNetworkingConfigurationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/configurations/networking", 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 +} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_updateasenetworkingconfiguration_autorest.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_updateasenetworkingconfiguration_autorest.go deleted file mode 100644 index 5e78afe9fe8..00000000000 --- a/resource-manager/web/2022-09-01/appserviceenvironments/method_updateasenetworkingconfiguration_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package appserviceenvironments - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateAseNetworkingConfigurationOperationResponse struct { - HttpResponse *http.Response - Model *AseV3NetworkingConfiguration -} - -// UpdateAseNetworkingConfiguration ... -func (c AppServiceEnvironmentsClient) UpdateAseNetworkingConfiguration(ctx context.Context, id HostingEnvironmentId, input AseV3NetworkingConfiguration) (result UpdateAseNetworkingConfigurationOperationResponse, err error) { - req, err := c.preparerForUpdateAseNetworkingConfiguration(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "UpdateAseNetworkingConfiguration", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "UpdateAseNetworkingConfiguration", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateAseNetworkingConfiguration(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "UpdateAseNetworkingConfiguration", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateAseNetworkingConfiguration prepares the UpdateAseNetworkingConfiguration request. -func (c AppServiceEnvironmentsClient) preparerForUpdateAseNetworkingConfiguration(ctx context.Context, id HostingEnvironmentId, input AseV3NetworkingConfiguration) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/configurations/networking", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateAseNetworkingConfiguration handles the response to the UpdateAseNetworkingConfiguration request. The method always -// closes the http.Response Body. -func (c AppServiceEnvironmentsClient) responderForUpdateAseNetworkingConfiguration(resp *http.Response) (result UpdateAseNetworkingConfigurationOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_updatemultirolepool.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_updatemultirolepool.go new file mode 100644 index 00000000000..2a542f2e4fd --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceenvironments/method_updatemultirolepool.go @@ -0,0 +1,57 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "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 UpdateMultiRolePoolOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkerPoolResource +} + +// UpdateMultiRolePool ... +func (c AppServiceEnvironmentsClient) UpdateMultiRolePool(ctx context.Context, id HostingEnvironmentId, input WorkerPoolResource) (result UpdateMultiRolePoolOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: fmt.Sprintf("%s/multiRolePools/default", 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 +} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_updatemultirolepool_autorest.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_updatemultirolepool_autorest.go deleted file mode 100644 index c2d23d911ba..00000000000 --- a/resource-manager/web/2022-09-01/appserviceenvironments/method_updatemultirolepool_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package appserviceenvironments - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateMultiRolePoolOperationResponse struct { - HttpResponse *http.Response - Model *WorkerPoolResource -} - -// UpdateMultiRolePool ... -func (c AppServiceEnvironmentsClient) UpdateMultiRolePool(ctx context.Context, id HostingEnvironmentId, input WorkerPoolResource) (result UpdateMultiRolePoolOperationResponse, err error) { - req, err := c.preparerForUpdateMultiRolePool(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "UpdateMultiRolePool", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "UpdateMultiRolePool", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateMultiRolePool(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "UpdateMultiRolePool", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateMultiRolePool prepares the UpdateMultiRolePool request. -func (c AppServiceEnvironmentsClient) preparerForUpdateMultiRolePool(ctx context.Context, id HostingEnvironmentId, input WorkerPoolResource) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/multiRolePools/default", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateMultiRolePool handles the response to the UpdateMultiRolePool request. The method always -// closes the http.Response Body. -func (c AppServiceEnvironmentsClient) responderForUpdateMultiRolePool(resp *http.Response) (result UpdateMultiRolePoolOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_updateworkerpool.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_updateworkerpool.go new file mode 100644 index 00000000000..1dd35b59912 --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceenvironments/method_updateworkerpool.go @@ -0,0 +1,56 @@ +package appserviceenvironments + +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 UpdateWorkerPoolOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkerPoolResource +} + +// UpdateWorkerPool ... +func (c AppServiceEnvironmentsClient) UpdateWorkerPool(ctx context.Context, id WorkerPoolId, input WorkerPoolResource) (result UpdateWorkerPoolOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + 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 +} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_updateworkerpool_autorest.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_updateworkerpool_autorest.go deleted file mode 100644 index 6c3e3d253e2..00000000000 --- a/resource-manager/web/2022-09-01/appserviceenvironments/method_updateworkerpool_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package appserviceenvironments - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateWorkerPoolOperationResponse struct { - HttpResponse *http.Response - Model *WorkerPoolResource -} - -// UpdateWorkerPool ... -func (c AppServiceEnvironmentsClient) UpdateWorkerPool(ctx context.Context, id WorkerPoolId, input WorkerPoolResource) (result UpdateWorkerPoolOperationResponse, err error) { - req, err := c.preparerForUpdateWorkerPool(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "UpdateWorkerPool", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "UpdateWorkerPool", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateWorkerPool(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "UpdateWorkerPool", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateWorkerPool prepares the UpdateWorkerPool request. -func (c AppServiceEnvironmentsClient) preparerForUpdateWorkerPool(ctx context.Context, id WorkerPoolId, input WorkerPoolResource) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateWorkerPool handles the response to the UpdateWorkerPool request. The method always -// closes the http.Response Body. -func (c AppServiceEnvironmentsClient) responderForUpdateWorkerPool(resp *http.Response) (result UpdateWorkerPoolOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_upgrade.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_upgrade.go new file mode 100644 index 00000000000..adacca06a3e --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceenvironments/method_upgrade.go @@ -0,0 +1,69 @@ +package appserviceenvironments + +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 UpgradeOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Upgrade ... +func (c AppServiceEnvironmentsClient) Upgrade(ctx context.Context, id HostingEnvironmentId) (result UpgradeOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/upgrade", 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 +} + +// UpgradeThenPoll performs Upgrade then polls until it's completed +func (c AppServiceEnvironmentsClient) UpgradeThenPoll(ctx context.Context, id HostingEnvironmentId) error { + result, err := c.Upgrade(ctx, id) + if err != nil { + return fmt.Errorf("performing Upgrade: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Upgrade: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/appserviceenvironments/method_upgrade_autorest.go b/resource-manager/web/2022-09-01/appserviceenvironments/method_upgrade_autorest.go deleted file mode 100644 index f2f4bc10d5a..00000000000 --- a/resource-manager/web/2022-09-01/appserviceenvironments/method_upgrade_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package appserviceenvironments - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpgradeOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Upgrade ... -func (c AppServiceEnvironmentsClient) Upgrade(ctx context.Context, id HostingEnvironmentId) (result UpgradeOperationResponse, err error) { - req, err := c.preparerForUpgrade(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "Upgrade", nil, "Failure preparing request") - return - } - - result, err = c.senderForUpgrade(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceenvironments.AppServiceEnvironmentsClient", "Upgrade", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// UpgradeThenPoll performs Upgrade then polls until it's completed -func (c AppServiceEnvironmentsClient) UpgradeThenPoll(ctx context.Context, id HostingEnvironmentId) error { - result, err := c.Upgrade(ctx, id) - if err != nil { - return fmt.Errorf("performing Upgrade: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Upgrade: %+v", err) - } - - return nil -} - -// preparerForUpgrade prepares the Upgrade request. -func (c AppServiceEnvironmentsClient) preparerForUpgrade(ctx context.Context, id HostingEnvironmentId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/upgrade", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForUpgrade sends the Upgrade request. The method will close the -// http.Response Body if it receives an error. -func (c AppServiceEnvironmentsClient) senderForUpgrade(ctx context.Context, req *http.Request) (future UpgradeOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/appserviceplans/client.go b/resource-manager/web/2022-09-01/appserviceplans/client.go index 560da62c44c..16725b30193 100644 --- a/resource-manager/web/2022-09-01/appserviceplans/client.go +++ b/resource-manager/web/2022-09-01/appserviceplans/client.go @@ -1,18 +1,26 @@ package appserviceplans -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 AppServicePlansClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewAppServicePlansClientWithBaseURI(endpoint string) AppServicePlansClient { - return AppServicePlansClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewAppServicePlansClientWithBaseURI(api environments.Api) (*AppServicePlansClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "appserviceplans", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AppServicePlansClient: %+v", err) } + + return &AppServicePlansClient{ + Client: client, + }, nil } diff --git a/resource-manager/web/2022-09-01/appserviceplans/constants.go b/resource-manager/web/2022-09-01/appserviceplans/constants.go index deb24dee64a..7325fcfa762 100644 --- a/resource-manager/web/2022-09-01/appserviceplans/constants.go +++ b/resource-manager/web/2022-09-01/appserviceplans/constants.go @@ -1,6 +1,10 @@ package appserviceplans -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. @@ -21,6 +25,19 @@ func PossibleValuesForAutoHealActionType() []string { } } +func (s *AutoHealActionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutoHealActionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAutoHealActionType(input string) (*AutoHealActionType, error) { vals := map[string]AutoHealActionType{ "customaction": AutoHealActionTypeCustomAction, @@ -54,6 +71,19 @@ func PossibleValuesForAzureStorageState() []string { } } +func (s *AzureStorageState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureStorageState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAzureStorageState(input string) (*AzureStorageState, error) { vals := map[string]AzureStorageState{ "invalidcredentials": AzureStorageStateInvalidCredentials, @@ -84,6 +114,19 @@ func PossibleValuesForAzureStorageType() []string { } } +func (s *AzureStorageType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureStorageType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAzureStorageType(input string) (*AzureStorageType, error) { vals := map[string]AzureStorageType{ "azureblob": AzureStorageTypeAzureBlob, @@ -114,6 +157,19 @@ func PossibleValuesForClientCertMode() []string { } } +func (s *ClientCertMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClientCertMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseClientCertMode(input string) (*ClientCertMode, error) { vals := map[string]ClientCertMode{ "optional": ClientCertModeOptional, @@ -161,6 +217,19 @@ func PossibleValuesForConnectionStringType() []string { } } +func (s *ConnectionStringType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConnectionStringType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseConnectionStringType(input string) (*ConnectionStringType, error) { vals := map[string]ConnectionStringType{ "apihub": ConnectionStringTypeApiHub, @@ -198,6 +267,19 @@ func PossibleValuesForDefaultAction() []string { } } +func (s *DefaultAction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDefaultAction(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseDefaultAction(input string) (*DefaultAction, error) { vals := map[string]DefaultAction{ "allow": DefaultActionAllow, @@ -228,6 +310,19 @@ func PossibleValuesForFtpsState() []string { } } +func (s *FtpsState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFtpsState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseFtpsState(input string) (*FtpsState, error) { vals := map[string]FtpsState{ "allallowed": FtpsStateAllAllowed, @@ -257,6 +352,19 @@ func PossibleValuesForHostType() []string { } } +func (s *HostType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHostType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseHostType(input string) (*HostType, error) { vals := map[string]HostType{ "repository": HostTypeRepository, @@ -287,6 +395,19 @@ func PossibleValuesForIPFilterTag() []string { } } +func (s *IPFilterTag) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPFilterTag(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseIPFilterTag(input string) (*IPFilterTag, error) { vals := map[string]IPFilterTag{ "default": IPFilterTagDefault, @@ -316,6 +437,19 @@ func PossibleValuesForManagedPipelineMode() []string { } } +func (s *ManagedPipelineMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedPipelineMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseManagedPipelineMode(input string) (*ManagedPipelineMode, error) { vals := map[string]ManagedPipelineMode{ "classic": ManagedPipelineModeClassic, @@ -350,6 +484,19 @@ func PossibleValuesForProvisioningState() []string { } } +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseProvisioningState(input string) (*ProvisioningState, error) { vals := map[string]ProvisioningState{ "canceled": ProvisioningStateCanceled, @@ -387,6 +534,19 @@ func PossibleValuesForRedundancyMode() []string { } } +func (s *RedundancyMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRedundancyMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseRedundancyMode(input string) (*RedundancyMode, error) { vals := map[string]RedundancyMode{ "activeactive": RedundancyModeActiveActive, @@ -420,6 +580,19 @@ func PossibleValuesForRouteType() []string { } } +func (s *RouteType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRouteType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseRouteType(input string) (*RouteType, error) { vals := map[string]RouteType{ "default": RouteTypeDefault, @@ -473,6 +646,19 @@ func PossibleValuesForScmType() []string { } } +func (s *ScmType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseScmType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseScmType(input string) (*ScmType, error) { vals := map[string]ScmType{ "bitbucketgit": ScmTypeBitbucketGit, @@ -515,6 +701,19 @@ func PossibleValuesForSiteAvailabilityState() []string { } } +func (s *SiteAvailabilityState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSiteAvailabilityState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseSiteAvailabilityState(input string) (*SiteAvailabilityState, error) { vals := map[string]SiteAvailabilityState{ "disasterrecoverymode": SiteAvailabilityStateDisasterRecoveryMode, @@ -552,6 +751,19 @@ func PossibleValuesForSiteLoadBalancing() []string { } } +func (s *SiteLoadBalancing) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSiteLoadBalancing(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseSiteLoadBalancing(input string) (*SiteLoadBalancing, error) { vals := map[string]SiteLoadBalancing{ "leastrequests": SiteLoadBalancingLeastRequests, @@ -586,6 +798,19 @@ func PossibleValuesForSslState() []string { } } +func (s *SslState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSslState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseSslState(input string) (*SslState, error) { vals := map[string]SslState{ "disabled": SslStateDisabled, @@ -617,6 +842,19 @@ func PossibleValuesForStatusOptions() []string { } } +func (s *StatusOptions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStatusOptions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseStatusOptions(input string) (*StatusOptions, error) { vals := map[string]StatusOptions{ "creating": StatusOptionsCreating, @@ -648,6 +886,19 @@ func PossibleValuesForSupportedTlsVersions() []string { } } +func (s *SupportedTlsVersions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSupportedTlsVersions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseSupportedTlsVersions(input string) (*SupportedTlsVersions, error) { vals := map[string]SupportedTlsVersions{ "1.1": SupportedTlsVersionsOnePointOne, @@ -677,6 +928,19 @@ func PossibleValuesForUsageState() []string { } } +func (s *UsageState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUsageState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseUsageState(input string) (*UsageState, error) { vals := map[string]UsageState{ "exceeded": UsageStateExceeded, diff --git a/resource-manager/web/2022-09-01/appserviceplans/method_createorupdate.go b/resource-manager/web/2022-09-01/appserviceplans/method_createorupdate.go new file mode 100644 index 00000000000..8bcca273b7f --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceplans/method_createorupdate.go @@ -0,0 +1,74 @@ +package appserviceplans + +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 +} + +// CreateOrUpdate ... +func (c AppServicePlansClient) CreateOrUpdate(ctx context.Context, id ServerFarmId, input AppServicePlan) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 AppServicePlansClient) CreateOrUpdateThenPoll(ctx context.Context, id ServerFarmId, input AppServicePlan) 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 +} diff --git a/resource-manager/web/2022-09-01/appserviceplans/method_createorupdate_autorest.go b/resource-manager/web/2022-09-01/appserviceplans/method_createorupdate_autorest.go deleted file mode 100644 index 603cd7dbf63..00000000000 --- a/resource-manager/web/2022-09-01/appserviceplans/method_createorupdate_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package appserviceplans - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateOrUpdate ... -func (c AppServicePlansClient) CreateOrUpdate(ctx context.Context, id ServerFarmId, input AppServicePlan) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c AppServicePlansClient) CreateOrUpdateThenPoll(ctx context.Context, id ServerFarmId, input AppServicePlan) error { - result, err := c.CreateOrUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateOrUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateOrUpdate: %+v", err) - } - - return nil -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c AppServicePlansClient) preparerForCreateOrUpdate(ctx context.Context, id ServerFarmId, input AppServicePlan) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateOrUpdate sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c AppServicePlansClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/appserviceplans/method_createorupdatevnetroute.go b/resource-manager/web/2022-09-01/appserviceplans/method_createorupdatevnetroute.go new file mode 100644 index 00000000000..39e4eddcb96 --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceplans/method_createorupdatevnetroute.go @@ -0,0 +1,55 @@ +package appserviceplans + +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 CreateOrUpdateVnetRouteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetRoute +} + +// CreateOrUpdateVnetRoute ... +func (c AppServicePlansClient) CreateOrUpdateVnetRoute(ctx context.Context, id RouteId, input VnetRoute) (result CreateOrUpdateVnetRouteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 +} diff --git a/resource-manager/web/2022-09-01/appserviceplans/method_createorupdatevnetroute_autorest.go b/resource-manager/web/2022-09-01/appserviceplans/method_createorupdatevnetroute_autorest.go deleted file mode 100644 index 1151676bd82..00000000000 --- a/resource-manager/web/2022-09-01/appserviceplans/method_createorupdatevnetroute_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package appserviceplans - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateVnetRouteOperationResponse struct { - HttpResponse *http.Response - Model *VnetRoute -} - -// CreateOrUpdateVnetRoute ... -func (c AppServicePlansClient) CreateOrUpdateVnetRoute(ctx context.Context, id RouteId, input VnetRoute) (result CreateOrUpdateVnetRouteOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdateVnetRoute(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "CreateOrUpdateVnetRoute", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "CreateOrUpdateVnetRoute", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdateVnetRoute(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "CreateOrUpdateVnetRoute", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdateVnetRoute prepares the CreateOrUpdateVnetRoute request. -func (c AppServicePlansClient) preparerForCreateOrUpdateVnetRoute(ctx context.Context, id RouteId, input VnetRoute) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateOrUpdateVnetRoute handles the response to the CreateOrUpdateVnetRoute request. The method always -// closes the http.Response Body. -func (c AppServicePlansClient) responderForCreateOrUpdateVnetRoute(resp *http.Response) (result CreateOrUpdateVnetRouteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/appserviceplans/method_delete.go b/resource-manager/web/2022-09-01/appserviceplans/method_delete.go new file mode 100644 index 00000000000..6778f1e7ffe --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceplans/method_delete.go @@ -0,0 +1,47 @@ +package appserviceplans + +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 +} + +// Delete ... +func (c AppServicePlansClient) Delete(ctx context.Context, id ServerFarmId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/appserviceplans/method_delete_autorest.go b/resource-manager/web/2022-09-01/appserviceplans/method_delete_autorest.go deleted file mode 100644 index 95dd366981f..00000000000 --- a/resource-manager/web/2022-09-01/appserviceplans/method_delete_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package appserviceplans - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// 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 -} - -// Delete ... -func (c AppServicePlansClient) Delete(ctx context.Context, id ServerFarmId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c AppServicePlansClient) preparerForDelete(ctx context.Context, id ServerFarmId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c AppServicePlansClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/appserviceplans/method_deletehybridconnection.go b/resource-manager/web/2022-09-01/appserviceplans/method_deletehybridconnection.go new file mode 100644 index 00000000000..edb791bd1dd --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceplans/method_deletehybridconnection.go @@ -0,0 +1,47 @@ +package appserviceplans + +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 DeleteHybridConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteHybridConnection ... +func (c AppServicePlansClient) DeleteHybridConnection(ctx context.Context, id HybridConnectionNamespaceRelayId) (result DeleteHybridConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/appserviceplans/method_deletehybridconnection_autorest.go b/resource-manager/web/2022-09-01/appserviceplans/method_deletehybridconnection_autorest.go deleted file mode 100644 index 257b3796256..00000000000 --- a/resource-manager/web/2022-09-01/appserviceplans/method_deletehybridconnection_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package appserviceplans - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteHybridConnectionOperationResponse struct { - HttpResponse *http.Response -} - -// DeleteHybridConnection ... -func (c AppServicePlansClient) DeleteHybridConnection(ctx context.Context, id HybridConnectionNamespaceRelayId) (result DeleteHybridConnectionOperationResponse, err error) { - req, err := c.preparerForDeleteHybridConnection(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "DeleteHybridConnection", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "DeleteHybridConnection", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeleteHybridConnection(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "DeleteHybridConnection", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeleteHybridConnection prepares the DeleteHybridConnection request. -func (c AppServicePlansClient) preparerForDeleteHybridConnection(ctx context.Context, id HybridConnectionNamespaceRelayId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeleteHybridConnection handles the response to the DeleteHybridConnection request. The method always -// closes the http.Response Body. -func (c AppServicePlansClient) responderForDeleteHybridConnection(resp *http.Response) (result DeleteHybridConnectionOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/appserviceplans/method_deletevnetroute.go b/resource-manager/web/2022-09-01/appserviceplans/method_deletevnetroute.go new file mode 100644 index 00000000000..2961596d499 --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceplans/method_deletevnetroute.go @@ -0,0 +1,46 @@ +package appserviceplans + +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 DeleteVnetRouteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteVnetRoute ... +func (c AppServicePlansClient) DeleteVnetRoute(ctx context.Context, id RouteId) (result DeleteVnetRouteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/appserviceplans/method_deletevnetroute_autorest.go b/resource-manager/web/2022-09-01/appserviceplans/method_deletevnetroute_autorest.go deleted file mode 100644 index 4a05b3effc5..00000000000 --- a/resource-manager/web/2022-09-01/appserviceplans/method_deletevnetroute_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package appserviceplans - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteVnetRouteOperationResponse struct { - HttpResponse *http.Response -} - -// DeleteVnetRoute ... -func (c AppServicePlansClient) DeleteVnetRoute(ctx context.Context, id RouteId) (result DeleteVnetRouteOperationResponse, err error) { - req, err := c.preparerForDeleteVnetRoute(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "DeleteVnetRoute", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "DeleteVnetRoute", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeleteVnetRoute(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "DeleteVnetRoute", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeleteVnetRoute prepares the DeleteVnetRoute request. -func (c AppServicePlansClient) preparerForDeleteVnetRoute(ctx context.Context, id RouteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeleteVnetRoute handles the response to the DeleteVnetRoute request. The method always -// closes the http.Response Body. -func (c AppServicePlansClient) responderForDeleteVnetRoute(resp *http.Response) (result DeleteVnetRouteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/appserviceplans/method_get.go b/resource-manager/web/2022-09-01/appserviceplans/method_get.go new file mode 100644 index 00000000000..e4d01553948 --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceplans/method_get.go @@ -0,0 +1,51 @@ +package appserviceplans + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AppServicePlan +} + +// Get ... +func (c AppServicePlansClient) Get(ctx context.Context, id ServerFarmId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/appserviceplans/method_get_autorest.go b/resource-manager/web/2022-09-01/appserviceplans/method_get_autorest.go deleted file mode 100644 index dcd2e6b16b4..00000000000 --- a/resource-manager/web/2022-09-01/appserviceplans/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package appserviceplans - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *AppServicePlan -} - -// Get ... -func (c AppServicePlansClient) Get(ctx context.Context, id ServerFarmId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c AppServicePlansClient) preparerForGet(ctx context.Context, id ServerFarmId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c AppServicePlansClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/appserviceplans/method_gethybridconnection.go b/resource-manager/web/2022-09-01/appserviceplans/method_gethybridconnection.go new file mode 100644 index 00000000000..ae40e005dea --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceplans/method_gethybridconnection.go @@ -0,0 +1,51 @@ +package appserviceplans + +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 GetHybridConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HybridConnection +} + +// GetHybridConnection ... +func (c AppServicePlansClient) GetHybridConnection(ctx context.Context, id HybridConnectionNamespaceRelayId) (result GetHybridConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/appserviceplans/method_gethybridconnection_autorest.go b/resource-manager/web/2022-09-01/appserviceplans/method_gethybridconnection_autorest.go deleted file mode 100644 index 01151e7d20a..00000000000 --- a/resource-manager/web/2022-09-01/appserviceplans/method_gethybridconnection_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package appserviceplans - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetHybridConnectionOperationResponse struct { - HttpResponse *http.Response - Model *HybridConnection -} - -// GetHybridConnection ... -func (c AppServicePlansClient) GetHybridConnection(ctx context.Context, id HybridConnectionNamespaceRelayId) (result GetHybridConnectionOperationResponse, err error) { - req, err := c.preparerForGetHybridConnection(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "GetHybridConnection", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "GetHybridConnection", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetHybridConnection(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "GetHybridConnection", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetHybridConnection prepares the GetHybridConnection request. -func (c AppServicePlansClient) preparerForGetHybridConnection(ctx context.Context, id HybridConnectionNamespaceRelayId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetHybridConnection handles the response to the GetHybridConnection request. The method always -// closes the http.Response Body. -func (c AppServicePlansClient) responderForGetHybridConnection(resp *http.Response) (result GetHybridConnectionOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/appserviceplans/method_gethybridconnectionplanlimit.go b/resource-manager/web/2022-09-01/appserviceplans/method_gethybridconnectionplanlimit.go new file mode 100644 index 00000000000..102da96c97e --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceplans/method_gethybridconnectionplanlimit.go @@ -0,0 +1,52 @@ +package appserviceplans + +import ( + "context" + "fmt" + "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 GetHybridConnectionPlanLimitOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HybridConnectionLimits +} + +// GetHybridConnectionPlanLimit ... +func (c AppServicePlansClient) GetHybridConnectionPlanLimit(ctx context.Context, id ServerFarmId) (result GetHybridConnectionPlanLimitOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/hybridConnectionPlanLimits/limit", 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 +} diff --git a/resource-manager/web/2022-09-01/appserviceplans/method_gethybridconnectionplanlimit_autorest.go b/resource-manager/web/2022-09-01/appserviceplans/method_gethybridconnectionplanlimit_autorest.go deleted file mode 100644 index 9366801abad..00000000000 --- a/resource-manager/web/2022-09-01/appserviceplans/method_gethybridconnectionplanlimit_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package appserviceplans - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetHybridConnectionPlanLimitOperationResponse struct { - HttpResponse *http.Response - Model *HybridConnectionLimits -} - -// GetHybridConnectionPlanLimit ... -func (c AppServicePlansClient) GetHybridConnectionPlanLimit(ctx context.Context, id ServerFarmId) (result GetHybridConnectionPlanLimitOperationResponse, err error) { - req, err := c.preparerForGetHybridConnectionPlanLimit(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "GetHybridConnectionPlanLimit", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "GetHybridConnectionPlanLimit", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetHybridConnectionPlanLimit(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "GetHybridConnectionPlanLimit", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetHybridConnectionPlanLimit prepares the GetHybridConnectionPlanLimit request. -func (c AppServicePlansClient) preparerForGetHybridConnectionPlanLimit(ctx context.Context, id ServerFarmId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/hybridConnectionPlanLimits/limit", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetHybridConnectionPlanLimit handles the response to the GetHybridConnectionPlanLimit request. The method always -// closes the http.Response Body. -func (c AppServicePlansClient) responderForGetHybridConnectionPlanLimit(resp *http.Response) (result GetHybridConnectionPlanLimitOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/appserviceplans/method_getrouteforvnet.go b/resource-manager/web/2022-09-01/appserviceplans/method_getrouteforvnet.go new file mode 100644 index 00000000000..51c8fdcd829 --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceplans/method_getrouteforvnet.go @@ -0,0 +1,51 @@ +package appserviceplans + +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 GetRouteForVnetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VnetRoute +} + +// GetRouteForVnet ... +func (c AppServicePlansClient) GetRouteForVnet(ctx context.Context, id RouteId) (result GetRouteForVnetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/appserviceplans/method_getrouteforvnet_autorest.go b/resource-manager/web/2022-09-01/appserviceplans/method_getrouteforvnet_autorest.go deleted file mode 100644 index 39ef1299971..00000000000 --- a/resource-manager/web/2022-09-01/appserviceplans/method_getrouteforvnet_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package appserviceplans - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetRouteForVnetOperationResponse struct { - HttpResponse *http.Response - Model *[]VnetRoute -} - -// GetRouteForVnet ... -func (c AppServicePlansClient) GetRouteForVnet(ctx context.Context, id RouteId) (result GetRouteForVnetOperationResponse, err error) { - req, err := c.preparerForGetRouteForVnet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "GetRouteForVnet", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "GetRouteForVnet", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetRouteForVnet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "GetRouteForVnet", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetRouteForVnet prepares the GetRouteForVnet request. -func (c AppServicePlansClient) preparerForGetRouteForVnet(ctx context.Context, id RouteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetRouteForVnet handles the response to the GetRouteForVnet request. The method always -// closes the http.Response Body. -func (c AppServicePlansClient) responderForGetRouteForVnet(resp *http.Response) (result GetRouteForVnetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/appserviceplans/method_getserverfarmskus.go b/resource-manager/web/2022-09-01/appserviceplans/method_getserverfarmskus.go new file mode 100644 index 00000000000..1c97e17f759 --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceplans/method_getserverfarmskus.go @@ -0,0 +1,52 @@ +package appserviceplans + +import ( + "context" + "fmt" + "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 GetServerFarmSkusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *interface{} +} + +// GetServerFarmSkus ... +func (c AppServicePlansClient) GetServerFarmSkus(ctx context.Context, id ServerFarmId) (result GetServerFarmSkusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/skus", 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 +} diff --git a/resource-manager/web/2022-09-01/appserviceplans/method_getserverfarmskus_autorest.go b/resource-manager/web/2022-09-01/appserviceplans/method_getserverfarmskus_autorest.go deleted file mode 100644 index 6e451136baa..00000000000 --- a/resource-manager/web/2022-09-01/appserviceplans/method_getserverfarmskus_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package appserviceplans - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetServerFarmSkusOperationResponse struct { - HttpResponse *http.Response - Model *interface{} -} - -// GetServerFarmSkus ... -func (c AppServicePlansClient) GetServerFarmSkus(ctx context.Context, id ServerFarmId) (result GetServerFarmSkusOperationResponse, err error) { - req, err := c.preparerForGetServerFarmSkus(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "GetServerFarmSkus", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "GetServerFarmSkus", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetServerFarmSkus(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "GetServerFarmSkus", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetServerFarmSkus prepares the GetServerFarmSkus request. -func (c AppServicePlansClient) preparerForGetServerFarmSkus(ctx context.Context, id ServerFarmId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/skus", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetServerFarmSkus handles the response to the GetServerFarmSkus request. The method always -// closes the http.Response Body. -func (c AppServicePlansClient) responderForGetServerFarmSkus(resp *http.Response) (result GetServerFarmSkusOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/appserviceplans/method_getvnetfromserverfarm.go b/resource-manager/web/2022-09-01/appserviceplans/method_getvnetfromserverfarm.go new file mode 100644 index 00000000000..9e43acb5137 --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceplans/method_getvnetfromserverfarm.go @@ -0,0 +1,51 @@ +package appserviceplans + +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 GetVnetFromServerFarmOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetInfoResource +} + +// GetVnetFromServerFarm ... +func (c AppServicePlansClient) GetVnetFromServerFarm(ctx context.Context, id ServerFarmVirtualNetworkConnectionId) (result GetVnetFromServerFarmOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/appserviceplans/method_getvnetfromserverfarm_autorest.go b/resource-manager/web/2022-09-01/appserviceplans/method_getvnetfromserverfarm_autorest.go deleted file mode 100644 index 2c085af30fc..00000000000 --- a/resource-manager/web/2022-09-01/appserviceplans/method_getvnetfromserverfarm_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package appserviceplans - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetVnetFromServerFarmOperationResponse struct { - HttpResponse *http.Response - Model *VnetInfoResource -} - -// GetVnetFromServerFarm ... -func (c AppServicePlansClient) GetVnetFromServerFarm(ctx context.Context, id ServerFarmVirtualNetworkConnectionId) (result GetVnetFromServerFarmOperationResponse, err error) { - req, err := c.preparerForGetVnetFromServerFarm(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "GetVnetFromServerFarm", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "GetVnetFromServerFarm", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetVnetFromServerFarm(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "GetVnetFromServerFarm", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetVnetFromServerFarm prepares the GetVnetFromServerFarm request. -func (c AppServicePlansClient) preparerForGetVnetFromServerFarm(ctx context.Context, id ServerFarmVirtualNetworkConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetVnetFromServerFarm handles the response to the GetVnetFromServerFarm request. The method always -// closes the http.Response Body. -func (c AppServicePlansClient) responderForGetVnetFromServerFarm(resp *http.Response) (result GetVnetFromServerFarmOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/appserviceplans/method_getvnetgateway.go b/resource-manager/web/2022-09-01/appserviceplans/method_getvnetgateway.go new file mode 100644 index 00000000000..839f478eb0d --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceplans/method_getvnetgateway.go @@ -0,0 +1,51 @@ +package appserviceplans + +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 GetVnetGatewayOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetGateway +} + +// GetVnetGateway ... +func (c AppServicePlansClient) GetVnetGateway(ctx context.Context, id VirtualNetworkConnectionGatewayId) (result GetVnetGatewayOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/appserviceplans/method_getvnetgateway_autorest.go b/resource-manager/web/2022-09-01/appserviceplans/method_getvnetgateway_autorest.go deleted file mode 100644 index cd3de68e1fc..00000000000 --- a/resource-manager/web/2022-09-01/appserviceplans/method_getvnetgateway_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package appserviceplans - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetVnetGatewayOperationResponse struct { - HttpResponse *http.Response - Model *VnetGateway -} - -// GetVnetGateway ... -func (c AppServicePlansClient) GetVnetGateway(ctx context.Context, id VirtualNetworkConnectionGatewayId) (result GetVnetGatewayOperationResponse, err error) { - req, err := c.preparerForGetVnetGateway(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "GetVnetGateway", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "GetVnetGateway", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetVnetGateway(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "GetVnetGateway", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetVnetGateway prepares the GetVnetGateway request. -func (c AppServicePlansClient) preparerForGetVnetGateway(ctx context.Context, id VirtualNetworkConnectionGatewayId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetVnetGateway handles the response to the GetVnetGateway request. The method always -// closes the http.Response Body. -func (c AppServicePlansClient) responderForGetVnetGateway(resp *http.Response) (result GetVnetGatewayOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/appserviceplans/method_list.go b/resource-manager/web/2022-09-01/appserviceplans/method_list.go new file mode 100644 index 00000000000..7081cffc7e8 --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceplans/method_list.go @@ -0,0 +1,118 @@ +package appserviceplans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AppServicePlan +} + +type ListCompleteResult struct { + Items []AppServicePlan +} + +type ListOperationOptions struct { + Detailed *bool +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Detailed != nil { + out.Append("detailed", fmt.Sprintf("%v", *o.Detailed)) + } + return &out +} + +// List ... +func (c AppServicePlansClient) List(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/serverFarms", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AppServicePlan `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c AppServicePlansClient) ListComplete(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, AppServicePlanOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServicePlansClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions, predicate AppServicePlanOperationPredicate) (result ListCompleteResult, err error) { + items := make([]AppServicePlan, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/appserviceplans/method_list_autorest.go b/resource-manager/web/2022-09-01/appserviceplans/method_list_autorest.go deleted file mode 100644 index f9f3ee22d35..00000000000 --- a/resource-manager/web/2022-09-01/appserviceplans/method_list_autorest.go +++ /dev/null @@ -1,216 +0,0 @@ -package appserviceplans - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListOperationResponse struct { - HttpResponse *http.Response - Model *[]AppServicePlan - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []AppServicePlan -} - -func (r ListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListOperationOptions struct { - Detailed *bool -} - -func DefaultListOperationOptions() ListOperationOptions { - return ListOperationOptions{} -} - -func (o ListOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Detailed != nil { - out["detailed"] = *o.Detailed - } - - return out -} - -// List ... -func (c AppServicePlansClient) List(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c AppServicePlansClient) preparerForList(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Web/serverFarms", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c AppServicePlansClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForList handles the response to the List request. The method always -// closes the http.Response Body. -func (c AppServicePlansClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []AppServicePlan `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { - req, err := c.preparerForListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c AppServicePlansClient) ListComplete(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, options, AppServicePlanOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c AppServicePlansClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions, predicate AppServicePlanOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]AppServicePlan, 0) - - page, err := c.List(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/appserviceplans/method_listbyresourcegroup.go b/resource-manager/web/2022-09-01/appserviceplans/method_listbyresourcegroup.go new file mode 100644 index 00000000000..872e67a3eb5 --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceplans/method_listbyresourcegroup.go @@ -0,0 +1,90 @@ +package appserviceplans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AppServicePlan +} + +type ListByResourceGroupCompleteResult struct { + Items []AppServicePlan +} + +// ListByResourceGroup ... +func (c AppServicePlansClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/serverFarms", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AppServicePlan `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c AppServicePlansClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, AppServicePlanOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServicePlansClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate AppServicePlanOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]AppServicePlan, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/appserviceplans/method_listbyresourcegroup_autorest.go b/resource-manager/web/2022-09-01/appserviceplans/method_listbyresourcegroup_autorest.go deleted file mode 100644 index 230c2aa0a8a..00000000000 --- a/resource-manager/web/2022-09-01/appserviceplans/method_listbyresourcegroup_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package appserviceplans - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByResourceGroupOperationResponse struct { - HttpResponse *http.Response - Model *[]AppServicePlan - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByResourceGroupOperationResponse, error) -} - -type ListByResourceGroupCompleteResult struct { - Items []AppServicePlan -} - -func (r ListByResourceGroupOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByResourceGroupOperationResponse) LoadMore(ctx context.Context) (resp ListByResourceGroupOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByResourceGroup ... -func (c AppServicePlansClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (resp ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroup(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "ListByResourceGroup", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByResourceGroup(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "ListByResourceGroup", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByResourceGroup prepares the ListByResourceGroup request. -func (c AppServicePlansClient) preparerForListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Web/serverFarms", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByResourceGroupWithNextLink prepares the ListByResourceGroup request with the given nextLink token. -func (c AppServicePlansClient) preparerForListByResourceGroupWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByResourceGroup handles the response to the ListByResourceGroup request. The method always -// closes the http.Response Body. -func (c AppServicePlansClient) responderForListByResourceGroup(resp *http.Response) (result ListByResourceGroupOperationResponse, err error) { - type page struct { - Values []AppServicePlan `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroupWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "ListByResourceGroup", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByResourceGroup(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "ListByResourceGroup", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByResourceGroupComplete retrieves all of the results into a single object -func (c AppServicePlansClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { - return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, AppServicePlanOperationPredicate{}) -} - -// ListByResourceGroupCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c AppServicePlansClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate AppServicePlanOperationPredicate) (resp ListByResourceGroupCompleteResult, err error) { - items := make([]AppServicePlan, 0) - - page, err := c.ListByResourceGroup(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByResourceGroupCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/appserviceplans/method_listcapabilities.go b/resource-manager/web/2022-09-01/appserviceplans/method_listcapabilities.go new file mode 100644 index 00000000000..e4771d4d4c9 --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceplans/method_listcapabilities.go @@ -0,0 +1,52 @@ +package appserviceplans + +import ( + "context" + "fmt" + "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 ListCapabilitiesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Capability +} + +// ListCapabilities ... +func (c AppServicePlansClient) ListCapabilities(ctx context.Context, id ServerFarmId) (result ListCapabilitiesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/capabilities", 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 +} diff --git a/resource-manager/web/2022-09-01/appserviceplans/method_listcapabilities_autorest.go b/resource-manager/web/2022-09-01/appserviceplans/method_listcapabilities_autorest.go deleted file mode 100644 index c9a2d16ea05..00000000000 --- a/resource-manager/web/2022-09-01/appserviceplans/method_listcapabilities_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package appserviceplans - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListCapabilitiesOperationResponse struct { - HttpResponse *http.Response - Model *[]Capability -} - -// ListCapabilities ... -func (c AppServicePlansClient) ListCapabilities(ctx context.Context, id ServerFarmId) (result ListCapabilitiesOperationResponse, err error) { - req, err := c.preparerForListCapabilities(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "ListCapabilities", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "ListCapabilities", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListCapabilities(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "ListCapabilities", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListCapabilities prepares the ListCapabilities request. -func (c AppServicePlansClient) preparerForListCapabilities(ctx context.Context, id ServerFarmId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/capabilities", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListCapabilities handles the response to the ListCapabilities request. The method always -// closes the http.Response Body. -func (c AppServicePlansClient) responderForListCapabilities(resp *http.Response) (result ListCapabilitiesOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/appserviceplans/method_listhybridconnectionkeys.go b/resource-manager/web/2022-09-01/appserviceplans/method_listhybridconnectionkeys.go new file mode 100644 index 00000000000..d9141097bb8 --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceplans/method_listhybridconnectionkeys.go @@ -0,0 +1,52 @@ +package appserviceplans + +import ( + "context" + "fmt" + "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 ListHybridConnectionKeysOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HybridConnectionKey +} + +// ListHybridConnectionKeys ... +func (c AppServicePlansClient) ListHybridConnectionKeys(ctx context.Context, id HybridConnectionNamespaceRelayId) (result ListHybridConnectionKeysOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listKeys", 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 +} diff --git a/resource-manager/web/2022-09-01/appserviceplans/method_listhybridconnectionkeys_autorest.go b/resource-manager/web/2022-09-01/appserviceplans/method_listhybridconnectionkeys_autorest.go deleted file mode 100644 index 79c7c2b89dc..00000000000 --- a/resource-manager/web/2022-09-01/appserviceplans/method_listhybridconnectionkeys_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package appserviceplans - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListHybridConnectionKeysOperationResponse struct { - HttpResponse *http.Response - Model *HybridConnectionKey -} - -// ListHybridConnectionKeys ... -func (c AppServicePlansClient) ListHybridConnectionKeys(ctx context.Context, id HybridConnectionNamespaceRelayId) (result ListHybridConnectionKeysOperationResponse, err error) { - req, err := c.preparerForListHybridConnectionKeys(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "ListHybridConnectionKeys", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "ListHybridConnectionKeys", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListHybridConnectionKeys(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "ListHybridConnectionKeys", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListHybridConnectionKeys prepares the ListHybridConnectionKeys request. -func (c AppServicePlansClient) preparerForListHybridConnectionKeys(ctx context.Context, id HybridConnectionNamespaceRelayId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/listKeys", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListHybridConnectionKeys handles the response to the ListHybridConnectionKeys request. The method always -// closes the http.Response Body. -func (c AppServicePlansClient) responderForListHybridConnectionKeys(resp *http.Response) (result ListHybridConnectionKeysOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/appserviceplans/method_listhybridconnections.go b/resource-manager/web/2022-09-01/appserviceplans/method_listhybridconnections.go new file mode 100644 index 00000000000..4ed58676161 --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceplans/method_listhybridconnections.go @@ -0,0 +1,89 @@ +package appserviceplans + +import ( + "context" + "fmt" + "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 ListHybridConnectionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]HybridConnection +} + +type ListHybridConnectionsCompleteResult struct { + Items []HybridConnection +} + +// ListHybridConnections ... +func (c AppServicePlansClient) ListHybridConnections(ctx context.Context, id ServerFarmId) (result ListHybridConnectionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/hybridConnectionRelays", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]HybridConnection `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListHybridConnectionsComplete retrieves all the results into a single object +func (c AppServicePlansClient) ListHybridConnectionsComplete(ctx context.Context, id ServerFarmId) (ListHybridConnectionsCompleteResult, error) { + return c.ListHybridConnectionsCompleteMatchingPredicate(ctx, id, HybridConnectionOperationPredicate{}) +} + +// ListHybridConnectionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServicePlansClient) ListHybridConnectionsCompleteMatchingPredicate(ctx context.Context, id ServerFarmId, predicate HybridConnectionOperationPredicate) (result ListHybridConnectionsCompleteResult, err error) { + items := make([]HybridConnection, 0) + + resp, err := c.ListHybridConnections(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListHybridConnectionsCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/appserviceplans/method_listhybridconnections_autorest.go b/resource-manager/web/2022-09-01/appserviceplans/method_listhybridconnections_autorest.go deleted file mode 100644 index ba38df82f63..00000000000 --- a/resource-manager/web/2022-09-01/appserviceplans/method_listhybridconnections_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package appserviceplans - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListHybridConnectionsOperationResponse struct { - HttpResponse *http.Response - Model *[]HybridConnection - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListHybridConnectionsOperationResponse, error) -} - -type ListHybridConnectionsCompleteResult struct { - Items []HybridConnection -} - -func (r ListHybridConnectionsOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListHybridConnectionsOperationResponse) LoadMore(ctx context.Context) (resp ListHybridConnectionsOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListHybridConnections ... -func (c AppServicePlansClient) ListHybridConnections(ctx context.Context, id ServerFarmId) (resp ListHybridConnectionsOperationResponse, err error) { - req, err := c.preparerForListHybridConnections(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "ListHybridConnections", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "ListHybridConnections", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListHybridConnections(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "ListHybridConnections", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListHybridConnections prepares the ListHybridConnections request. -func (c AppServicePlansClient) preparerForListHybridConnections(ctx context.Context, id ServerFarmId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/hybridConnectionRelays", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListHybridConnectionsWithNextLink prepares the ListHybridConnections request with the given nextLink token. -func (c AppServicePlansClient) preparerForListHybridConnectionsWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListHybridConnections handles the response to the ListHybridConnections request. The method always -// closes the http.Response Body. -func (c AppServicePlansClient) responderForListHybridConnections(resp *http.Response) (result ListHybridConnectionsOperationResponse, err error) { - type page struct { - Values []HybridConnection `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListHybridConnectionsOperationResponse, err error) { - req, err := c.preparerForListHybridConnectionsWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "ListHybridConnections", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "ListHybridConnections", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListHybridConnections(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "ListHybridConnections", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListHybridConnectionsComplete retrieves all of the results into a single object -func (c AppServicePlansClient) ListHybridConnectionsComplete(ctx context.Context, id ServerFarmId) (ListHybridConnectionsCompleteResult, error) { - return c.ListHybridConnectionsCompleteMatchingPredicate(ctx, id, HybridConnectionOperationPredicate{}) -} - -// ListHybridConnectionsCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c AppServicePlansClient) ListHybridConnectionsCompleteMatchingPredicate(ctx context.Context, id ServerFarmId, predicate HybridConnectionOperationPredicate) (resp ListHybridConnectionsCompleteResult, err error) { - items := make([]HybridConnection, 0) - - page, err := c.ListHybridConnections(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListHybridConnectionsCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/appserviceplans/method_listroutesforvnet.go b/resource-manager/web/2022-09-01/appserviceplans/method_listroutesforvnet.go new file mode 100644 index 00000000000..6053cbb866b --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceplans/method_listroutesforvnet.go @@ -0,0 +1,52 @@ +package appserviceplans + +import ( + "context" + "fmt" + "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 ListRoutesForVnetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VnetRoute +} + +// ListRoutesForVnet ... +func (c AppServicePlansClient) ListRoutesForVnet(ctx context.Context, id ServerFarmVirtualNetworkConnectionId) (result ListRoutesForVnetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/routes", 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 +} diff --git a/resource-manager/web/2022-09-01/appserviceplans/method_listroutesforvnet_autorest.go b/resource-manager/web/2022-09-01/appserviceplans/method_listroutesforvnet_autorest.go deleted file mode 100644 index 8549629b520..00000000000 --- a/resource-manager/web/2022-09-01/appserviceplans/method_listroutesforvnet_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package appserviceplans - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListRoutesForVnetOperationResponse struct { - HttpResponse *http.Response - Model *[]VnetRoute -} - -// ListRoutesForVnet ... -func (c AppServicePlansClient) ListRoutesForVnet(ctx context.Context, id ServerFarmVirtualNetworkConnectionId) (result ListRoutesForVnetOperationResponse, err error) { - req, err := c.preparerForListRoutesForVnet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "ListRoutesForVnet", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "ListRoutesForVnet", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListRoutesForVnet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "ListRoutesForVnet", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListRoutesForVnet prepares the ListRoutesForVnet request. -func (c AppServicePlansClient) preparerForListRoutesForVnet(ctx context.Context, id ServerFarmVirtualNetworkConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/routes", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListRoutesForVnet handles the response to the ListRoutesForVnet request. The method always -// closes the http.Response Body. -func (c AppServicePlansClient) responderForListRoutesForVnet(resp *http.Response) (result ListRoutesForVnetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/appserviceplans/method_listusages.go b/resource-manager/web/2022-09-01/appserviceplans/method_listusages.go new file mode 100644 index 00000000000..6c2fcf059b7 --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceplans/method_listusages.go @@ -0,0 +1,117 @@ +package appserviceplans + +import ( + "context" + "fmt" + "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 ListUsagesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CsmUsageQuota +} + +type ListUsagesCompleteResult struct { + Items []CsmUsageQuota +} + +type ListUsagesOperationOptions struct { + Filter *string +} + +func DefaultListUsagesOperationOptions() ListUsagesOperationOptions { + return ListUsagesOperationOptions{} +} + +func (o ListUsagesOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListUsagesOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListUsagesOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +// ListUsages ... +func (c AppServicePlansClient) ListUsages(ctx context.Context, id ServerFarmId, options ListUsagesOperationOptions) (result ListUsagesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/usages", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]CsmUsageQuota `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListUsagesComplete retrieves all the results into a single object +func (c AppServicePlansClient) ListUsagesComplete(ctx context.Context, id ServerFarmId, options ListUsagesOperationOptions) (ListUsagesCompleteResult, error) { + return c.ListUsagesCompleteMatchingPredicate(ctx, id, options, CsmUsageQuotaOperationPredicate{}) +} + +// ListUsagesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServicePlansClient) ListUsagesCompleteMatchingPredicate(ctx context.Context, id ServerFarmId, options ListUsagesOperationOptions, predicate CsmUsageQuotaOperationPredicate) (result ListUsagesCompleteResult, err error) { + items := make([]CsmUsageQuota, 0) + + resp, err := c.ListUsages(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListUsagesCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/appserviceplans/method_listusages_autorest.go b/resource-manager/web/2022-09-01/appserviceplans/method_listusages_autorest.go deleted file mode 100644 index c79c9aebad0..00000000000 --- a/resource-manager/web/2022-09-01/appserviceplans/method_listusages_autorest.go +++ /dev/null @@ -1,215 +0,0 @@ -package appserviceplans - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListUsagesOperationResponse struct { - HttpResponse *http.Response - Model *[]CsmUsageQuota - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListUsagesOperationResponse, error) -} - -type ListUsagesCompleteResult struct { - Items []CsmUsageQuota -} - -func (r ListUsagesOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListUsagesOperationResponse) LoadMore(ctx context.Context) (resp ListUsagesOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListUsagesOperationOptions struct { - Filter *string -} - -func DefaultListUsagesOperationOptions() ListUsagesOperationOptions { - return ListUsagesOperationOptions{} -} - -func (o ListUsagesOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListUsagesOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - return out -} - -// ListUsages ... -func (c AppServicePlansClient) ListUsages(ctx context.Context, id ServerFarmId, options ListUsagesOperationOptions) (resp ListUsagesOperationResponse, err error) { - req, err := c.preparerForListUsages(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "ListUsages", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "ListUsages", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListUsages(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "ListUsages", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListUsages prepares the ListUsages request. -func (c AppServicePlansClient) preparerForListUsages(ctx context.Context, id ServerFarmId, options ListUsagesOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/usages", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListUsagesWithNextLink prepares the ListUsages request with the given nextLink token. -func (c AppServicePlansClient) preparerForListUsagesWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListUsages handles the response to the ListUsages request. The method always -// closes the http.Response Body. -func (c AppServicePlansClient) responderForListUsages(resp *http.Response) (result ListUsagesOperationResponse, err error) { - type page struct { - Values []CsmUsageQuota `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListUsagesOperationResponse, err error) { - req, err := c.preparerForListUsagesWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "ListUsages", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "ListUsages", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListUsages(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "ListUsages", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListUsagesComplete retrieves all of the results into a single object -func (c AppServicePlansClient) ListUsagesComplete(ctx context.Context, id ServerFarmId, options ListUsagesOperationOptions) (ListUsagesCompleteResult, error) { - return c.ListUsagesCompleteMatchingPredicate(ctx, id, options, CsmUsageQuotaOperationPredicate{}) -} - -// ListUsagesCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c AppServicePlansClient) ListUsagesCompleteMatchingPredicate(ctx context.Context, id ServerFarmId, options ListUsagesOperationOptions, predicate CsmUsageQuotaOperationPredicate) (resp ListUsagesCompleteResult, err error) { - items := make([]CsmUsageQuota, 0) - - page, err := c.ListUsages(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListUsagesCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/appserviceplans/method_listvnets.go b/resource-manager/web/2022-09-01/appserviceplans/method_listvnets.go new file mode 100644 index 00000000000..78e06efdc63 --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceplans/method_listvnets.go @@ -0,0 +1,52 @@ +package appserviceplans + +import ( + "context" + "fmt" + "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 ListVnetsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VnetInfoResource +} + +// ListVnets ... +func (c AppServicePlansClient) ListVnets(ctx context.Context, id ServerFarmId) (result ListVnetsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/virtualNetworkConnections", 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 +} diff --git a/resource-manager/web/2022-09-01/appserviceplans/method_listvnets_autorest.go b/resource-manager/web/2022-09-01/appserviceplans/method_listvnets_autorest.go deleted file mode 100644 index 7ff8dc8e26c..00000000000 --- a/resource-manager/web/2022-09-01/appserviceplans/method_listvnets_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package appserviceplans - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListVnetsOperationResponse struct { - HttpResponse *http.Response - Model *[]VnetInfoResource -} - -// ListVnets ... -func (c AppServicePlansClient) ListVnets(ctx context.Context, id ServerFarmId) (result ListVnetsOperationResponse, err error) { - req, err := c.preparerForListVnets(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "ListVnets", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "ListVnets", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListVnets(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "ListVnets", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListVnets prepares the ListVnets request. -func (c AppServicePlansClient) preparerForListVnets(ctx context.Context, id ServerFarmId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/virtualNetworkConnections", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListVnets handles the response to the ListVnets request. The method always -// closes the http.Response Body. -func (c AppServicePlansClient) responderForListVnets(resp *http.Response) (result ListVnetsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/appserviceplans/method_listwebapps.go b/resource-manager/web/2022-09-01/appserviceplans/method_listwebapps.go new file mode 100644 index 00000000000..a8ead2a851f --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceplans/method_listwebapps.go @@ -0,0 +1,121 @@ +package appserviceplans + +import ( + "context" + "fmt" + "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 ListWebAppsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Site +} + +type ListWebAppsCompleteResult struct { + Items []Site +} + +type ListWebAppsOperationOptions struct { + Filter *string + Top *string +} + +func DefaultListWebAppsOperationOptions() ListWebAppsOperationOptions { + return ListWebAppsOperationOptions{} +} + +func (o ListWebAppsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListWebAppsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListWebAppsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListWebApps ... +func (c AppServicePlansClient) ListWebApps(ctx context.Context, id ServerFarmId, options ListWebAppsOperationOptions) (result ListWebAppsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/sites", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Site `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListWebAppsComplete retrieves all the results into a single object +func (c AppServicePlansClient) ListWebAppsComplete(ctx context.Context, id ServerFarmId, options ListWebAppsOperationOptions) (ListWebAppsCompleteResult, error) { + return c.ListWebAppsCompleteMatchingPredicate(ctx, id, options, SiteOperationPredicate{}) +} + +// ListWebAppsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServicePlansClient) ListWebAppsCompleteMatchingPredicate(ctx context.Context, id ServerFarmId, options ListWebAppsOperationOptions, predicate SiteOperationPredicate) (result ListWebAppsCompleteResult, err error) { + items := make([]Site, 0) + + resp, err := c.ListWebApps(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListWebAppsCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/appserviceplans/method_listwebapps_autorest.go b/resource-manager/web/2022-09-01/appserviceplans/method_listwebapps_autorest.go deleted file mode 100644 index 1cd6cd9466d..00000000000 --- a/resource-manager/web/2022-09-01/appserviceplans/method_listwebapps_autorest.go +++ /dev/null @@ -1,220 +0,0 @@ -package appserviceplans - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListWebAppsOperationResponse struct { - HttpResponse *http.Response - Model *[]Site - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListWebAppsOperationResponse, error) -} - -type ListWebAppsCompleteResult struct { - Items []Site -} - -func (r ListWebAppsOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListWebAppsOperationResponse) LoadMore(ctx context.Context) (resp ListWebAppsOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListWebAppsOperationOptions struct { - Filter *string - Top *string -} - -func DefaultListWebAppsOperationOptions() ListWebAppsOperationOptions { - return ListWebAppsOperationOptions{} -} - -func (o ListWebAppsOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListWebAppsOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// ListWebApps ... -func (c AppServicePlansClient) ListWebApps(ctx context.Context, id ServerFarmId, options ListWebAppsOperationOptions) (resp ListWebAppsOperationResponse, err error) { - req, err := c.preparerForListWebApps(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "ListWebApps", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "ListWebApps", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListWebApps(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "ListWebApps", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListWebApps prepares the ListWebApps request. -func (c AppServicePlansClient) preparerForListWebApps(ctx context.Context, id ServerFarmId, options ListWebAppsOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/sites", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWebAppsWithNextLink prepares the ListWebApps request with the given nextLink token. -func (c AppServicePlansClient) preparerForListWebAppsWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListWebApps handles the response to the ListWebApps request. The method always -// closes the http.Response Body. -func (c AppServicePlansClient) responderForListWebApps(resp *http.Response) (result ListWebAppsOperationResponse, err error) { - type page struct { - Values []Site `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListWebAppsOperationResponse, err error) { - req, err := c.preparerForListWebAppsWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "ListWebApps", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "ListWebApps", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListWebApps(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "ListWebApps", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListWebAppsComplete retrieves all of the results into a single object -func (c AppServicePlansClient) ListWebAppsComplete(ctx context.Context, id ServerFarmId, options ListWebAppsOperationOptions) (ListWebAppsCompleteResult, error) { - return c.ListWebAppsCompleteMatchingPredicate(ctx, id, options, SiteOperationPredicate{}) -} - -// ListWebAppsCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c AppServicePlansClient) ListWebAppsCompleteMatchingPredicate(ctx context.Context, id ServerFarmId, options ListWebAppsOperationOptions, predicate SiteOperationPredicate) (resp ListWebAppsCompleteResult, err error) { - items := make([]Site, 0) - - page, err := c.ListWebApps(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListWebAppsCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/appserviceplans/method_listwebappsbyhybridconnection.go b/resource-manager/web/2022-09-01/appserviceplans/method_listwebappsbyhybridconnection.go new file mode 100644 index 00000000000..0e7c7ef6a09 --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceplans/method_listwebappsbyhybridconnection.go @@ -0,0 +1,82 @@ +package appserviceplans + +import ( + "context" + "fmt" + "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 ListWebAppsByHybridConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]string +} + +type ListWebAppsByHybridConnectionCompleteResult struct { + Items []string +} + +// ListWebAppsByHybridConnection ... +func (c AppServicePlansClient) ListWebAppsByHybridConnection(ctx context.Context, id HybridConnectionNamespaceRelayId) (result ListWebAppsByHybridConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/sites", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]string `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListWebAppsByHybridConnectionComplete retrieves all the results into a single object +func (c AppServicePlansClient) ListWebAppsByHybridConnectionComplete(ctx context.Context, id HybridConnectionNamespaceRelayId) (result ListWebAppsByHybridConnectionCompleteResult, err error) { + items := make([]string, 0) + + resp, err := c.ListWebAppsByHybridConnection(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + items = append(items, v) + } + } + + result = ListWebAppsByHybridConnectionCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/appserviceplans/method_listwebappsbyhybridconnection_autorest.go b/resource-manager/web/2022-09-01/appserviceplans/method_listwebappsbyhybridconnection_autorest.go deleted file mode 100644 index c1db3786bb2..00000000000 --- a/resource-manager/web/2022-09-01/appserviceplans/method_listwebappsbyhybridconnection_autorest.go +++ /dev/null @@ -1,177 +0,0 @@ -package appserviceplans - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListWebAppsByHybridConnectionOperationResponse struct { - HttpResponse *http.Response - Model *[]string - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListWebAppsByHybridConnectionOperationResponse, error) -} - -type ListWebAppsByHybridConnectionCompleteResult struct { - Items []string -} - -func (r ListWebAppsByHybridConnectionOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListWebAppsByHybridConnectionOperationResponse) LoadMore(ctx context.Context) (resp ListWebAppsByHybridConnectionOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListWebAppsByHybridConnection ... -func (c AppServicePlansClient) ListWebAppsByHybridConnection(ctx context.Context, id HybridConnectionNamespaceRelayId) (resp ListWebAppsByHybridConnectionOperationResponse, err error) { - req, err := c.preparerForListWebAppsByHybridConnection(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "ListWebAppsByHybridConnection", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "ListWebAppsByHybridConnection", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListWebAppsByHybridConnection(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "ListWebAppsByHybridConnection", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListWebAppsByHybridConnection prepares the ListWebAppsByHybridConnection request. -func (c AppServicePlansClient) preparerForListWebAppsByHybridConnection(ctx context.Context, id HybridConnectionNamespaceRelayId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/sites", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWebAppsByHybridConnectionWithNextLink prepares the ListWebAppsByHybridConnection request with the given nextLink token. -func (c AppServicePlansClient) preparerForListWebAppsByHybridConnectionWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListWebAppsByHybridConnection handles the response to the ListWebAppsByHybridConnection request. The method always -// closes the http.Response Body. -func (c AppServicePlansClient) responderForListWebAppsByHybridConnection(resp *http.Response) (result ListWebAppsByHybridConnectionOperationResponse, err error) { - type page struct { - Values []string `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListWebAppsByHybridConnectionOperationResponse, err error) { - req, err := c.preparerForListWebAppsByHybridConnectionWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "ListWebAppsByHybridConnection", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "ListWebAppsByHybridConnection", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListWebAppsByHybridConnection(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "ListWebAppsByHybridConnection", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListWebAppsByHybridConnectionComplete retrieves all of the results into a single object -func (c AppServicePlansClient) ListWebAppsByHybridConnectionComplete(ctx context.Context, id HybridConnectionNamespaceRelayId) (result ListWebAppsByHybridConnectionCompleteResult, err error) { - items := make([]string, 0) - - page, err := c.ListWebAppsByHybridConnection(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - items = append(items, v) - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - items = append(items, v) - } - } - } - - out := ListWebAppsByHybridConnectionCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/appserviceplans/method_rebootworker.go b/resource-manager/web/2022-09-01/appserviceplans/method_rebootworker.go new file mode 100644 index 00000000000..91cbd2cb420 --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceplans/method_rebootworker.go @@ -0,0 +1,47 @@ +package appserviceplans + +import ( + "context" + "fmt" + "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 RebootWorkerOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// RebootWorker ... +func (c AppServicePlansClient) RebootWorker(ctx context.Context, id WorkerId) (result RebootWorkerOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/reboot", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/appserviceplans/method_rebootworker_autorest.go b/resource-manager/web/2022-09-01/appserviceplans/method_rebootworker_autorest.go deleted file mode 100644 index de5520f9bbc..00000000000 --- a/resource-manager/web/2022-09-01/appserviceplans/method_rebootworker_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package appserviceplans - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type RebootWorkerOperationResponse struct { - HttpResponse *http.Response -} - -// RebootWorker ... -func (c AppServicePlansClient) RebootWorker(ctx context.Context, id WorkerId) (result RebootWorkerOperationResponse, err error) { - req, err := c.preparerForRebootWorker(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "RebootWorker", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "RebootWorker", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForRebootWorker(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "RebootWorker", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForRebootWorker prepares the RebootWorker request. -func (c AppServicePlansClient) preparerForRebootWorker(ctx context.Context, id WorkerId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/reboot", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForRebootWorker handles the response to the RebootWorker request. The method always -// closes the http.Response Body. -func (c AppServicePlansClient) responderForRebootWorker(resp *http.Response) (result RebootWorkerOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/appserviceplans/method_restartwebapps.go b/resource-manager/web/2022-09-01/appserviceplans/method_restartwebapps.go new file mode 100644 index 00000000000..34ae415bcef --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceplans/method_restartwebapps.go @@ -0,0 +1,75 @@ +package appserviceplans + +import ( + "context" + "fmt" + "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 RestartWebAppsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type RestartWebAppsOperationOptions struct { + SoftRestart *bool +} + +func DefaultRestartWebAppsOperationOptions() RestartWebAppsOperationOptions { + return RestartWebAppsOperationOptions{} +} + +func (o RestartWebAppsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o RestartWebAppsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o RestartWebAppsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.SoftRestart != nil { + out.Append("softRestart", fmt.Sprintf("%v", *o.SoftRestart)) + } + return &out +} + +// RestartWebApps ... +func (c AppServicePlansClient) RestartWebApps(ctx context.Context, id ServerFarmId, options RestartWebAppsOperationOptions) (result RestartWebAppsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restartSites", id.ID()), + OptionsObject: options, + } + + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/appserviceplans/method_restartwebapps_autorest.go b/resource-manager/web/2022-09-01/appserviceplans/method_restartwebapps_autorest.go deleted file mode 100644 index 394a6319205..00000000000 --- a/resource-manager/web/2022-09-01/appserviceplans/method_restartwebapps_autorest.go +++ /dev/null @@ -1,96 +0,0 @@ -package appserviceplans - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type RestartWebAppsOperationResponse struct { - HttpResponse *http.Response -} - -type RestartWebAppsOperationOptions struct { - SoftRestart *bool -} - -func DefaultRestartWebAppsOperationOptions() RestartWebAppsOperationOptions { - return RestartWebAppsOperationOptions{} -} - -func (o RestartWebAppsOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o RestartWebAppsOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.SoftRestart != nil { - out["softRestart"] = *o.SoftRestart - } - - return out -} - -// RestartWebApps ... -func (c AppServicePlansClient) RestartWebApps(ctx context.Context, id ServerFarmId, options RestartWebAppsOperationOptions) (result RestartWebAppsOperationResponse, err error) { - req, err := c.preparerForRestartWebApps(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "RestartWebApps", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "RestartWebApps", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForRestartWebApps(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "RestartWebApps", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForRestartWebApps prepares the RestartWebApps request. -func (c AppServicePlansClient) preparerForRestartWebApps(ctx context.Context, id ServerFarmId, options RestartWebAppsOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/restartSites", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForRestartWebApps handles the response to the RestartWebApps request. The method always -// closes the http.Response Body. -func (c AppServicePlansClient) responderForRestartWebApps(resp *http.Response) (result RestartWebAppsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/appserviceplans/method_update.go b/resource-manager/web/2022-09-01/appserviceplans/method_update.go new file mode 100644 index 00000000000..2ac0a05b13c --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceplans/method_update.go @@ -0,0 +1,56 @@ +package appserviceplans + +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 UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AppServicePlan +} + +// Update ... +func (c AppServicePlansClient) Update(ctx context.Context, id ServerFarmId, input AppServicePlanPatchResource) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + 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 +} diff --git a/resource-manager/web/2022-09-01/appserviceplans/method_update_autorest.go b/resource-manager/web/2022-09-01/appserviceplans/method_update_autorest.go deleted file mode 100644 index 0b2659558c0..00000000000 --- a/resource-manager/web/2022-09-01/appserviceplans/method_update_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package appserviceplans - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateOperationResponse struct { - HttpResponse *http.Response - Model *AppServicePlan -} - -// Update ... -func (c AppServicePlansClient) Update(ctx context.Context, id ServerFarmId, input AppServicePlanPatchResource) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c AppServicePlansClient) preparerForUpdate(ctx context.Context, id ServerFarmId, input AppServicePlanPatchResource) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdate handles the response to the Update request. The method always -// closes the http.Response Body. -func (c AppServicePlansClient) responderForUpdate(resp *http.Response) (result UpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/appserviceplans/method_updatevnetgateway.go b/resource-manager/web/2022-09-01/appserviceplans/method_updatevnetgateway.go new file mode 100644 index 00000000000..ecd8a8dcc52 --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceplans/method_updatevnetgateway.go @@ -0,0 +1,55 @@ +package appserviceplans + +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 UpdateVnetGatewayOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetGateway +} + +// UpdateVnetGateway ... +func (c AppServicePlansClient) UpdateVnetGateway(ctx context.Context, id VirtualNetworkConnectionGatewayId, input VnetGateway) (result UpdateVnetGatewayOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 +} diff --git a/resource-manager/web/2022-09-01/appserviceplans/method_updatevnetgateway_autorest.go b/resource-manager/web/2022-09-01/appserviceplans/method_updatevnetgateway_autorest.go deleted file mode 100644 index e15e7ff83b5..00000000000 --- a/resource-manager/web/2022-09-01/appserviceplans/method_updatevnetgateway_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package appserviceplans - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateVnetGatewayOperationResponse struct { - HttpResponse *http.Response - Model *VnetGateway -} - -// UpdateVnetGateway ... -func (c AppServicePlansClient) UpdateVnetGateway(ctx context.Context, id VirtualNetworkConnectionGatewayId, input VnetGateway) (result UpdateVnetGatewayOperationResponse, err error) { - req, err := c.preparerForUpdateVnetGateway(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "UpdateVnetGateway", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "UpdateVnetGateway", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateVnetGateway(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "UpdateVnetGateway", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateVnetGateway prepares the UpdateVnetGateway request. -func (c AppServicePlansClient) preparerForUpdateVnetGateway(ctx context.Context, id VirtualNetworkConnectionGatewayId, input VnetGateway) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateVnetGateway handles the response to the UpdateVnetGateway request. The method always -// closes the http.Response Body. -func (c AppServicePlansClient) responderForUpdateVnetGateway(resp *http.Response) (result UpdateVnetGatewayOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/appserviceplans/method_updatevnetroute.go b/resource-manager/web/2022-09-01/appserviceplans/method_updatevnetroute.go new file mode 100644 index 00000000000..96355d5e9bc --- /dev/null +++ b/resource-manager/web/2022-09-01/appserviceplans/method_updatevnetroute.go @@ -0,0 +1,55 @@ +package appserviceplans + +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 UpdateVnetRouteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetRoute +} + +// UpdateVnetRoute ... +func (c AppServicePlansClient) UpdateVnetRoute(ctx context.Context, id RouteId, input VnetRoute) (result UpdateVnetRouteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + 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 +} diff --git a/resource-manager/web/2022-09-01/appserviceplans/method_updatevnetroute_autorest.go b/resource-manager/web/2022-09-01/appserviceplans/method_updatevnetroute_autorest.go deleted file mode 100644 index 107b850b522..00000000000 --- a/resource-manager/web/2022-09-01/appserviceplans/method_updatevnetroute_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package appserviceplans - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateVnetRouteOperationResponse struct { - HttpResponse *http.Response - Model *VnetRoute -} - -// UpdateVnetRoute ... -func (c AppServicePlansClient) UpdateVnetRoute(ctx context.Context, id RouteId, input VnetRoute) (result UpdateVnetRouteOperationResponse, err error) { - req, err := c.preparerForUpdateVnetRoute(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "UpdateVnetRoute", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "UpdateVnetRoute", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateVnetRoute(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "appserviceplans.AppServicePlansClient", "UpdateVnetRoute", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateVnetRoute prepares the UpdateVnetRoute request. -func (c AppServicePlansClient) preparerForUpdateVnetRoute(ctx context.Context, id RouteId, input VnetRoute) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateVnetRoute handles the response to the UpdateVnetRoute request. The method always -// closes the http.Response Body. -func (c AppServicePlansClient) responderForUpdateVnetRoute(resp *http.Response) (result UpdateVnetRouteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/certificateordersdiagnostics/client.go b/resource-manager/web/2022-09-01/certificateordersdiagnostics/client.go index 47489517979..d4b2b27b862 100644 --- a/resource-manager/web/2022-09-01/certificateordersdiagnostics/client.go +++ b/resource-manager/web/2022-09-01/certificateordersdiagnostics/client.go @@ -1,18 +1,26 @@ package certificateordersdiagnostics -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 CertificateOrdersDiagnosticsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewCertificateOrdersDiagnosticsClientWithBaseURI(endpoint string) CertificateOrdersDiagnosticsClient { - return CertificateOrdersDiagnosticsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewCertificateOrdersDiagnosticsClientWithBaseURI(api environments.Api) (*CertificateOrdersDiagnosticsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "certificateordersdiagnostics", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CertificateOrdersDiagnosticsClient: %+v", err) } + + return &CertificateOrdersDiagnosticsClient{ + Client: client, + }, nil } diff --git a/resource-manager/web/2022-09-01/certificateordersdiagnostics/constants.go b/resource-manager/web/2022-09-01/certificateordersdiagnostics/constants.go index b645ed940af..5a46c7d7aeb 100644 --- a/resource-manager/web/2022-09-01/certificateordersdiagnostics/constants.go +++ b/resource-manager/web/2022-09-01/certificateordersdiagnostics/constants.go @@ -1,6 +1,10 @@ package certificateordersdiagnostics -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. @@ -21,6 +25,19 @@ func PossibleValuesForDetectorType() []string { } } +func (s *DetectorType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDetectorType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseDetectorType(input string) (*DetectorType, error) { vals := map[string]DetectorType{ "analysis": DetectorTypeAnalysis, @@ -56,6 +73,19 @@ func PossibleValuesForInsightStatus() []string { } } +func (s *InsightStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseInsightStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseInsightStatus(input string) (*InsightStatus, error) { vals := map[string]InsightStatus{ "critical": InsightStatusCritical, @@ -133,6 +163,19 @@ func PossibleValuesForRenderingType() []string { } } +func (s *RenderingType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRenderingType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseRenderingType(input string) (*RenderingType, error) { vals := map[string]RenderingType{ "appinsight": RenderingTypeAppInsight, diff --git a/resource-manager/web/2022-09-01/certificateordersdiagnostics/method_getappservicecertificateorderdetectorresponse.go b/resource-manager/web/2022-09-01/certificateordersdiagnostics/method_getappservicecertificateorderdetectorresponse.go new file mode 100644 index 00000000000..e5aa6d8e820 --- /dev/null +++ b/resource-manager/web/2022-09-01/certificateordersdiagnostics/method_getappservicecertificateorderdetectorresponse.go @@ -0,0 +1,88 @@ +package certificateordersdiagnostics + +import ( + "context" + "fmt" + "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 GetAppServiceCertificateOrderDetectorResponseOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DetectorResponse +} + +type GetAppServiceCertificateOrderDetectorResponseOperationOptions struct { + EndTime *string + StartTime *string + TimeGrain *string +} + +func DefaultGetAppServiceCertificateOrderDetectorResponseOperationOptions() GetAppServiceCertificateOrderDetectorResponseOperationOptions { + return GetAppServiceCertificateOrderDetectorResponseOperationOptions{} +} + +func (o GetAppServiceCertificateOrderDetectorResponseOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetAppServiceCertificateOrderDetectorResponseOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o GetAppServiceCertificateOrderDetectorResponseOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.EndTime != nil { + out.Append("endTime", fmt.Sprintf("%v", *o.EndTime)) + } + if o.StartTime != nil { + out.Append("startTime", fmt.Sprintf("%v", *o.StartTime)) + } + if o.TimeGrain != nil { + out.Append("timeGrain", fmt.Sprintf("%v", *o.TimeGrain)) + } + return &out +} + +// GetAppServiceCertificateOrderDetectorResponse ... +func (c CertificateOrdersDiagnosticsClient) GetAppServiceCertificateOrderDetectorResponse(ctx context.Context, id DetectorId, options GetAppServiceCertificateOrderDetectorResponseOperationOptions) (result GetAppServiceCertificateOrderDetectorResponseOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + OptionsObject: options, + } + + 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 +} diff --git a/resource-manager/web/2022-09-01/certificateordersdiagnostics/method_getappservicecertificateorderdetectorresponse_autorest.go b/resource-manager/web/2022-09-01/certificateordersdiagnostics/method_getappservicecertificateorderdetectorresponse_autorest.go deleted file mode 100644 index 82d82cb8bd8..00000000000 --- a/resource-manager/web/2022-09-01/certificateordersdiagnostics/method_getappservicecertificateorderdetectorresponse_autorest.go +++ /dev/null @@ -1,107 +0,0 @@ -package certificateordersdiagnostics - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetAppServiceCertificateOrderDetectorResponseOperationResponse struct { - HttpResponse *http.Response - Model *DetectorResponse -} - -type GetAppServiceCertificateOrderDetectorResponseOperationOptions struct { - EndTime *string - StartTime *string - TimeGrain *string -} - -func DefaultGetAppServiceCertificateOrderDetectorResponseOperationOptions() GetAppServiceCertificateOrderDetectorResponseOperationOptions { - return GetAppServiceCertificateOrderDetectorResponseOperationOptions{} -} - -func (o GetAppServiceCertificateOrderDetectorResponseOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o GetAppServiceCertificateOrderDetectorResponseOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.EndTime != nil { - out["endTime"] = *o.EndTime - } - - if o.StartTime != nil { - out["startTime"] = *o.StartTime - } - - if o.TimeGrain != nil { - out["timeGrain"] = *o.TimeGrain - } - - return out -} - -// GetAppServiceCertificateOrderDetectorResponse ... -func (c CertificateOrdersDiagnosticsClient) GetAppServiceCertificateOrderDetectorResponse(ctx context.Context, id DetectorId, options GetAppServiceCertificateOrderDetectorResponseOperationOptions) (result GetAppServiceCertificateOrderDetectorResponseOperationResponse, err error) { - req, err := c.preparerForGetAppServiceCertificateOrderDetectorResponse(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "certificateordersdiagnostics.CertificateOrdersDiagnosticsClient", "GetAppServiceCertificateOrderDetectorResponse", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "certificateordersdiagnostics.CertificateOrdersDiagnosticsClient", "GetAppServiceCertificateOrderDetectorResponse", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetAppServiceCertificateOrderDetectorResponse(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "certificateordersdiagnostics.CertificateOrdersDiagnosticsClient", "GetAppServiceCertificateOrderDetectorResponse", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetAppServiceCertificateOrderDetectorResponse prepares the GetAppServiceCertificateOrderDetectorResponse request. -func (c CertificateOrdersDiagnosticsClient) preparerForGetAppServiceCertificateOrderDetectorResponse(ctx context.Context, id DetectorId, options GetAppServiceCertificateOrderDetectorResponseOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetAppServiceCertificateOrderDetectorResponse handles the response to the GetAppServiceCertificateOrderDetectorResponse request. The method always -// closes the http.Response Body. -func (c CertificateOrdersDiagnosticsClient) responderForGetAppServiceCertificateOrderDetectorResponse(resp *http.Response) (result GetAppServiceCertificateOrderDetectorResponseOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/certificateordersdiagnostics/method_listappservicecertificateorderdetectorresponse.go b/resource-manager/web/2022-09-01/certificateordersdiagnostics/method_listappservicecertificateorderdetectorresponse.go new file mode 100644 index 00000000000..36552ac60c9 --- /dev/null +++ b/resource-manager/web/2022-09-01/certificateordersdiagnostics/method_listappservicecertificateorderdetectorresponse.go @@ -0,0 +1,89 @@ +package certificateordersdiagnostics + +import ( + "context" + "fmt" + "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 ListAppServiceCertificateOrderDetectorResponseOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DetectorResponse +} + +type ListAppServiceCertificateOrderDetectorResponseCompleteResult struct { + Items []DetectorResponse +} + +// ListAppServiceCertificateOrderDetectorResponse ... +func (c CertificateOrdersDiagnosticsClient) ListAppServiceCertificateOrderDetectorResponse(ctx context.Context, id CertificateOrderId) (result ListAppServiceCertificateOrderDetectorResponseOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/detectors", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]DetectorResponse `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAppServiceCertificateOrderDetectorResponseComplete retrieves all the results into a single object +func (c CertificateOrdersDiagnosticsClient) ListAppServiceCertificateOrderDetectorResponseComplete(ctx context.Context, id CertificateOrderId) (ListAppServiceCertificateOrderDetectorResponseCompleteResult, error) { + return c.ListAppServiceCertificateOrderDetectorResponseCompleteMatchingPredicate(ctx, id, DetectorResponseOperationPredicate{}) +} + +// ListAppServiceCertificateOrderDetectorResponseCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c CertificateOrdersDiagnosticsClient) ListAppServiceCertificateOrderDetectorResponseCompleteMatchingPredicate(ctx context.Context, id CertificateOrderId, predicate DetectorResponseOperationPredicate) (result ListAppServiceCertificateOrderDetectorResponseCompleteResult, err error) { + items := make([]DetectorResponse, 0) + + resp, err := c.ListAppServiceCertificateOrderDetectorResponse(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListAppServiceCertificateOrderDetectorResponseCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/certificateordersdiagnostics/method_listappservicecertificateorderdetectorresponse_autorest.go b/resource-manager/web/2022-09-01/certificateordersdiagnostics/method_listappservicecertificateorderdetectorresponse_autorest.go deleted file mode 100644 index 5403d94d0b9..00000000000 --- a/resource-manager/web/2022-09-01/certificateordersdiagnostics/method_listappservicecertificateorderdetectorresponse_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package certificateordersdiagnostics - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListAppServiceCertificateOrderDetectorResponseOperationResponse struct { - HttpResponse *http.Response - Model *[]DetectorResponse - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListAppServiceCertificateOrderDetectorResponseOperationResponse, error) -} - -type ListAppServiceCertificateOrderDetectorResponseCompleteResult struct { - Items []DetectorResponse -} - -func (r ListAppServiceCertificateOrderDetectorResponseOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListAppServiceCertificateOrderDetectorResponseOperationResponse) LoadMore(ctx context.Context) (resp ListAppServiceCertificateOrderDetectorResponseOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListAppServiceCertificateOrderDetectorResponse ... -func (c CertificateOrdersDiagnosticsClient) ListAppServiceCertificateOrderDetectorResponse(ctx context.Context, id CertificateOrderId) (resp ListAppServiceCertificateOrderDetectorResponseOperationResponse, err error) { - req, err := c.preparerForListAppServiceCertificateOrderDetectorResponse(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "certificateordersdiagnostics.CertificateOrdersDiagnosticsClient", "ListAppServiceCertificateOrderDetectorResponse", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "certificateordersdiagnostics.CertificateOrdersDiagnosticsClient", "ListAppServiceCertificateOrderDetectorResponse", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListAppServiceCertificateOrderDetectorResponse(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "certificateordersdiagnostics.CertificateOrdersDiagnosticsClient", "ListAppServiceCertificateOrderDetectorResponse", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListAppServiceCertificateOrderDetectorResponse prepares the ListAppServiceCertificateOrderDetectorResponse request. -func (c CertificateOrdersDiagnosticsClient) preparerForListAppServiceCertificateOrderDetectorResponse(ctx context.Context, id CertificateOrderId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/detectors", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListAppServiceCertificateOrderDetectorResponseWithNextLink prepares the ListAppServiceCertificateOrderDetectorResponse request with the given nextLink token. -func (c CertificateOrdersDiagnosticsClient) preparerForListAppServiceCertificateOrderDetectorResponseWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListAppServiceCertificateOrderDetectorResponse handles the response to the ListAppServiceCertificateOrderDetectorResponse request. The method always -// closes the http.Response Body. -func (c CertificateOrdersDiagnosticsClient) responderForListAppServiceCertificateOrderDetectorResponse(resp *http.Response) (result ListAppServiceCertificateOrderDetectorResponseOperationResponse, err error) { - type page struct { - Values []DetectorResponse `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListAppServiceCertificateOrderDetectorResponseOperationResponse, err error) { - req, err := c.preparerForListAppServiceCertificateOrderDetectorResponseWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "certificateordersdiagnostics.CertificateOrdersDiagnosticsClient", "ListAppServiceCertificateOrderDetectorResponse", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "certificateordersdiagnostics.CertificateOrdersDiagnosticsClient", "ListAppServiceCertificateOrderDetectorResponse", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListAppServiceCertificateOrderDetectorResponse(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "certificateordersdiagnostics.CertificateOrdersDiagnosticsClient", "ListAppServiceCertificateOrderDetectorResponse", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListAppServiceCertificateOrderDetectorResponseComplete retrieves all of the results into a single object -func (c CertificateOrdersDiagnosticsClient) ListAppServiceCertificateOrderDetectorResponseComplete(ctx context.Context, id CertificateOrderId) (ListAppServiceCertificateOrderDetectorResponseCompleteResult, error) { - return c.ListAppServiceCertificateOrderDetectorResponseCompleteMatchingPredicate(ctx, id, DetectorResponseOperationPredicate{}) -} - -// ListAppServiceCertificateOrderDetectorResponseCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c CertificateOrdersDiagnosticsClient) ListAppServiceCertificateOrderDetectorResponseCompleteMatchingPredicate(ctx context.Context, id CertificateOrderId, predicate DetectorResponseOperationPredicate) (resp ListAppServiceCertificateOrderDetectorResponseCompleteResult, err error) { - items := make([]DetectorResponse, 0) - - page, err := c.ListAppServiceCertificateOrderDetectorResponse(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListAppServiceCertificateOrderDetectorResponseCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/certificates/client.go b/resource-manager/web/2022-09-01/certificates/client.go index 76fe67c326e..1df2d72c23a 100644 --- a/resource-manager/web/2022-09-01/certificates/client.go +++ b/resource-manager/web/2022-09-01/certificates/client.go @@ -1,18 +1,26 @@ package certificates -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 CertificatesClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewCertificatesClientWithBaseURI(endpoint string) CertificatesClient { - return CertificatesClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewCertificatesClientWithBaseURI(api environments.Api) (*CertificatesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "certificates", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CertificatesClient: %+v", err) } + + return &CertificatesClient{ + Client: client, + }, nil } diff --git a/resource-manager/web/2022-09-01/certificates/constants.go b/resource-manager/web/2022-09-01/certificates/constants.go index 9ef113c8daf..afe3445c7e6 100644 --- a/resource-manager/web/2022-09-01/certificates/constants.go +++ b/resource-manager/web/2022-09-01/certificates/constants.go @@ -1,6 +1,10 @@ package certificates -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. @@ -37,6 +41,19 @@ func PossibleValuesForKeyVaultSecretStatus() []string { } } +func (s *KeyVaultSecretStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKeyVaultSecretStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseKeyVaultSecretStatus(input string) (*KeyVaultSecretStatus, error) { vals := map[string]KeyVaultSecretStatus{ "azureserviceunauthorizedtoaccesskeyvault": KeyVaultSecretStatusAzureServiceUnauthorizedToAccessKeyVault, diff --git a/resource-manager/web/2022-09-01/certificates/method_createorupdate.go b/resource-manager/web/2022-09-01/certificates/method_createorupdate.go new file mode 100644 index 00000000000..d10caee5c36 --- /dev/null +++ b/resource-manager/web/2022-09-01/certificates/method_createorupdate.go @@ -0,0 +1,55 @@ +package certificates + +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 *Certificate +} + +// CreateOrUpdate ... +func (c CertificatesClient) CreateOrUpdate(ctx context.Context, id CertificateId, input Certificate) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 +} diff --git a/resource-manager/web/2022-09-01/certificates/method_createorupdate_autorest.go b/resource-manager/web/2022-09-01/certificates/method_createorupdate_autorest.go deleted file mode 100644 index c304251281a..00000000000 --- a/resource-manager/web/2022-09-01/certificates/method_createorupdate_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package certificates - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// 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 - Model *Certificate -} - -// CreateOrUpdate ... -func (c CertificatesClient) CreateOrUpdate(ctx context.Context, id CertificateId, input Certificate) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "certificates.CertificatesClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "certificates.CertificatesClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "certificates.CertificatesClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c CertificatesClient) preparerForCreateOrUpdate(ctx context.Context, id CertificateId, input Certificate) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateOrUpdate handles the response to the CreateOrUpdate request. The method always -// closes the http.Response Body. -func (c CertificatesClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/certificates/method_delete.go b/resource-manager/web/2022-09-01/certificates/method_delete.go new file mode 100644 index 00000000000..162d6402c67 --- /dev/null +++ b/resource-manager/web/2022-09-01/certificates/method_delete.go @@ -0,0 +1,47 @@ +package certificates + +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 +} + +// Delete ... +func (c CertificatesClient) Delete(ctx context.Context, id CertificateId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/certificates/method_delete_autorest.go b/resource-manager/web/2022-09-01/certificates/method_delete_autorest.go deleted file mode 100644 index 9784a5478d2..00000000000 --- a/resource-manager/web/2022-09-01/certificates/method_delete_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package certificates - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// 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 -} - -// Delete ... -func (c CertificatesClient) Delete(ctx context.Context, id CertificateId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "certificates.CertificatesClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "certificates.CertificatesClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "certificates.CertificatesClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c CertificatesClient) preparerForDelete(ctx context.Context, id CertificateId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c CertificatesClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/certificates/method_get.go b/resource-manager/web/2022-09-01/certificates/method_get.go new file mode 100644 index 00000000000..dbbb97e49aa --- /dev/null +++ b/resource-manager/web/2022-09-01/certificates/method_get.go @@ -0,0 +1,51 @@ +package certificates + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Certificate +} + +// Get ... +func (c CertificatesClient) Get(ctx context.Context, id CertificateId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/certificates/method_get_autorest.go b/resource-manager/web/2022-09-01/certificates/method_get_autorest.go deleted file mode 100644 index c30e94b1ad9..00000000000 --- a/resource-manager/web/2022-09-01/certificates/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package certificates - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *Certificate -} - -// Get ... -func (c CertificatesClient) Get(ctx context.Context, id CertificateId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "certificates.CertificatesClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "certificates.CertificatesClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "certificates.CertificatesClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c CertificatesClient) preparerForGet(ctx context.Context, id CertificateId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c CertificatesClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/certificates/method_list.go b/resource-manager/web/2022-09-01/certificates/method_list.go new file mode 100644 index 00000000000..47ddec7d97b --- /dev/null +++ b/resource-manager/web/2022-09-01/certificates/method_list.go @@ -0,0 +1,118 @@ +package certificates + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Certificate +} + +type ListCompleteResult struct { + Items []Certificate +} + +type ListOperationOptions struct { + Filter *string +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +// List ... +func (c CertificatesClient) List(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/certificates", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Certificate `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c CertificatesClient) ListComplete(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, CertificateOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c CertificatesClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions, predicate CertificateOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Certificate, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/certificates/method_list_autorest.go b/resource-manager/web/2022-09-01/certificates/method_list_autorest.go deleted file mode 100644 index 93c7e8ca464..00000000000 --- a/resource-manager/web/2022-09-01/certificates/method_list_autorest.go +++ /dev/null @@ -1,216 +0,0 @@ -package certificates - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListOperationResponse struct { - HttpResponse *http.Response - Model *[]Certificate - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []Certificate -} - -func (r ListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListOperationOptions struct { - Filter *string -} - -func DefaultListOperationOptions() ListOperationOptions { - return ListOperationOptions{} -} - -func (o ListOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - return out -} - -// List ... -func (c CertificatesClient) List(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "certificates.CertificatesClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "certificates.CertificatesClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "certificates.CertificatesClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c CertificatesClient) preparerForList(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Web/certificates", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c CertificatesClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForList handles the response to the List request. The method always -// closes the http.Response Body. -func (c CertificatesClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []Certificate `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { - req, err := c.preparerForListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "certificates.CertificatesClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "certificates.CertificatesClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "certificates.CertificatesClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c CertificatesClient) ListComplete(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, options, CertificateOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c CertificatesClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions, predicate CertificateOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]Certificate, 0) - - page, err := c.List(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/certificates/method_listbyresourcegroup.go b/resource-manager/web/2022-09-01/certificates/method_listbyresourcegroup.go new file mode 100644 index 00000000000..b9e07fa6ac8 --- /dev/null +++ b/resource-manager/web/2022-09-01/certificates/method_listbyresourcegroup.go @@ -0,0 +1,90 @@ +package certificates + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Certificate +} + +type ListByResourceGroupCompleteResult struct { + Items []Certificate +} + +// ListByResourceGroup ... +func (c CertificatesClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/certificates", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Certificate `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c CertificatesClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, CertificateOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c CertificatesClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate CertificateOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]Certificate, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/certificates/method_listbyresourcegroup_autorest.go b/resource-manager/web/2022-09-01/certificates/method_listbyresourcegroup_autorest.go deleted file mode 100644 index 3ffe1501081..00000000000 --- a/resource-manager/web/2022-09-01/certificates/method_listbyresourcegroup_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package certificates - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByResourceGroupOperationResponse struct { - HttpResponse *http.Response - Model *[]Certificate - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByResourceGroupOperationResponse, error) -} - -type ListByResourceGroupCompleteResult struct { - Items []Certificate -} - -func (r ListByResourceGroupOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByResourceGroupOperationResponse) LoadMore(ctx context.Context) (resp ListByResourceGroupOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByResourceGroup ... -func (c CertificatesClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (resp ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroup(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "certificates.CertificatesClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "certificates.CertificatesClient", "ListByResourceGroup", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByResourceGroup(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "certificates.CertificatesClient", "ListByResourceGroup", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByResourceGroup prepares the ListByResourceGroup request. -func (c CertificatesClient) preparerForListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Web/certificates", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByResourceGroupWithNextLink prepares the ListByResourceGroup request with the given nextLink token. -func (c CertificatesClient) preparerForListByResourceGroupWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByResourceGroup handles the response to the ListByResourceGroup request. The method always -// closes the http.Response Body. -func (c CertificatesClient) responderForListByResourceGroup(resp *http.Response) (result ListByResourceGroupOperationResponse, err error) { - type page struct { - Values []Certificate `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroupWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "certificates.CertificatesClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "certificates.CertificatesClient", "ListByResourceGroup", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByResourceGroup(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "certificates.CertificatesClient", "ListByResourceGroup", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByResourceGroupComplete retrieves all of the results into a single object -func (c CertificatesClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { - return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, CertificateOperationPredicate{}) -} - -// ListByResourceGroupCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c CertificatesClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate CertificateOperationPredicate) (resp ListByResourceGroupCompleteResult, err error) { - items := make([]Certificate, 0) - - page, err := c.ListByResourceGroup(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByResourceGroupCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/certificates/method_update.go b/resource-manager/web/2022-09-01/certificates/method_update.go new file mode 100644 index 00000000000..f0aed354863 --- /dev/null +++ b/resource-manager/web/2022-09-01/certificates/method_update.go @@ -0,0 +1,55 @@ +package certificates + +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 UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Certificate +} + +// Update ... +func (c CertificatesClient) Update(ctx context.Context, id CertificateId, input CertificatePatchResource) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + 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 +} diff --git a/resource-manager/web/2022-09-01/certificates/method_update_autorest.go b/resource-manager/web/2022-09-01/certificates/method_update_autorest.go deleted file mode 100644 index 2b19fc5d827..00000000000 --- a/resource-manager/web/2022-09-01/certificates/method_update_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package certificates - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateOperationResponse struct { - HttpResponse *http.Response - Model *Certificate -} - -// Update ... -func (c CertificatesClient) Update(ctx context.Context, id CertificateId, input CertificatePatchResource) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "certificates.CertificatesClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "certificates.CertificatesClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "certificates.CertificatesClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c CertificatesClient) preparerForUpdate(ctx context.Context, id CertificateId, input CertificatePatchResource) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdate handles the response to the Update request. The method always -// closes the http.Response Body. -func (c CertificatesClient) responderForUpdate(resp *http.Response) (result UpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/client.go b/resource-manager/web/2022-09-01/client.go index 45dfec235c7..7116db91bcd 100644 --- a/resource-manager/web/2022-09-01/client.go +++ b/resource-manager/web/2022-09-01/client.go @@ -4,7 +4,8 @@ package v2022_09_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/web/2022-09-01/appservicecertificateorders" "github.com/hashicorp/go-azure-sdk/resource-manager/web/2022-09-01/appserviceenvironments" "github.com/hashicorp/go-azure-sdk/resource-manager/web/2022-09-01/appserviceplans" @@ -30,6 +31,8 @@ import ( "github.com/hashicorp/go-azure-sdk/resource-manager/web/2022-09-01/workflowtriggerhistories" "github.com/hashicorp/go-azure-sdk/resource-manager/web/2022-09-01/workflowtriggers" "github.com/hashicorp/go-azure-sdk/resource-manager/web/2022-09-01/workflowversions" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/environments" ) type Client struct { @@ -60,108 +63,182 @@ type Client struct { Workflows *workflows.WorkflowsClient } -func NewClientWithBaseURI(endpoint string, configureAuthFunc func(c *autorest.Client)) Client { - - appServiceCertificateOrdersClient := appservicecertificateorders.NewAppServiceCertificateOrdersClientWithBaseURI(endpoint) - configureAuthFunc(&appServiceCertificateOrdersClient.Client) - - appServiceEnvironmentsClient := appserviceenvironments.NewAppServiceEnvironmentsClientWithBaseURI(endpoint) - configureAuthFunc(&appServiceEnvironmentsClient.Client) +func NewClientWithBaseURI(api environments.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + appServiceCertificateOrdersClient, err := appservicecertificateorders.NewAppServiceCertificateOrdersClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building AppServiceCertificateOrders client: %+v", err) + } + configureFunc(appServiceCertificateOrdersClient.Client) - appServicePlansClient := appserviceplans.NewAppServicePlansClientWithBaseURI(endpoint) - configureAuthFunc(&appServicePlansClient.Client) + appServiceEnvironmentsClient, err := appserviceenvironments.NewAppServiceEnvironmentsClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building AppServiceEnvironments client: %+v", err) + } + configureFunc(appServiceEnvironmentsClient.Client) - certificateOrdersDiagnosticsClient := certificateordersdiagnostics.NewCertificateOrdersDiagnosticsClientWithBaseURI(endpoint) - configureAuthFunc(&certificateOrdersDiagnosticsClient.Client) + appServicePlansClient, err := appserviceplans.NewAppServicePlansClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building AppServicePlans client: %+v", err) + } + configureFunc(appServicePlansClient.Client) - certificatesClient := certificates.NewCertificatesClientWithBaseURI(endpoint) - configureAuthFunc(&certificatesClient.Client) + certificateOrdersDiagnosticsClient, err := certificateordersdiagnostics.NewCertificateOrdersDiagnosticsClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building CertificateOrdersDiagnostics client: %+v", err) + } + configureFunc(certificateOrdersDiagnosticsClient.Client) - containerAppsClient := containerapps.NewContainerAppsClientWithBaseURI(endpoint) - configureAuthFunc(&containerAppsClient.Client) + certificatesClient, err := certificates.NewCertificatesClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Certificates client: %+v", err) + } + configureFunc(certificatesClient.Client) - containerAppsRevisionsClient := containerappsrevisions.NewContainerAppsRevisionsClientWithBaseURI(endpoint) - configureAuthFunc(&containerAppsRevisionsClient.Client) + containerAppsClient, err := containerapps.NewContainerAppsClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ContainerApps client: %+v", err) + } + configureFunc(containerAppsClient.Client) - deletedWebAppsClient := deletedwebapps.NewDeletedWebAppsClientWithBaseURI(endpoint) - configureAuthFunc(&deletedWebAppsClient.Client) + containerAppsRevisionsClient, err := containerappsrevisions.NewContainerAppsRevisionsClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ContainerAppsRevisions client: %+v", err) + } + configureFunc(containerAppsRevisionsClient.Client) - diagnosticsClient := diagnostics.NewDiagnosticsClientWithBaseURI(endpoint) - configureAuthFunc(&diagnosticsClient.Client) + deletedWebAppsClient, err := deletedwebapps.NewDeletedWebAppsClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building DeletedWebApps client: %+v", err) + } + configureFunc(deletedWebAppsClient.Client) - domainsClient := domains.NewDomainsClientWithBaseURI(endpoint) - configureAuthFunc(&domainsClient.Client) + diagnosticsClient, err := diagnostics.NewDiagnosticsClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Diagnostics client: %+v", err) + } + configureFunc(diagnosticsClient.Client) - globalClient := global.NewGlobalClientWithBaseURI(endpoint) - configureAuthFunc(&globalClient.Client) + domainsClient, err := domains.NewDomainsClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Domains client: %+v", err) + } + configureFunc(domainsClient.Client) - kubeEnvironmentsClient := kubeenvironments.NewKubeEnvironmentsClientWithBaseURI(endpoint) - configureAuthFunc(&kubeEnvironmentsClient.Client) + globalClient, err := global.NewGlobalClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Global client: %+v", err) + } + configureFunc(globalClient.Client) - providerClient := provider.NewProviderClientWithBaseURI(endpoint) - configureAuthFunc(&providerClient.Client) + kubeEnvironmentsClient, err := kubeenvironments.NewKubeEnvironmentsClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building KubeEnvironments client: %+v", err) + } + configureFunc(kubeEnvironmentsClient.Client) - recommendationsClient := recommendations.NewRecommendationsClientWithBaseURI(endpoint) - configureAuthFunc(&recommendationsClient.Client) + providerClient, err := provider.NewProviderClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Provider client: %+v", err) + } + configureFunc(providerClient.Client) - resourceHealthMetadataClient := resourcehealthmetadata.NewResourceHealthMetadataClientWithBaseURI(endpoint) - configureAuthFunc(&resourceHealthMetadataClient.Client) + recommendationsClient, err := recommendations.NewRecommendationsClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Recommendations client: %+v", err) + } + configureFunc(recommendationsClient.Client) - resourceProvidersClient := resourceproviders.NewResourceProvidersClientWithBaseURI(endpoint) - configureAuthFunc(&resourceProvidersClient.Client) + resourceHealthMetadataClient, err := resourcehealthmetadata.NewResourceHealthMetadataClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ResourceHealthMetadata client: %+v", err) + } + configureFunc(resourceHealthMetadataClient.Client) - staticSitesClient := staticsites.NewStaticSitesClientWithBaseURI(endpoint) - configureAuthFunc(&staticSitesClient.Client) + resourceProvidersClient, err := resourceproviders.NewResourceProvidersClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building ResourceProviders client: %+v", err) + } + configureFunc(resourceProvidersClient.Client) - topLevelDomainsClient := topleveldomains.NewTopLevelDomainsClientWithBaseURI(endpoint) - configureAuthFunc(&topLevelDomainsClient.Client) + staticSitesClient, err := staticsites.NewStaticSitesClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building StaticSites client: %+v", err) + } + configureFunc(staticSitesClient.Client) - webAppsClient := webapps.NewWebAppsClientWithBaseURI(endpoint) - configureAuthFunc(&webAppsClient.Client) + topLevelDomainsClient, err := topleveldomains.NewTopLevelDomainsClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building TopLevelDomains client: %+v", err) + } + configureFunc(topLevelDomainsClient.Client) - workflowRunActionsClient := workflowrunactions.NewWorkflowRunActionsClientWithBaseURI(endpoint) - configureAuthFunc(&workflowRunActionsClient.Client) + webAppsClient, err := webapps.NewWebAppsClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building WebApps client: %+v", err) + } + configureFunc(webAppsClient.Client) - workflowRunsClient := workflowruns.NewWorkflowRunsClientWithBaseURI(endpoint) - configureAuthFunc(&workflowRunsClient.Client) + workflowRunActionsClient, err := workflowrunactions.NewWorkflowRunActionsClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building WorkflowRunActions client: %+v", err) + } + configureFunc(workflowRunActionsClient.Client) - workflowTriggerHistoriesClient := workflowtriggerhistories.NewWorkflowTriggerHistoriesClientWithBaseURI(endpoint) - configureAuthFunc(&workflowTriggerHistoriesClient.Client) + workflowRunsClient, err := workflowruns.NewWorkflowRunsClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building WorkflowRuns client: %+v", err) + } + configureFunc(workflowRunsClient.Client) - workflowTriggersClient := workflowtriggers.NewWorkflowTriggersClientWithBaseURI(endpoint) - configureAuthFunc(&workflowTriggersClient.Client) + workflowTriggerHistoriesClient, err := workflowtriggerhistories.NewWorkflowTriggerHistoriesClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building WorkflowTriggerHistories client: %+v", err) + } + configureFunc(workflowTriggerHistoriesClient.Client) - workflowVersionsClient := workflowversions.NewWorkflowVersionsClientWithBaseURI(endpoint) - configureAuthFunc(&workflowVersionsClient.Client) + workflowTriggersClient, err := workflowtriggers.NewWorkflowTriggersClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building WorkflowTriggers client: %+v", err) + } + configureFunc(workflowTriggersClient.Client) - workflowsClient := workflows.NewWorkflowsClientWithBaseURI(endpoint) - configureAuthFunc(&workflowsClient.Client) + workflowVersionsClient, err := workflowversions.NewWorkflowVersionsClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building WorkflowVersions client: %+v", err) + } + configureFunc(workflowVersionsClient.Client) - return Client{ - AppServiceCertificateOrders: &appServiceCertificateOrdersClient, - AppServiceEnvironments: &appServiceEnvironmentsClient, - AppServicePlans: &appServicePlansClient, - CertificateOrdersDiagnostics: &certificateOrdersDiagnosticsClient, - Certificates: &certificatesClient, - ContainerApps: &containerAppsClient, - ContainerAppsRevisions: &containerAppsRevisionsClient, - DeletedWebApps: &deletedWebAppsClient, - Diagnostics: &diagnosticsClient, - Domains: &domainsClient, - Global: &globalClient, - KubeEnvironments: &kubeEnvironmentsClient, - Provider: &providerClient, - Recommendations: &recommendationsClient, - ResourceHealthMetadata: &resourceHealthMetadataClient, - ResourceProviders: &resourceProvidersClient, - StaticSites: &staticSitesClient, - TopLevelDomains: &topLevelDomainsClient, - WebApps: &webAppsClient, - WorkflowRunActions: &workflowRunActionsClient, - WorkflowRuns: &workflowRunsClient, - WorkflowTriggerHistories: &workflowTriggerHistoriesClient, - WorkflowTriggers: &workflowTriggersClient, - WorkflowVersions: &workflowVersionsClient, - Workflows: &workflowsClient, + workflowsClient, err := workflows.NewWorkflowsClientWithBaseURI(api) + if err != nil { + return nil, fmt.Errorf("building Workflows client: %+v", err) } + configureFunc(workflowsClient.Client) + + return &Client{ + AppServiceCertificateOrders: appServiceCertificateOrdersClient, + AppServiceEnvironments: appServiceEnvironmentsClient, + AppServicePlans: appServicePlansClient, + CertificateOrdersDiagnostics: certificateOrdersDiagnosticsClient, + Certificates: certificatesClient, + ContainerApps: containerAppsClient, + ContainerAppsRevisions: containerAppsRevisionsClient, + DeletedWebApps: deletedWebAppsClient, + Diagnostics: diagnosticsClient, + Domains: domainsClient, + Global: globalClient, + KubeEnvironments: kubeEnvironmentsClient, + Provider: providerClient, + Recommendations: recommendationsClient, + ResourceHealthMetadata: resourceHealthMetadataClient, + ResourceProviders: resourceProvidersClient, + StaticSites: staticSitesClient, + TopLevelDomains: topLevelDomainsClient, + WebApps: webAppsClient, + WorkflowRunActions: workflowRunActionsClient, + WorkflowRuns: workflowRunsClient, + WorkflowTriggerHistories: workflowTriggerHistoriesClient, + WorkflowTriggers: workflowTriggersClient, + WorkflowVersions: workflowVersionsClient, + Workflows: workflowsClient, + }, nil } diff --git a/resource-manager/web/2022-09-01/containerapps/client.go b/resource-manager/web/2022-09-01/containerapps/client.go index a0d5c49ca4a..e416f85d501 100644 --- a/resource-manager/web/2022-09-01/containerapps/client.go +++ b/resource-manager/web/2022-09-01/containerapps/client.go @@ -1,18 +1,26 @@ package containerapps -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 ContainerAppsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewContainerAppsClientWithBaseURI(endpoint string) ContainerAppsClient { - return ContainerAppsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewContainerAppsClientWithBaseURI(api environments.Api) (*ContainerAppsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "containerapps", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ContainerAppsClient: %+v", err) } + + return &ContainerAppsClient{ + Client: client, + }, nil } diff --git a/resource-manager/web/2022-09-01/containerapps/constants.go b/resource-manager/web/2022-09-01/containerapps/constants.go index 0255f88104f..f6e8265656f 100644 --- a/resource-manager/web/2022-09-01/containerapps/constants.go +++ b/resource-manager/web/2022-09-01/containerapps/constants.go @@ -1,6 +1,10 @@ package containerapps -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. @@ -19,6 +23,19 @@ func PossibleValuesForActiveRevisionsMode() []string { } } +func (s *ActiveRevisionsMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseActiveRevisionsMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseActiveRevisionsMode(input string) (*ActiveRevisionsMode, error) { vals := map[string]ActiveRevisionsMode{ "multiple": ActiveRevisionsModeMultiple, @@ -51,6 +68,19 @@ func PossibleValuesForContainerAppProvisioningState() []string { } } +func (s *ContainerAppProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseContainerAppProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseContainerAppProvisioningState(input string) (*ContainerAppProvisioningState, error) { vals := map[string]ContainerAppProvisioningState{ "canceled": ContainerAppProvisioningStateCanceled, @@ -83,6 +113,19 @@ func PossibleValuesForIngressTransportMethod() []string { } } +func (s *IngressTransportMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIngressTransportMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseIngressTransportMethod(input string) (*IngressTransportMethod, error) { vals := map[string]IngressTransportMethod{ "auto": IngressTransportMethodAuto, diff --git a/resource-manager/web/2022-09-01/containerapps/method_createorupdate.go b/resource-manager/web/2022-09-01/containerapps/method_createorupdate.go new file mode 100644 index 00000000000..646e9316f4d --- /dev/null +++ b/resource-manager/web/2022-09-01/containerapps/method_createorupdate.go @@ -0,0 +1,74 @@ +package containerapps + +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 +} + +// CreateOrUpdate ... +func (c ContainerAppsClient) CreateOrUpdate(ctx context.Context, id ProviderContainerAppId, input ContainerApp) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 ContainerAppsClient) CreateOrUpdateThenPoll(ctx context.Context, id ProviderContainerAppId, input ContainerApp) 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 +} diff --git a/resource-manager/web/2022-09-01/containerapps/method_createorupdate_autorest.go b/resource-manager/web/2022-09-01/containerapps/method_createorupdate_autorest.go deleted file mode 100644 index fa046d96428..00000000000 --- a/resource-manager/web/2022-09-01/containerapps/method_createorupdate_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package containerapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateOrUpdate ... -func (c ContainerAppsClient) CreateOrUpdate(ctx context.Context, id ProviderContainerAppId, input ContainerApp) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "containerapps.ContainerAppsClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "containerapps.ContainerAppsClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c ContainerAppsClient) CreateOrUpdateThenPoll(ctx context.Context, id ProviderContainerAppId, input ContainerApp) error { - result, err := c.CreateOrUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateOrUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateOrUpdate: %+v", err) - } - - return nil -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c ContainerAppsClient) preparerForCreateOrUpdate(ctx context.Context, id ProviderContainerAppId, input ContainerApp) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateOrUpdate sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c ContainerAppsClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/containerapps/method_delete.go b/resource-manager/web/2022-09-01/containerapps/method_delete.go new file mode 100644 index 00000000000..bd2e1f8effc --- /dev/null +++ b/resource-manager/web/2022-09-01/containerapps/method_delete.go @@ -0,0 +1,71 @@ +package containerapps + +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 ContainerAppsClient) Delete(ctx context.Context, id ProviderContainerAppId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 ContainerAppsClient) DeleteThenPoll(ctx context.Context, id ProviderContainerAppId) 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 +} diff --git a/resource-manager/web/2022-09-01/containerapps/method_delete_autorest.go b/resource-manager/web/2022-09-01/containerapps/method_delete_autorest.go deleted file mode 100644 index ee7b4e25e84..00000000000 --- a/resource-manager/web/2022-09-01/containerapps/method_delete_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package containerapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// Delete ... -func (c ContainerAppsClient) Delete(ctx context.Context, id ProviderContainerAppId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "containerapps.ContainerAppsClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "containerapps.ContainerAppsClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c ContainerAppsClient) DeleteThenPoll(ctx context.Context, id ProviderContainerAppId) error { - result, err := c.Delete(ctx, id) - if err != nil { - return fmt.Errorf("performing Delete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Delete: %+v", err) - } - - return nil -} - -// preparerForDelete prepares the Delete request. -func (c ContainerAppsClient) preparerForDelete(ctx context.Context, id ProviderContainerAppId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDelete sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (c ContainerAppsClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/containerapps/method_get.go b/resource-manager/web/2022-09-01/containerapps/method_get.go new file mode 100644 index 00000000000..0903f8129c3 --- /dev/null +++ b/resource-manager/web/2022-09-01/containerapps/method_get.go @@ -0,0 +1,51 @@ +package containerapps + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ContainerApp +} + +// Get ... +func (c ContainerAppsClient) Get(ctx context.Context, id ProviderContainerAppId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/containerapps/method_get_autorest.go b/resource-manager/web/2022-09-01/containerapps/method_get_autorest.go deleted file mode 100644 index 9e6e26eb71c..00000000000 --- a/resource-manager/web/2022-09-01/containerapps/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package containerapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *ContainerApp -} - -// Get ... -func (c ContainerAppsClient) Get(ctx context.Context, id ProviderContainerAppId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "containerapps.ContainerAppsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "containerapps.ContainerAppsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "containerapps.ContainerAppsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c ContainerAppsClient) preparerForGet(ctx context.Context, id ProviderContainerAppId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c ContainerAppsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/containerapps/method_listbyresourcegroup.go b/resource-manager/web/2022-09-01/containerapps/method_listbyresourcegroup.go new file mode 100644 index 00000000000..d411e2961ab --- /dev/null +++ b/resource-manager/web/2022-09-01/containerapps/method_listbyresourcegroup.go @@ -0,0 +1,90 @@ +package containerapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ContainerApp +} + +type ListByResourceGroupCompleteResult struct { + Items []ContainerApp +} + +// ListByResourceGroup ... +func (c ContainerAppsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/containerApps", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ContainerApp `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c ContainerAppsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, ContainerAppOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ContainerAppsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ContainerAppOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]ContainerApp, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/containerapps/method_listbyresourcegroup_autorest.go b/resource-manager/web/2022-09-01/containerapps/method_listbyresourcegroup_autorest.go deleted file mode 100644 index 6f32308fa6a..00000000000 --- a/resource-manager/web/2022-09-01/containerapps/method_listbyresourcegroup_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package containerapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByResourceGroupOperationResponse struct { - HttpResponse *http.Response - Model *[]ContainerApp - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByResourceGroupOperationResponse, error) -} - -type ListByResourceGroupCompleteResult struct { - Items []ContainerApp -} - -func (r ListByResourceGroupOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByResourceGroupOperationResponse) LoadMore(ctx context.Context) (resp ListByResourceGroupOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByResourceGroup ... -func (c ContainerAppsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (resp ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroup(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "containerapps.ContainerAppsClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "containerapps.ContainerAppsClient", "ListByResourceGroup", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByResourceGroup(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "containerapps.ContainerAppsClient", "ListByResourceGroup", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByResourceGroup prepares the ListByResourceGroup request. -func (c ContainerAppsClient) preparerForListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Web/containerApps", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByResourceGroupWithNextLink prepares the ListByResourceGroup request with the given nextLink token. -func (c ContainerAppsClient) preparerForListByResourceGroupWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByResourceGroup handles the response to the ListByResourceGroup request. The method always -// closes the http.Response Body. -func (c ContainerAppsClient) responderForListByResourceGroup(resp *http.Response) (result ListByResourceGroupOperationResponse, err error) { - type page struct { - Values []ContainerApp `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroupWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "containerapps.ContainerAppsClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "containerapps.ContainerAppsClient", "ListByResourceGroup", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByResourceGroup(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "containerapps.ContainerAppsClient", "ListByResourceGroup", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByResourceGroupComplete retrieves all of the results into a single object -func (c ContainerAppsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { - return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, ContainerAppOperationPredicate{}) -} - -// ListByResourceGroupCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ContainerAppsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ContainerAppOperationPredicate) (resp ListByResourceGroupCompleteResult, err error) { - items := make([]ContainerApp, 0) - - page, err := c.ListByResourceGroup(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByResourceGroupCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/containerapps/method_listbysubscription.go b/resource-manager/web/2022-09-01/containerapps/method_listbysubscription.go new file mode 100644 index 00000000000..f3ebbe4b4f7 --- /dev/null +++ b/resource-manager/web/2022-09-01/containerapps/method_listbysubscription.go @@ -0,0 +1,90 @@ +package containerapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ContainerApp +} + +type ListBySubscriptionCompleteResult struct { + Items []ContainerApp +} + +// ListBySubscription ... +func (c ContainerAppsClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/containerApps", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ContainerApp `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c ContainerAppsClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, ContainerAppOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ContainerAppsClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ContainerAppOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]ContainerApp, 0) + + resp, err := c.ListBySubscription(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListBySubscriptionCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/containerapps/method_listbysubscription_autorest.go b/resource-manager/web/2022-09-01/containerapps/method_listbysubscription_autorest.go deleted file mode 100644 index 20c88a8c5ef..00000000000 --- a/resource-manager/web/2022-09-01/containerapps/method_listbysubscription_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package containerapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListBySubscriptionOperationResponse struct { - HttpResponse *http.Response - Model *[]ContainerApp - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListBySubscriptionOperationResponse, error) -} - -type ListBySubscriptionCompleteResult struct { - Items []ContainerApp -} - -func (r ListBySubscriptionOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListBySubscriptionOperationResponse) LoadMore(ctx context.Context) (resp ListBySubscriptionOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListBySubscription ... -func (c ContainerAppsClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (resp ListBySubscriptionOperationResponse, err error) { - req, err := c.preparerForListBySubscription(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "containerapps.ContainerAppsClient", "ListBySubscription", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "containerapps.ContainerAppsClient", "ListBySubscription", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListBySubscription(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "containerapps.ContainerAppsClient", "ListBySubscription", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListBySubscription prepares the ListBySubscription request. -func (c ContainerAppsClient) preparerForListBySubscription(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Web/containerApps", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListBySubscriptionWithNextLink prepares the ListBySubscription request with the given nextLink token. -func (c ContainerAppsClient) preparerForListBySubscriptionWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListBySubscription handles the response to the ListBySubscription request. The method always -// closes the http.Response Body. -func (c ContainerAppsClient) responderForListBySubscription(resp *http.Response) (result ListBySubscriptionOperationResponse, err error) { - type page struct { - Values []ContainerApp `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListBySubscriptionOperationResponse, err error) { - req, err := c.preparerForListBySubscriptionWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "containerapps.ContainerAppsClient", "ListBySubscription", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "containerapps.ContainerAppsClient", "ListBySubscription", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListBySubscription(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "containerapps.ContainerAppsClient", "ListBySubscription", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListBySubscriptionComplete retrieves all of the results into a single object -func (c ContainerAppsClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { - return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, ContainerAppOperationPredicate{}) -} - -// ListBySubscriptionCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ContainerAppsClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ContainerAppOperationPredicate) (resp ListBySubscriptionCompleteResult, err error) { - items := make([]ContainerApp, 0) - - page, err := c.ListBySubscription(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListBySubscriptionCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/containerapps/method_listsecrets.go b/resource-manager/web/2022-09-01/containerapps/method_listsecrets.go new file mode 100644 index 00000000000..997008d572d --- /dev/null +++ b/resource-manager/web/2022-09-01/containerapps/method_listsecrets.go @@ -0,0 +1,52 @@ +package containerapps + +import ( + "context" + "fmt" + "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 ListSecretsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SecretsCollection +} + +// ListSecrets ... +func (c ContainerAppsClient) ListSecrets(ctx context.Context, id ContainerAppId) (result ListSecretsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listSecrets", 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 +} diff --git a/resource-manager/web/2022-09-01/containerapps/method_listsecrets_autorest.go b/resource-manager/web/2022-09-01/containerapps/method_listsecrets_autorest.go deleted file mode 100644 index c6ad38b777c..00000000000 --- a/resource-manager/web/2022-09-01/containerapps/method_listsecrets_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package containerapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListSecretsOperationResponse struct { - HttpResponse *http.Response - Model *SecretsCollection -} - -// ListSecrets ... -func (c ContainerAppsClient) ListSecrets(ctx context.Context, id ContainerAppId) (result ListSecretsOperationResponse, err error) { - req, err := c.preparerForListSecrets(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "containerapps.ContainerAppsClient", "ListSecrets", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "containerapps.ContainerAppsClient", "ListSecrets", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListSecrets(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "containerapps.ContainerAppsClient", "ListSecrets", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListSecrets prepares the ListSecrets request. -func (c ContainerAppsClient) preparerForListSecrets(ctx context.Context, id ContainerAppId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/listSecrets", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListSecrets handles the response to the ListSecrets request. The method always -// closes the http.Response Body. -func (c ContainerAppsClient) responderForListSecrets(resp *http.Response) (result ListSecretsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/containerappsrevisions/client.go b/resource-manager/web/2022-09-01/containerappsrevisions/client.go index 68c18534395..4dded455868 100644 --- a/resource-manager/web/2022-09-01/containerappsrevisions/client.go +++ b/resource-manager/web/2022-09-01/containerappsrevisions/client.go @@ -1,18 +1,26 @@ package containerappsrevisions -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 ContainerAppsRevisionsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewContainerAppsRevisionsClientWithBaseURI(endpoint string) ContainerAppsRevisionsClient { - return ContainerAppsRevisionsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewContainerAppsRevisionsClientWithBaseURI(api environments.Api) (*ContainerAppsRevisionsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "containerappsrevisions", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ContainerAppsRevisionsClient: %+v", err) } + + return &ContainerAppsRevisionsClient{ + Client: client, + }, nil } diff --git a/resource-manager/web/2022-09-01/containerappsrevisions/constants.go b/resource-manager/web/2022-09-01/containerappsrevisions/constants.go index 6c1f36b22a9..0405b958db3 100644 --- a/resource-manager/web/2022-09-01/containerappsrevisions/constants.go +++ b/resource-manager/web/2022-09-01/containerappsrevisions/constants.go @@ -1,6 +1,10 @@ package containerappsrevisions -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. @@ -21,6 +25,19 @@ func PossibleValuesForRevisionHealthState() []string { } } +func (s *RevisionHealthState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRevisionHealthState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseRevisionHealthState(input string) (*RevisionHealthState, error) { vals := map[string]RevisionHealthState{ "healthy": RevisionHealthStateHealthy, @@ -56,6 +73,19 @@ func PossibleValuesForRevisionProvisioningState() []string { } } +func (s *RevisionProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRevisionProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseRevisionProvisioningState(input string) (*RevisionProvisioningState, error) { vals := map[string]RevisionProvisioningState{ "deprovisioned": RevisionProvisioningStateDeprovisioned, diff --git a/resource-manager/web/2022-09-01/containerappsrevisions/method_activaterevision.go b/resource-manager/web/2022-09-01/containerappsrevisions/method_activaterevision.go new file mode 100644 index 00000000000..45880783d47 --- /dev/null +++ b/resource-manager/web/2022-09-01/containerappsrevisions/method_activaterevision.go @@ -0,0 +1,47 @@ +package containerappsrevisions + +import ( + "context" + "fmt" + "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 ActivateRevisionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ActivateRevision ... +func (c ContainerAppsRevisionsClient) ActivateRevision(ctx context.Context, id RevisionId) (result ActivateRevisionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/activate", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/containerappsrevisions/method_activaterevision_autorest.go b/resource-manager/web/2022-09-01/containerappsrevisions/method_activaterevision_autorest.go deleted file mode 100644 index 7d6701a4a3e..00000000000 --- a/resource-manager/web/2022-09-01/containerappsrevisions/method_activaterevision_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package containerappsrevisions - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ActivateRevisionOperationResponse struct { - HttpResponse *http.Response -} - -// ActivateRevision ... -func (c ContainerAppsRevisionsClient) ActivateRevision(ctx context.Context, id RevisionId) (result ActivateRevisionOperationResponse, err error) { - req, err := c.preparerForActivateRevision(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "containerappsrevisions.ContainerAppsRevisionsClient", "ActivateRevision", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "containerappsrevisions.ContainerAppsRevisionsClient", "ActivateRevision", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForActivateRevision(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "containerappsrevisions.ContainerAppsRevisionsClient", "ActivateRevision", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForActivateRevision prepares the ActivateRevision request. -func (c ContainerAppsRevisionsClient) preparerForActivateRevision(ctx context.Context, id RevisionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/activate", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForActivateRevision handles the response to the ActivateRevision request. The method always -// closes the http.Response Body. -func (c ContainerAppsRevisionsClient) responderForActivateRevision(resp *http.Response) (result ActivateRevisionOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/containerappsrevisions/method_deactivaterevision.go b/resource-manager/web/2022-09-01/containerappsrevisions/method_deactivaterevision.go new file mode 100644 index 00000000000..e855b16a44a --- /dev/null +++ b/resource-manager/web/2022-09-01/containerappsrevisions/method_deactivaterevision.go @@ -0,0 +1,47 @@ +package containerappsrevisions + +import ( + "context" + "fmt" + "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 DeactivateRevisionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeactivateRevision ... +func (c ContainerAppsRevisionsClient) DeactivateRevision(ctx context.Context, id RevisionId) (result DeactivateRevisionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/deactivate", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/containerappsrevisions/method_deactivaterevision_autorest.go b/resource-manager/web/2022-09-01/containerappsrevisions/method_deactivaterevision_autorest.go deleted file mode 100644 index 821d34b2851..00000000000 --- a/resource-manager/web/2022-09-01/containerappsrevisions/method_deactivaterevision_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package containerappsrevisions - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeactivateRevisionOperationResponse struct { - HttpResponse *http.Response -} - -// DeactivateRevision ... -func (c ContainerAppsRevisionsClient) DeactivateRevision(ctx context.Context, id RevisionId) (result DeactivateRevisionOperationResponse, err error) { - req, err := c.preparerForDeactivateRevision(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "containerappsrevisions.ContainerAppsRevisionsClient", "DeactivateRevision", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "containerappsrevisions.ContainerAppsRevisionsClient", "DeactivateRevision", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeactivateRevision(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "containerappsrevisions.ContainerAppsRevisionsClient", "DeactivateRevision", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeactivateRevision prepares the DeactivateRevision request. -func (c ContainerAppsRevisionsClient) preparerForDeactivateRevision(ctx context.Context, id RevisionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/deactivate", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeactivateRevision handles the response to the DeactivateRevision request. The method always -// closes the http.Response Body. -func (c ContainerAppsRevisionsClient) responderForDeactivateRevision(resp *http.Response) (result DeactivateRevisionOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/containerappsrevisions/method_getrevision.go b/resource-manager/web/2022-09-01/containerappsrevisions/method_getrevision.go new file mode 100644 index 00000000000..9356f8aa6e0 --- /dev/null +++ b/resource-manager/web/2022-09-01/containerappsrevisions/method_getrevision.go @@ -0,0 +1,51 @@ +package containerappsrevisions + +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 GetRevisionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Revision +} + +// GetRevision ... +func (c ContainerAppsRevisionsClient) GetRevision(ctx context.Context, id RevisionId) (result GetRevisionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/containerappsrevisions/method_getrevision_autorest.go b/resource-manager/web/2022-09-01/containerappsrevisions/method_getrevision_autorest.go deleted file mode 100644 index 9cc457910e0..00000000000 --- a/resource-manager/web/2022-09-01/containerappsrevisions/method_getrevision_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package containerappsrevisions - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetRevisionOperationResponse struct { - HttpResponse *http.Response - Model *Revision -} - -// GetRevision ... -func (c ContainerAppsRevisionsClient) GetRevision(ctx context.Context, id RevisionId) (result GetRevisionOperationResponse, err error) { - req, err := c.preparerForGetRevision(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "containerappsrevisions.ContainerAppsRevisionsClient", "GetRevision", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "containerappsrevisions.ContainerAppsRevisionsClient", "GetRevision", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetRevision(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "containerappsrevisions.ContainerAppsRevisionsClient", "GetRevision", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetRevision prepares the GetRevision request. -func (c ContainerAppsRevisionsClient) preparerForGetRevision(ctx context.Context, id RevisionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetRevision handles the response to the GetRevision request. The method always -// closes the http.Response Body. -func (c ContainerAppsRevisionsClient) responderForGetRevision(resp *http.Response) (result GetRevisionOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/containerappsrevisions/method_listrevisions.go b/resource-manager/web/2022-09-01/containerappsrevisions/method_listrevisions.go new file mode 100644 index 00000000000..01138ee32c0 --- /dev/null +++ b/resource-manager/web/2022-09-01/containerappsrevisions/method_listrevisions.go @@ -0,0 +1,89 @@ +package containerappsrevisions + +import ( + "context" + "fmt" + "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 ListRevisionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Revision +} + +type ListRevisionsCompleteResult struct { + Items []Revision +} + +// ListRevisions ... +func (c ContainerAppsRevisionsClient) ListRevisions(ctx context.Context, id ProviderContainerAppId) (result ListRevisionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/revisions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Revision `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListRevisionsComplete retrieves all the results into a single object +func (c ContainerAppsRevisionsClient) ListRevisionsComplete(ctx context.Context, id ProviderContainerAppId) (ListRevisionsCompleteResult, error) { + return c.ListRevisionsCompleteMatchingPredicate(ctx, id, RevisionOperationPredicate{}) +} + +// ListRevisionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ContainerAppsRevisionsClient) ListRevisionsCompleteMatchingPredicate(ctx context.Context, id ProviderContainerAppId, predicate RevisionOperationPredicate) (result ListRevisionsCompleteResult, err error) { + items := make([]Revision, 0) + + resp, err := c.ListRevisions(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListRevisionsCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/containerappsrevisions/method_listrevisions_autorest.go b/resource-manager/web/2022-09-01/containerappsrevisions/method_listrevisions_autorest.go deleted file mode 100644 index c3f8e850f2c..00000000000 --- a/resource-manager/web/2022-09-01/containerappsrevisions/method_listrevisions_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package containerappsrevisions - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListRevisionsOperationResponse struct { - HttpResponse *http.Response - Model *[]Revision - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListRevisionsOperationResponse, error) -} - -type ListRevisionsCompleteResult struct { - Items []Revision -} - -func (r ListRevisionsOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListRevisionsOperationResponse) LoadMore(ctx context.Context) (resp ListRevisionsOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListRevisions ... -func (c ContainerAppsRevisionsClient) ListRevisions(ctx context.Context, id ProviderContainerAppId) (resp ListRevisionsOperationResponse, err error) { - req, err := c.preparerForListRevisions(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "containerappsrevisions.ContainerAppsRevisionsClient", "ListRevisions", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "containerappsrevisions.ContainerAppsRevisionsClient", "ListRevisions", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListRevisions(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "containerappsrevisions.ContainerAppsRevisionsClient", "ListRevisions", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListRevisions prepares the ListRevisions request. -func (c ContainerAppsRevisionsClient) preparerForListRevisions(ctx context.Context, id ProviderContainerAppId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/revisions", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListRevisionsWithNextLink prepares the ListRevisions request with the given nextLink token. -func (c ContainerAppsRevisionsClient) preparerForListRevisionsWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListRevisions handles the response to the ListRevisions request. The method always -// closes the http.Response Body. -func (c ContainerAppsRevisionsClient) responderForListRevisions(resp *http.Response) (result ListRevisionsOperationResponse, err error) { - type page struct { - Values []Revision `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListRevisionsOperationResponse, err error) { - req, err := c.preparerForListRevisionsWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "containerappsrevisions.ContainerAppsRevisionsClient", "ListRevisions", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "containerappsrevisions.ContainerAppsRevisionsClient", "ListRevisions", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListRevisions(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "containerappsrevisions.ContainerAppsRevisionsClient", "ListRevisions", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListRevisionsComplete retrieves all of the results into a single object -func (c ContainerAppsRevisionsClient) ListRevisionsComplete(ctx context.Context, id ProviderContainerAppId) (ListRevisionsCompleteResult, error) { - return c.ListRevisionsCompleteMatchingPredicate(ctx, id, RevisionOperationPredicate{}) -} - -// ListRevisionsCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ContainerAppsRevisionsClient) ListRevisionsCompleteMatchingPredicate(ctx context.Context, id ProviderContainerAppId, predicate RevisionOperationPredicate) (resp ListRevisionsCompleteResult, err error) { - items := make([]Revision, 0) - - page, err := c.ListRevisions(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListRevisionsCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/containerappsrevisions/method_restartrevision.go b/resource-manager/web/2022-09-01/containerappsrevisions/method_restartrevision.go new file mode 100644 index 00000000000..969e12a327b --- /dev/null +++ b/resource-manager/web/2022-09-01/containerappsrevisions/method_restartrevision.go @@ -0,0 +1,47 @@ +package containerappsrevisions + +import ( + "context" + "fmt" + "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 RestartRevisionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// RestartRevision ... +func (c ContainerAppsRevisionsClient) RestartRevision(ctx context.Context, id RevisionId) (result RestartRevisionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restart", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/containerappsrevisions/method_restartrevision_autorest.go b/resource-manager/web/2022-09-01/containerappsrevisions/method_restartrevision_autorest.go deleted file mode 100644 index d1d7bb6594c..00000000000 --- a/resource-manager/web/2022-09-01/containerappsrevisions/method_restartrevision_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package containerappsrevisions - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type RestartRevisionOperationResponse struct { - HttpResponse *http.Response -} - -// RestartRevision ... -func (c ContainerAppsRevisionsClient) RestartRevision(ctx context.Context, id RevisionId) (result RestartRevisionOperationResponse, err error) { - req, err := c.preparerForRestartRevision(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "containerappsrevisions.ContainerAppsRevisionsClient", "RestartRevision", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "containerappsrevisions.ContainerAppsRevisionsClient", "RestartRevision", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForRestartRevision(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "containerappsrevisions.ContainerAppsRevisionsClient", "RestartRevision", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForRestartRevision prepares the RestartRevision request. -func (c ContainerAppsRevisionsClient) preparerForRestartRevision(ctx context.Context, id RevisionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/restart", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForRestartRevision handles the response to the RestartRevision request. The method always -// closes the http.Response Body. -func (c ContainerAppsRevisionsClient) responderForRestartRevision(resp *http.Response) (result RestartRevisionOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/deletedwebapps/client.go b/resource-manager/web/2022-09-01/deletedwebapps/client.go index c38d8273bea..4385e47f870 100644 --- a/resource-manager/web/2022-09-01/deletedwebapps/client.go +++ b/resource-manager/web/2022-09-01/deletedwebapps/client.go @@ -1,18 +1,26 @@ package deletedwebapps -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 DeletedWebAppsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewDeletedWebAppsClientWithBaseURI(endpoint string) DeletedWebAppsClient { - return DeletedWebAppsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewDeletedWebAppsClientWithBaseURI(api environments.Api) (*DeletedWebAppsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "deletedwebapps", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DeletedWebAppsClient: %+v", err) } + + return &DeletedWebAppsClient{ + Client: client, + }, nil } diff --git a/resource-manager/web/2022-09-01/deletedwebapps/method_getdeletedwebappbylocation.go b/resource-manager/web/2022-09-01/deletedwebapps/method_getdeletedwebappbylocation.go new file mode 100644 index 00000000000..7b10886b2c5 --- /dev/null +++ b/resource-manager/web/2022-09-01/deletedwebapps/method_getdeletedwebappbylocation.go @@ -0,0 +1,51 @@ +package deletedwebapps + +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 GetDeletedWebAppByLocationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DeletedSite +} + +// GetDeletedWebAppByLocation ... +func (c DeletedWebAppsClient) GetDeletedWebAppByLocation(ctx context.Context, id LocationDeletedSiteId) (result GetDeletedWebAppByLocationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/deletedwebapps/method_getdeletedwebappbylocation_autorest.go b/resource-manager/web/2022-09-01/deletedwebapps/method_getdeletedwebappbylocation_autorest.go deleted file mode 100644 index b46105706a3..00000000000 --- a/resource-manager/web/2022-09-01/deletedwebapps/method_getdeletedwebappbylocation_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package deletedwebapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetDeletedWebAppByLocationOperationResponse struct { - HttpResponse *http.Response - Model *DeletedSite -} - -// GetDeletedWebAppByLocation ... -func (c DeletedWebAppsClient) GetDeletedWebAppByLocation(ctx context.Context, id LocationDeletedSiteId) (result GetDeletedWebAppByLocationOperationResponse, err error) { - req, err := c.preparerForGetDeletedWebAppByLocation(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "deletedwebapps.DeletedWebAppsClient", "GetDeletedWebAppByLocation", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "deletedwebapps.DeletedWebAppsClient", "GetDeletedWebAppByLocation", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetDeletedWebAppByLocation(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "deletedwebapps.DeletedWebAppsClient", "GetDeletedWebAppByLocation", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetDeletedWebAppByLocation prepares the GetDeletedWebAppByLocation request. -func (c DeletedWebAppsClient) preparerForGetDeletedWebAppByLocation(ctx context.Context, id LocationDeletedSiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetDeletedWebAppByLocation handles the response to the GetDeletedWebAppByLocation request. The method always -// closes the http.Response Body. -func (c DeletedWebAppsClient) responderForGetDeletedWebAppByLocation(resp *http.Response) (result GetDeletedWebAppByLocationOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/deletedwebapps/method_list.go b/resource-manager/web/2022-09-01/deletedwebapps/method_list.go new file mode 100644 index 00000000000..e92582e0dda --- /dev/null +++ b/resource-manager/web/2022-09-01/deletedwebapps/method_list.go @@ -0,0 +1,90 @@ +package deletedwebapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DeletedSite +} + +type ListCompleteResult struct { + Items []DeletedSite +} + +// List ... +func (c DeletedWebAppsClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/deletedSites", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]DeletedSite `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c DeletedWebAppsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, DeletedSiteOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DeletedWebAppsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate DeletedSiteOperationPredicate) (result ListCompleteResult, err error) { + items := make([]DeletedSite, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/deletedwebapps/method_list_autorest.go b/resource-manager/web/2022-09-01/deletedwebapps/method_list_autorest.go deleted file mode 100644 index 290ec07eca4..00000000000 --- a/resource-manager/web/2022-09-01/deletedwebapps/method_list_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package deletedwebapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListOperationResponse struct { - HttpResponse *http.Response - Model *[]DeletedSite - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []DeletedSite -} - -func (r ListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// List ... -func (c DeletedWebAppsClient) List(ctx context.Context, id commonids.SubscriptionId) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "deletedwebapps.DeletedWebAppsClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "deletedwebapps.DeletedWebAppsClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "deletedwebapps.DeletedWebAppsClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c DeletedWebAppsClient) preparerForList(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Web/deletedSites", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c DeletedWebAppsClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForList handles the response to the List request. The method always -// closes the http.Response Body. -func (c DeletedWebAppsClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []DeletedSite `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { - req, err := c.preparerForListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "deletedwebapps.DeletedWebAppsClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "deletedwebapps.DeletedWebAppsClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "deletedwebapps.DeletedWebAppsClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c DeletedWebAppsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, DeletedSiteOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c DeletedWebAppsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate DeletedSiteOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]DeletedSite, 0) - - page, err := c.List(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/deletedwebapps/method_listbylocation.go b/resource-manager/web/2022-09-01/deletedwebapps/method_listbylocation.go new file mode 100644 index 00000000000..86b54c727ba --- /dev/null +++ b/resource-manager/web/2022-09-01/deletedwebapps/method_listbylocation.go @@ -0,0 +1,89 @@ +package deletedwebapps + +import ( + "context" + "fmt" + "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 ListByLocationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DeletedSite +} + +type ListByLocationCompleteResult struct { + Items []DeletedSite +} + +// ListByLocation ... +func (c DeletedWebAppsClient) ListByLocation(ctx context.Context, id ProviderLocationId) (result ListByLocationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/deletedSites", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]DeletedSite `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByLocationComplete retrieves all the results into a single object +func (c DeletedWebAppsClient) ListByLocationComplete(ctx context.Context, id ProviderLocationId) (ListByLocationCompleteResult, error) { + return c.ListByLocationCompleteMatchingPredicate(ctx, id, DeletedSiteOperationPredicate{}) +} + +// ListByLocationCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DeletedWebAppsClient) ListByLocationCompleteMatchingPredicate(ctx context.Context, id ProviderLocationId, predicate DeletedSiteOperationPredicate) (result ListByLocationCompleteResult, err error) { + items := make([]DeletedSite, 0) + + resp, err := c.ListByLocation(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByLocationCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/deletedwebapps/method_listbylocation_autorest.go b/resource-manager/web/2022-09-01/deletedwebapps/method_listbylocation_autorest.go deleted file mode 100644 index 0302df3eb87..00000000000 --- a/resource-manager/web/2022-09-01/deletedwebapps/method_listbylocation_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package deletedwebapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByLocationOperationResponse struct { - HttpResponse *http.Response - Model *[]DeletedSite - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByLocationOperationResponse, error) -} - -type ListByLocationCompleteResult struct { - Items []DeletedSite -} - -func (r ListByLocationOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByLocationOperationResponse) LoadMore(ctx context.Context) (resp ListByLocationOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByLocation ... -func (c DeletedWebAppsClient) ListByLocation(ctx context.Context, id ProviderLocationId) (resp ListByLocationOperationResponse, err error) { - req, err := c.preparerForListByLocation(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "deletedwebapps.DeletedWebAppsClient", "ListByLocation", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "deletedwebapps.DeletedWebAppsClient", "ListByLocation", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByLocation(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "deletedwebapps.DeletedWebAppsClient", "ListByLocation", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByLocation prepares the ListByLocation request. -func (c DeletedWebAppsClient) preparerForListByLocation(ctx context.Context, id ProviderLocationId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/deletedSites", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByLocationWithNextLink prepares the ListByLocation request with the given nextLink token. -func (c DeletedWebAppsClient) preparerForListByLocationWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByLocation handles the response to the ListByLocation request. The method always -// closes the http.Response Body. -func (c DeletedWebAppsClient) responderForListByLocation(resp *http.Response) (result ListByLocationOperationResponse, err error) { - type page struct { - Values []DeletedSite `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByLocationOperationResponse, err error) { - req, err := c.preparerForListByLocationWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "deletedwebapps.DeletedWebAppsClient", "ListByLocation", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "deletedwebapps.DeletedWebAppsClient", "ListByLocation", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByLocation(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "deletedwebapps.DeletedWebAppsClient", "ListByLocation", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByLocationComplete retrieves all of the results into a single object -func (c DeletedWebAppsClient) ListByLocationComplete(ctx context.Context, id ProviderLocationId) (ListByLocationCompleteResult, error) { - return c.ListByLocationCompleteMatchingPredicate(ctx, id, DeletedSiteOperationPredicate{}) -} - -// ListByLocationCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c DeletedWebAppsClient) ListByLocationCompleteMatchingPredicate(ctx context.Context, id ProviderLocationId, predicate DeletedSiteOperationPredicate) (resp ListByLocationCompleteResult, err error) { - items := make([]DeletedSite, 0) - - page, err := c.ListByLocation(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByLocationCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/diagnostics/client.go b/resource-manager/web/2022-09-01/diagnostics/client.go index 5ceda32894a..2a59b0cb111 100644 --- a/resource-manager/web/2022-09-01/diagnostics/client.go +++ b/resource-manager/web/2022-09-01/diagnostics/client.go @@ -1,18 +1,26 @@ package diagnostics -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 DiagnosticsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewDiagnosticsClientWithBaseURI(endpoint string) DiagnosticsClient { - return DiagnosticsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewDiagnosticsClientWithBaseURI(api environments.Api) (*DiagnosticsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "diagnostics", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DiagnosticsClient: %+v", err) } + + return &DiagnosticsClient{ + Client: client, + }, nil } diff --git a/resource-manager/web/2022-09-01/diagnostics/constants.go b/resource-manager/web/2022-09-01/diagnostics/constants.go index bb8262e3a07..47006b35190 100644 --- a/resource-manager/web/2022-09-01/diagnostics/constants.go +++ b/resource-manager/web/2022-09-01/diagnostics/constants.go @@ -1,6 +1,10 @@ package diagnostics -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. @@ -21,6 +25,19 @@ func PossibleValuesForDetectorType() []string { } } +func (s *DetectorType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDetectorType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseDetectorType(input string) (*DetectorType, error) { vals := map[string]DetectorType{ "analysis": DetectorTypeAnalysis, @@ -56,6 +73,19 @@ func PossibleValuesForInsightStatus() []string { } } +func (s *InsightStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseInsightStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseInsightStatus(input string) (*InsightStatus, error) { vals := map[string]InsightStatus{ "critical": InsightStatusCritical, @@ -99,6 +129,19 @@ func PossibleValuesForIssueType() []string { } } +func (s *IssueType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIssueType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseIssueType(input string) (*IssueType, error) { vals := map[string]IssueType{ "appcrash": IssueTypeAppCrash, @@ -179,6 +222,19 @@ func PossibleValuesForRenderingType() []string { } } +func (s *RenderingType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRenderingType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseRenderingType(input string) (*RenderingType, error) { vals := map[string]RenderingType{ "appinsight": RenderingTypeAppInsight, @@ -232,6 +288,19 @@ func PossibleValuesForSolutionType() []string { } } +func (s *SolutionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSolutionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseSolutionType(input string) (*SolutionType, error) { vals := map[string]SolutionType{ "bestpractices": SolutionTypeBestPractices, diff --git a/resource-manager/web/2022-09-01/diagnostics/method_executesiteanalysis.go b/resource-manager/web/2022-09-01/diagnostics/method_executesiteanalysis.go new file mode 100644 index 00000000000..f6926571e25 --- /dev/null +++ b/resource-manager/web/2022-09-01/diagnostics/method_executesiteanalysis.go @@ -0,0 +1,88 @@ +package diagnostics + +import ( + "context" + "fmt" + "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 ExecuteSiteAnalysisOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DiagnosticAnalysis +} + +type ExecuteSiteAnalysisOperationOptions struct { + EndTime *string + StartTime *string + TimeGrain *string +} + +func DefaultExecuteSiteAnalysisOperationOptions() ExecuteSiteAnalysisOperationOptions { + return ExecuteSiteAnalysisOperationOptions{} +} + +func (o ExecuteSiteAnalysisOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ExecuteSiteAnalysisOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ExecuteSiteAnalysisOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.EndTime != nil { + out.Append("endTime", fmt.Sprintf("%v", *o.EndTime)) + } + if o.StartTime != nil { + out.Append("startTime", fmt.Sprintf("%v", *o.StartTime)) + } + if o.TimeGrain != nil { + out.Append("timeGrain", fmt.Sprintf("%v", *o.TimeGrain)) + } + return &out +} + +// ExecuteSiteAnalysis ... +func (c DiagnosticsClient) ExecuteSiteAnalysis(ctx context.Context, id AnalysisId, options ExecuteSiteAnalysisOperationOptions) (result ExecuteSiteAnalysisOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/execute", id.ID()), + OptionsObject: options, + } + + 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 +} diff --git a/resource-manager/web/2022-09-01/diagnostics/method_executesiteanalysis_autorest.go b/resource-manager/web/2022-09-01/diagnostics/method_executesiteanalysis_autorest.go deleted file mode 100644 index 6b1a9099a63..00000000000 --- a/resource-manager/web/2022-09-01/diagnostics/method_executesiteanalysis_autorest.go +++ /dev/null @@ -1,108 +0,0 @@ -package diagnostics - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ExecuteSiteAnalysisOperationResponse struct { - HttpResponse *http.Response - Model *DiagnosticAnalysis -} - -type ExecuteSiteAnalysisOperationOptions struct { - EndTime *string - StartTime *string - TimeGrain *string -} - -func DefaultExecuteSiteAnalysisOperationOptions() ExecuteSiteAnalysisOperationOptions { - return ExecuteSiteAnalysisOperationOptions{} -} - -func (o ExecuteSiteAnalysisOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ExecuteSiteAnalysisOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.EndTime != nil { - out["endTime"] = *o.EndTime - } - - if o.StartTime != nil { - out["startTime"] = *o.StartTime - } - - if o.TimeGrain != nil { - out["timeGrain"] = *o.TimeGrain - } - - return out -} - -// ExecuteSiteAnalysis ... -func (c DiagnosticsClient) ExecuteSiteAnalysis(ctx context.Context, id AnalysisId, options ExecuteSiteAnalysisOperationOptions) (result ExecuteSiteAnalysisOperationResponse, err error) { - req, err := c.preparerForExecuteSiteAnalysis(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ExecuteSiteAnalysis", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ExecuteSiteAnalysis", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForExecuteSiteAnalysis(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ExecuteSiteAnalysis", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForExecuteSiteAnalysis prepares the ExecuteSiteAnalysis request. -func (c DiagnosticsClient) preparerForExecuteSiteAnalysis(ctx context.Context, id AnalysisId, options ExecuteSiteAnalysisOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/execute", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForExecuteSiteAnalysis handles the response to the ExecuteSiteAnalysis request. The method always -// closes the http.Response Body. -func (c DiagnosticsClient) responderForExecuteSiteAnalysis(resp *http.Response) (result ExecuteSiteAnalysisOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/diagnostics/method_executesiteanalysisslot.go b/resource-manager/web/2022-09-01/diagnostics/method_executesiteanalysisslot.go new file mode 100644 index 00000000000..37d4a930461 --- /dev/null +++ b/resource-manager/web/2022-09-01/diagnostics/method_executesiteanalysisslot.go @@ -0,0 +1,88 @@ +package diagnostics + +import ( + "context" + "fmt" + "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 ExecuteSiteAnalysisSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DiagnosticAnalysis +} + +type ExecuteSiteAnalysisSlotOperationOptions struct { + EndTime *string + StartTime *string + TimeGrain *string +} + +func DefaultExecuteSiteAnalysisSlotOperationOptions() ExecuteSiteAnalysisSlotOperationOptions { + return ExecuteSiteAnalysisSlotOperationOptions{} +} + +func (o ExecuteSiteAnalysisSlotOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ExecuteSiteAnalysisSlotOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ExecuteSiteAnalysisSlotOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.EndTime != nil { + out.Append("endTime", fmt.Sprintf("%v", *o.EndTime)) + } + if o.StartTime != nil { + out.Append("startTime", fmt.Sprintf("%v", *o.StartTime)) + } + if o.TimeGrain != nil { + out.Append("timeGrain", fmt.Sprintf("%v", *o.TimeGrain)) + } + return &out +} + +// ExecuteSiteAnalysisSlot ... +func (c DiagnosticsClient) ExecuteSiteAnalysisSlot(ctx context.Context, id DiagnosticAnalysisId, options ExecuteSiteAnalysisSlotOperationOptions) (result ExecuteSiteAnalysisSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/execute", id.ID()), + OptionsObject: options, + } + + 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 +} diff --git a/resource-manager/web/2022-09-01/diagnostics/method_executesiteanalysisslot_autorest.go b/resource-manager/web/2022-09-01/diagnostics/method_executesiteanalysisslot_autorest.go deleted file mode 100644 index 696f72ad1d7..00000000000 --- a/resource-manager/web/2022-09-01/diagnostics/method_executesiteanalysisslot_autorest.go +++ /dev/null @@ -1,108 +0,0 @@ -package diagnostics - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ExecuteSiteAnalysisSlotOperationResponse struct { - HttpResponse *http.Response - Model *DiagnosticAnalysis -} - -type ExecuteSiteAnalysisSlotOperationOptions struct { - EndTime *string - StartTime *string - TimeGrain *string -} - -func DefaultExecuteSiteAnalysisSlotOperationOptions() ExecuteSiteAnalysisSlotOperationOptions { - return ExecuteSiteAnalysisSlotOperationOptions{} -} - -func (o ExecuteSiteAnalysisSlotOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ExecuteSiteAnalysisSlotOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.EndTime != nil { - out["endTime"] = *o.EndTime - } - - if o.StartTime != nil { - out["startTime"] = *o.StartTime - } - - if o.TimeGrain != nil { - out["timeGrain"] = *o.TimeGrain - } - - return out -} - -// ExecuteSiteAnalysisSlot ... -func (c DiagnosticsClient) ExecuteSiteAnalysisSlot(ctx context.Context, id DiagnosticAnalysisId, options ExecuteSiteAnalysisSlotOperationOptions) (result ExecuteSiteAnalysisSlotOperationResponse, err error) { - req, err := c.preparerForExecuteSiteAnalysisSlot(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ExecuteSiteAnalysisSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ExecuteSiteAnalysisSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForExecuteSiteAnalysisSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ExecuteSiteAnalysisSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForExecuteSiteAnalysisSlot prepares the ExecuteSiteAnalysisSlot request. -func (c DiagnosticsClient) preparerForExecuteSiteAnalysisSlot(ctx context.Context, id DiagnosticAnalysisId, options ExecuteSiteAnalysisSlotOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/execute", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForExecuteSiteAnalysisSlot handles the response to the ExecuteSiteAnalysisSlot request. The method always -// closes the http.Response Body. -func (c DiagnosticsClient) responderForExecuteSiteAnalysisSlot(resp *http.Response) (result ExecuteSiteAnalysisSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/diagnostics/method_executesitedetector.go b/resource-manager/web/2022-09-01/diagnostics/method_executesitedetector.go new file mode 100644 index 00000000000..6e8cf42848a --- /dev/null +++ b/resource-manager/web/2022-09-01/diagnostics/method_executesitedetector.go @@ -0,0 +1,88 @@ +package diagnostics + +import ( + "context" + "fmt" + "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 ExecuteSiteDetectorOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DiagnosticDetectorResponse +} + +type ExecuteSiteDetectorOperationOptions struct { + EndTime *string + StartTime *string + TimeGrain *string +} + +func DefaultExecuteSiteDetectorOperationOptions() ExecuteSiteDetectorOperationOptions { + return ExecuteSiteDetectorOperationOptions{} +} + +func (o ExecuteSiteDetectorOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ExecuteSiteDetectorOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ExecuteSiteDetectorOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.EndTime != nil { + out.Append("endTime", fmt.Sprintf("%v", *o.EndTime)) + } + if o.StartTime != nil { + out.Append("startTime", fmt.Sprintf("%v", *o.StartTime)) + } + if o.TimeGrain != nil { + out.Append("timeGrain", fmt.Sprintf("%v", *o.TimeGrain)) + } + return &out +} + +// ExecuteSiteDetector ... +func (c DiagnosticsClient) ExecuteSiteDetector(ctx context.Context, id DiagnosticDetectorId, options ExecuteSiteDetectorOperationOptions) (result ExecuteSiteDetectorOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/execute", id.ID()), + OptionsObject: options, + } + + 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 +} diff --git a/resource-manager/web/2022-09-01/diagnostics/method_executesitedetector_autorest.go b/resource-manager/web/2022-09-01/diagnostics/method_executesitedetector_autorest.go deleted file mode 100644 index 188cf60ac41..00000000000 --- a/resource-manager/web/2022-09-01/diagnostics/method_executesitedetector_autorest.go +++ /dev/null @@ -1,108 +0,0 @@ -package diagnostics - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ExecuteSiteDetectorOperationResponse struct { - HttpResponse *http.Response - Model *DiagnosticDetectorResponse -} - -type ExecuteSiteDetectorOperationOptions struct { - EndTime *string - StartTime *string - TimeGrain *string -} - -func DefaultExecuteSiteDetectorOperationOptions() ExecuteSiteDetectorOperationOptions { - return ExecuteSiteDetectorOperationOptions{} -} - -func (o ExecuteSiteDetectorOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ExecuteSiteDetectorOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.EndTime != nil { - out["endTime"] = *o.EndTime - } - - if o.StartTime != nil { - out["startTime"] = *o.StartTime - } - - if o.TimeGrain != nil { - out["timeGrain"] = *o.TimeGrain - } - - return out -} - -// ExecuteSiteDetector ... -func (c DiagnosticsClient) ExecuteSiteDetector(ctx context.Context, id DiagnosticDetectorId, options ExecuteSiteDetectorOperationOptions) (result ExecuteSiteDetectorOperationResponse, err error) { - req, err := c.preparerForExecuteSiteDetector(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ExecuteSiteDetector", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ExecuteSiteDetector", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForExecuteSiteDetector(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ExecuteSiteDetector", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForExecuteSiteDetector prepares the ExecuteSiteDetector request. -func (c DiagnosticsClient) preparerForExecuteSiteDetector(ctx context.Context, id DiagnosticDetectorId, options ExecuteSiteDetectorOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/execute", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForExecuteSiteDetector handles the response to the ExecuteSiteDetector request. The method always -// closes the http.Response Body. -func (c DiagnosticsClient) responderForExecuteSiteDetector(resp *http.Response) (result ExecuteSiteDetectorOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/diagnostics/method_executesitedetectorslot.go b/resource-manager/web/2022-09-01/diagnostics/method_executesitedetectorslot.go new file mode 100644 index 00000000000..1e36fab76b6 --- /dev/null +++ b/resource-manager/web/2022-09-01/diagnostics/method_executesitedetectorslot.go @@ -0,0 +1,88 @@ +package diagnostics + +import ( + "context" + "fmt" + "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 ExecuteSiteDetectorSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DiagnosticDetectorResponse +} + +type ExecuteSiteDetectorSlotOperationOptions struct { + EndTime *string + StartTime *string + TimeGrain *string +} + +func DefaultExecuteSiteDetectorSlotOperationOptions() ExecuteSiteDetectorSlotOperationOptions { + return ExecuteSiteDetectorSlotOperationOptions{} +} + +func (o ExecuteSiteDetectorSlotOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ExecuteSiteDetectorSlotOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ExecuteSiteDetectorSlotOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.EndTime != nil { + out.Append("endTime", fmt.Sprintf("%v", *o.EndTime)) + } + if o.StartTime != nil { + out.Append("startTime", fmt.Sprintf("%v", *o.StartTime)) + } + if o.TimeGrain != nil { + out.Append("timeGrain", fmt.Sprintf("%v", *o.TimeGrain)) + } + return &out +} + +// ExecuteSiteDetectorSlot ... +func (c DiagnosticsClient) ExecuteSiteDetectorSlot(ctx context.Context, id SlotDiagnosticDetectorId, options ExecuteSiteDetectorSlotOperationOptions) (result ExecuteSiteDetectorSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/execute", id.ID()), + OptionsObject: options, + } + + 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 +} diff --git a/resource-manager/web/2022-09-01/diagnostics/method_executesitedetectorslot_autorest.go b/resource-manager/web/2022-09-01/diagnostics/method_executesitedetectorslot_autorest.go deleted file mode 100644 index 4b9e8ef4f4d..00000000000 --- a/resource-manager/web/2022-09-01/diagnostics/method_executesitedetectorslot_autorest.go +++ /dev/null @@ -1,108 +0,0 @@ -package diagnostics - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ExecuteSiteDetectorSlotOperationResponse struct { - HttpResponse *http.Response - Model *DiagnosticDetectorResponse -} - -type ExecuteSiteDetectorSlotOperationOptions struct { - EndTime *string - StartTime *string - TimeGrain *string -} - -func DefaultExecuteSiteDetectorSlotOperationOptions() ExecuteSiteDetectorSlotOperationOptions { - return ExecuteSiteDetectorSlotOperationOptions{} -} - -func (o ExecuteSiteDetectorSlotOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ExecuteSiteDetectorSlotOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.EndTime != nil { - out["endTime"] = *o.EndTime - } - - if o.StartTime != nil { - out["startTime"] = *o.StartTime - } - - if o.TimeGrain != nil { - out["timeGrain"] = *o.TimeGrain - } - - return out -} - -// ExecuteSiteDetectorSlot ... -func (c DiagnosticsClient) ExecuteSiteDetectorSlot(ctx context.Context, id SlotDiagnosticDetectorId, options ExecuteSiteDetectorSlotOperationOptions) (result ExecuteSiteDetectorSlotOperationResponse, err error) { - req, err := c.preparerForExecuteSiteDetectorSlot(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ExecuteSiteDetectorSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ExecuteSiteDetectorSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForExecuteSiteDetectorSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ExecuteSiteDetectorSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForExecuteSiteDetectorSlot prepares the ExecuteSiteDetectorSlot request. -func (c DiagnosticsClient) preparerForExecuteSiteDetectorSlot(ctx context.Context, id SlotDiagnosticDetectorId, options ExecuteSiteDetectorSlotOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/execute", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForExecuteSiteDetectorSlot handles the response to the ExecuteSiteDetectorSlot request. The method always -// closes the http.Response Body. -func (c DiagnosticsClient) responderForExecuteSiteDetectorSlot(resp *http.Response) (result ExecuteSiteDetectorSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/diagnostics/method_gethostingenvironmentdetectorresponse.go b/resource-manager/web/2022-09-01/diagnostics/method_gethostingenvironmentdetectorresponse.go new file mode 100644 index 00000000000..fafbd52c544 --- /dev/null +++ b/resource-manager/web/2022-09-01/diagnostics/method_gethostingenvironmentdetectorresponse.go @@ -0,0 +1,88 @@ +package diagnostics + +import ( + "context" + "fmt" + "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 GetHostingEnvironmentDetectorResponseOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DetectorResponse +} + +type GetHostingEnvironmentDetectorResponseOperationOptions struct { + EndTime *string + StartTime *string + TimeGrain *string +} + +func DefaultGetHostingEnvironmentDetectorResponseOperationOptions() GetHostingEnvironmentDetectorResponseOperationOptions { + return GetHostingEnvironmentDetectorResponseOperationOptions{} +} + +func (o GetHostingEnvironmentDetectorResponseOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetHostingEnvironmentDetectorResponseOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o GetHostingEnvironmentDetectorResponseOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.EndTime != nil { + out.Append("endTime", fmt.Sprintf("%v", *o.EndTime)) + } + if o.StartTime != nil { + out.Append("startTime", fmt.Sprintf("%v", *o.StartTime)) + } + if o.TimeGrain != nil { + out.Append("timeGrain", fmt.Sprintf("%v", *o.TimeGrain)) + } + return &out +} + +// GetHostingEnvironmentDetectorResponse ... +func (c DiagnosticsClient) GetHostingEnvironmentDetectorResponse(ctx context.Context, id HostingEnvironmentDetectorId, options GetHostingEnvironmentDetectorResponseOperationOptions) (result GetHostingEnvironmentDetectorResponseOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + OptionsObject: options, + } + + 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 +} diff --git a/resource-manager/web/2022-09-01/diagnostics/method_gethostingenvironmentdetectorresponse_autorest.go b/resource-manager/web/2022-09-01/diagnostics/method_gethostingenvironmentdetectorresponse_autorest.go deleted file mode 100644 index 533f7dce59d..00000000000 --- a/resource-manager/web/2022-09-01/diagnostics/method_gethostingenvironmentdetectorresponse_autorest.go +++ /dev/null @@ -1,107 +0,0 @@ -package diagnostics - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetHostingEnvironmentDetectorResponseOperationResponse struct { - HttpResponse *http.Response - Model *DetectorResponse -} - -type GetHostingEnvironmentDetectorResponseOperationOptions struct { - EndTime *string - StartTime *string - TimeGrain *string -} - -func DefaultGetHostingEnvironmentDetectorResponseOperationOptions() GetHostingEnvironmentDetectorResponseOperationOptions { - return GetHostingEnvironmentDetectorResponseOperationOptions{} -} - -func (o GetHostingEnvironmentDetectorResponseOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o GetHostingEnvironmentDetectorResponseOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.EndTime != nil { - out["endTime"] = *o.EndTime - } - - if o.StartTime != nil { - out["startTime"] = *o.StartTime - } - - if o.TimeGrain != nil { - out["timeGrain"] = *o.TimeGrain - } - - return out -} - -// GetHostingEnvironmentDetectorResponse ... -func (c DiagnosticsClient) GetHostingEnvironmentDetectorResponse(ctx context.Context, id HostingEnvironmentDetectorId, options GetHostingEnvironmentDetectorResponseOperationOptions) (result GetHostingEnvironmentDetectorResponseOperationResponse, err error) { - req, err := c.preparerForGetHostingEnvironmentDetectorResponse(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "GetHostingEnvironmentDetectorResponse", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "GetHostingEnvironmentDetectorResponse", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetHostingEnvironmentDetectorResponse(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "GetHostingEnvironmentDetectorResponse", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetHostingEnvironmentDetectorResponse prepares the GetHostingEnvironmentDetectorResponse request. -func (c DiagnosticsClient) preparerForGetHostingEnvironmentDetectorResponse(ctx context.Context, id HostingEnvironmentDetectorId, options GetHostingEnvironmentDetectorResponseOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetHostingEnvironmentDetectorResponse handles the response to the GetHostingEnvironmentDetectorResponse request. The method always -// closes the http.Response Body. -func (c DiagnosticsClient) responderForGetHostingEnvironmentDetectorResponse(resp *http.Response) (result GetHostingEnvironmentDetectorResponseOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/diagnostics/method_getsiteanalysis.go b/resource-manager/web/2022-09-01/diagnostics/method_getsiteanalysis.go new file mode 100644 index 00000000000..182dde17a0e --- /dev/null +++ b/resource-manager/web/2022-09-01/diagnostics/method_getsiteanalysis.go @@ -0,0 +1,51 @@ +package diagnostics + +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 GetSiteAnalysisOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AnalysisDefinition +} + +// GetSiteAnalysis ... +func (c DiagnosticsClient) GetSiteAnalysis(ctx context.Context, id AnalysisId) (result GetSiteAnalysisOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/diagnostics/method_getsiteanalysis_autorest.go b/resource-manager/web/2022-09-01/diagnostics/method_getsiteanalysis_autorest.go deleted file mode 100644 index 425a75f91f5..00000000000 --- a/resource-manager/web/2022-09-01/diagnostics/method_getsiteanalysis_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package diagnostics - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetSiteAnalysisOperationResponse struct { - HttpResponse *http.Response - Model *AnalysisDefinition -} - -// GetSiteAnalysis ... -func (c DiagnosticsClient) GetSiteAnalysis(ctx context.Context, id AnalysisId) (result GetSiteAnalysisOperationResponse, err error) { - req, err := c.preparerForGetSiteAnalysis(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "GetSiteAnalysis", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "GetSiteAnalysis", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetSiteAnalysis(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "GetSiteAnalysis", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetSiteAnalysis prepares the GetSiteAnalysis request. -func (c DiagnosticsClient) preparerForGetSiteAnalysis(ctx context.Context, id AnalysisId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetSiteAnalysis handles the response to the GetSiteAnalysis request. The method always -// closes the http.Response Body. -func (c DiagnosticsClient) responderForGetSiteAnalysis(resp *http.Response) (result GetSiteAnalysisOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/diagnostics/method_getsiteanalysisslot.go b/resource-manager/web/2022-09-01/diagnostics/method_getsiteanalysisslot.go new file mode 100644 index 00000000000..c37f87fd248 --- /dev/null +++ b/resource-manager/web/2022-09-01/diagnostics/method_getsiteanalysisslot.go @@ -0,0 +1,51 @@ +package diagnostics + +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 GetSiteAnalysisSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AnalysisDefinition +} + +// GetSiteAnalysisSlot ... +func (c DiagnosticsClient) GetSiteAnalysisSlot(ctx context.Context, id DiagnosticAnalysisId) (result GetSiteAnalysisSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/diagnostics/method_getsiteanalysisslot_autorest.go b/resource-manager/web/2022-09-01/diagnostics/method_getsiteanalysisslot_autorest.go deleted file mode 100644 index 1ec012b0128..00000000000 --- a/resource-manager/web/2022-09-01/diagnostics/method_getsiteanalysisslot_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package diagnostics - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetSiteAnalysisSlotOperationResponse struct { - HttpResponse *http.Response - Model *AnalysisDefinition -} - -// GetSiteAnalysisSlot ... -func (c DiagnosticsClient) GetSiteAnalysisSlot(ctx context.Context, id DiagnosticAnalysisId) (result GetSiteAnalysisSlotOperationResponse, err error) { - req, err := c.preparerForGetSiteAnalysisSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "GetSiteAnalysisSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "GetSiteAnalysisSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetSiteAnalysisSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "GetSiteAnalysisSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetSiteAnalysisSlot prepares the GetSiteAnalysisSlot request. -func (c DiagnosticsClient) preparerForGetSiteAnalysisSlot(ctx context.Context, id DiagnosticAnalysisId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetSiteAnalysisSlot handles the response to the GetSiteAnalysisSlot request. The method always -// closes the http.Response Body. -func (c DiagnosticsClient) responderForGetSiteAnalysisSlot(resp *http.Response) (result GetSiteAnalysisSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/diagnostics/method_getsitedetector.go b/resource-manager/web/2022-09-01/diagnostics/method_getsitedetector.go new file mode 100644 index 00000000000..410d2848aed --- /dev/null +++ b/resource-manager/web/2022-09-01/diagnostics/method_getsitedetector.go @@ -0,0 +1,51 @@ +package diagnostics + +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 GetSiteDetectorOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DetectorDefinitionResource +} + +// GetSiteDetector ... +func (c DiagnosticsClient) GetSiteDetector(ctx context.Context, id DiagnosticDetectorId) (result GetSiteDetectorOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/diagnostics/method_getsitedetector_autorest.go b/resource-manager/web/2022-09-01/diagnostics/method_getsitedetector_autorest.go deleted file mode 100644 index 478b9e00d7b..00000000000 --- a/resource-manager/web/2022-09-01/diagnostics/method_getsitedetector_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package diagnostics - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetSiteDetectorOperationResponse struct { - HttpResponse *http.Response - Model *DetectorDefinitionResource -} - -// GetSiteDetector ... -func (c DiagnosticsClient) GetSiteDetector(ctx context.Context, id DiagnosticDetectorId) (result GetSiteDetectorOperationResponse, err error) { - req, err := c.preparerForGetSiteDetector(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "GetSiteDetector", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "GetSiteDetector", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetSiteDetector(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "GetSiteDetector", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetSiteDetector prepares the GetSiteDetector request. -func (c DiagnosticsClient) preparerForGetSiteDetector(ctx context.Context, id DiagnosticDetectorId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetSiteDetector handles the response to the GetSiteDetector request. The method always -// closes the http.Response Body. -func (c DiagnosticsClient) responderForGetSiteDetector(resp *http.Response) (result GetSiteDetectorOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/diagnostics/method_getsitedetectorresponse.go b/resource-manager/web/2022-09-01/diagnostics/method_getsitedetectorresponse.go new file mode 100644 index 00000000000..66dafcb66f0 --- /dev/null +++ b/resource-manager/web/2022-09-01/diagnostics/method_getsitedetectorresponse.go @@ -0,0 +1,88 @@ +package diagnostics + +import ( + "context" + "fmt" + "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 GetSiteDetectorResponseOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DetectorResponse +} + +type GetSiteDetectorResponseOperationOptions struct { + EndTime *string + StartTime *string + TimeGrain *string +} + +func DefaultGetSiteDetectorResponseOperationOptions() GetSiteDetectorResponseOperationOptions { + return GetSiteDetectorResponseOperationOptions{} +} + +func (o GetSiteDetectorResponseOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetSiteDetectorResponseOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o GetSiteDetectorResponseOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.EndTime != nil { + out.Append("endTime", fmt.Sprintf("%v", *o.EndTime)) + } + if o.StartTime != nil { + out.Append("startTime", fmt.Sprintf("%v", *o.StartTime)) + } + if o.TimeGrain != nil { + out.Append("timeGrain", fmt.Sprintf("%v", *o.TimeGrain)) + } + return &out +} + +// GetSiteDetectorResponse ... +func (c DiagnosticsClient) GetSiteDetectorResponse(ctx context.Context, id DetectorId, options GetSiteDetectorResponseOperationOptions) (result GetSiteDetectorResponseOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + OptionsObject: options, + } + + 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 +} diff --git a/resource-manager/web/2022-09-01/diagnostics/method_getsitedetectorresponse_autorest.go b/resource-manager/web/2022-09-01/diagnostics/method_getsitedetectorresponse_autorest.go deleted file mode 100644 index 68010512a8f..00000000000 --- a/resource-manager/web/2022-09-01/diagnostics/method_getsitedetectorresponse_autorest.go +++ /dev/null @@ -1,107 +0,0 @@ -package diagnostics - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetSiteDetectorResponseOperationResponse struct { - HttpResponse *http.Response - Model *DetectorResponse -} - -type GetSiteDetectorResponseOperationOptions struct { - EndTime *string - StartTime *string - TimeGrain *string -} - -func DefaultGetSiteDetectorResponseOperationOptions() GetSiteDetectorResponseOperationOptions { - return GetSiteDetectorResponseOperationOptions{} -} - -func (o GetSiteDetectorResponseOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o GetSiteDetectorResponseOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.EndTime != nil { - out["endTime"] = *o.EndTime - } - - if o.StartTime != nil { - out["startTime"] = *o.StartTime - } - - if o.TimeGrain != nil { - out["timeGrain"] = *o.TimeGrain - } - - return out -} - -// GetSiteDetectorResponse ... -func (c DiagnosticsClient) GetSiteDetectorResponse(ctx context.Context, id DetectorId, options GetSiteDetectorResponseOperationOptions) (result GetSiteDetectorResponseOperationResponse, err error) { - req, err := c.preparerForGetSiteDetectorResponse(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "GetSiteDetectorResponse", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "GetSiteDetectorResponse", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetSiteDetectorResponse(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "GetSiteDetectorResponse", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetSiteDetectorResponse prepares the GetSiteDetectorResponse request. -func (c DiagnosticsClient) preparerForGetSiteDetectorResponse(ctx context.Context, id DetectorId, options GetSiteDetectorResponseOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetSiteDetectorResponse handles the response to the GetSiteDetectorResponse request. The method always -// closes the http.Response Body. -func (c DiagnosticsClient) responderForGetSiteDetectorResponse(resp *http.Response) (result GetSiteDetectorResponseOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/diagnostics/method_getsitedetectorresponseslot.go b/resource-manager/web/2022-09-01/diagnostics/method_getsitedetectorresponseslot.go new file mode 100644 index 00000000000..94fe7dfb27b --- /dev/null +++ b/resource-manager/web/2022-09-01/diagnostics/method_getsitedetectorresponseslot.go @@ -0,0 +1,88 @@ +package diagnostics + +import ( + "context" + "fmt" + "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 GetSiteDetectorResponseSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DetectorResponse +} + +type GetSiteDetectorResponseSlotOperationOptions struct { + EndTime *string + StartTime *string + TimeGrain *string +} + +func DefaultGetSiteDetectorResponseSlotOperationOptions() GetSiteDetectorResponseSlotOperationOptions { + return GetSiteDetectorResponseSlotOperationOptions{} +} + +func (o GetSiteDetectorResponseSlotOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetSiteDetectorResponseSlotOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o GetSiteDetectorResponseSlotOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.EndTime != nil { + out.Append("endTime", fmt.Sprintf("%v", *o.EndTime)) + } + if o.StartTime != nil { + out.Append("startTime", fmt.Sprintf("%v", *o.StartTime)) + } + if o.TimeGrain != nil { + out.Append("timeGrain", fmt.Sprintf("%v", *o.TimeGrain)) + } + return &out +} + +// GetSiteDetectorResponseSlot ... +func (c DiagnosticsClient) GetSiteDetectorResponseSlot(ctx context.Context, id SlotDetectorId, options GetSiteDetectorResponseSlotOperationOptions) (result GetSiteDetectorResponseSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + OptionsObject: options, + } + + 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 +} diff --git a/resource-manager/web/2022-09-01/diagnostics/method_getsitedetectorresponseslot_autorest.go b/resource-manager/web/2022-09-01/diagnostics/method_getsitedetectorresponseslot_autorest.go deleted file mode 100644 index 7b554300cbe..00000000000 --- a/resource-manager/web/2022-09-01/diagnostics/method_getsitedetectorresponseslot_autorest.go +++ /dev/null @@ -1,107 +0,0 @@ -package diagnostics - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetSiteDetectorResponseSlotOperationResponse struct { - HttpResponse *http.Response - Model *DetectorResponse -} - -type GetSiteDetectorResponseSlotOperationOptions struct { - EndTime *string - StartTime *string - TimeGrain *string -} - -func DefaultGetSiteDetectorResponseSlotOperationOptions() GetSiteDetectorResponseSlotOperationOptions { - return GetSiteDetectorResponseSlotOperationOptions{} -} - -func (o GetSiteDetectorResponseSlotOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o GetSiteDetectorResponseSlotOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.EndTime != nil { - out["endTime"] = *o.EndTime - } - - if o.StartTime != nil { - out["startTime"] = *o.StartTime - } - - if o.TimeGrain != nil { - out["timeGrain"] = *o.TimeGrain - } - - return out -} - -// GetSiteDetectorResponseSlot ... -func (c DiagnosticsClient) GetSiteDetectorResponseSlot(ctx context.Context, id SlotDetectorId, options GetSiteDetectorResponseSlotOperationOptions) (result GetSiteDetectorResponseSlotOperationResponse, err error) { - req, err := c.preparerForGetSiteDetectorResponseSlot(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "GetSiteDetectorResponseSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "GetSiteDetectorResponseSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetSiteDetectorResponseSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "GetSiteDetectorResponseSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetSiteDetectorResponseSlot prepares the GetSiteDetectorResponseSlot request. -func (c DiagnosticsClient) preparerForGetSiteDetectorResponseSlot(ctx context.Context, id SlotDetectorId, options GetSiteDetectorResponseSlotOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetSiteDetectorResponseSlot handles the response to the GetSiteDetectorResponseSlot request. The method always -// closes the http.Response Body. -func (c DiagnosticsClient) responderForGetSiteDetectorResponseSlot(resp *http.Response) (result GetSiteDetectorResponseSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/diagnostics/method_getsitedetectorslot.go b/resource-manager/web/2022-09-01/diagnostics/method_getsitedetectorslot.go new file mode 100644 index 00000000000..c987c0ccb59 --- /dev/null +++ b/resource-manager/web/2022-09-01/diagnostics/method_getsitedetectorslot.go @@ -0,0 +1,51 @@ +package diagnostics + +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 GetSiteDetectorSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DetectorDefinitionResource +} + +// GetSiteDetectorSlot ... +func (c DiagnosticsClient) GetSiteDetectorSlot(ctx context.Context, id SlotDiagnosticDetectorId) (result GetSiteDetectorSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/diagnostics/method_getsitedetectorslot_autorest.go b/resource-manager/web/2022-09-01/diagnostics/method_getsitedetectorslot_autorest.go deleted file mode 100644 index 7ef7490c3e9..00000000000 --- a/resource-manager/web/2022-09-01/diagnostics/method_getsitedetectorslot_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package diagnostics - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetSiteDetectorSlotOperationResponse struct { - HttpResponse *http.Response - Model *DetectorDefinitionResource -} - -// GetSiteDetectorSlot ... -func (c DiagnosticsClient) GetSiteDetectorSlot(ctx context.Context, id SlotDiagnosticDetectorId) (result GetSiteDetectorSlotOperationResponse, err error) { - req, err := c.preparerForGetSiteDetectorSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "GetSiteDetectorSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "GetSiteDetectorSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetSiteDetectorSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "GetSiteDetectorSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetSiteDetectorSlot prepares the GetSiteDetectorSlot request. -func (c DiagnosticsClient) preparerForGetSiteDetectorSlot(ctx context.Context, id SlotDiagnosticDetectorId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetSiteDetectorSlot handles the response to the GetSiteDetectorSlot request. The method always -// closes the http.Response Body. -func (c DiagnosticsClient) responderForGetSiteDetectorSlot(resp *http.Response) (result GetSiteDetectorSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/diagnostics/method_getsitediagnosticcategory.go b/resource-manager/web/2022-09-01/diagnostics/method_getsitediagnosticcategory.go new file mode 100644 index 00000000000..90da45dc962 --- /dev/null +++ b/resource-manager/web/2022-09-01/diagnostics/method_getsitediagnosticcategory.go @@ -0,0 +1,51 @@ +package diagnostics + +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 GetSiteDiagnosticCategoryOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DiagnosticCategory +} + +// GetSiteDiagnosticCategory ... +func (c DiagnosticsClient) GetSiteDiagnosticCategory(ctx context.Context, id DiagnosticId) (result GetSiteDiagnosticCategoryOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/diagnostics/method_getsitediagnosticcategory_autorest.go b/resource-manager/web/2022-09-01/diagnostics/method_getsitediagnosticcategory_autorest.go deleted file mode 100644 index 60deef45a78..00000000000 --- a/resource-manager/web/2022-09-01/diagnostics/method_getsitediagnosticcategory_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package diagnostics - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetSiteDiagnosticCategoryOperationResponse struct { - HttpResponse *http.Response - Model *DiagnosticCategory -} - -// GetSiteDiagnosticCategory ... -func (c DiagnosticsClient) GetSiteDiagnosticCategory(ctx context.Context, id DiagnosticId) (result GetSiteDiagnosticCategoryOperationResponse, err error) { - req, err := c.preparerForGetSiteDiagnosticCategory(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "GetSiteDiagnosticCategory", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "GetSiteDiagnosticCategory", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetSiteDiagnosticCategory(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "GetSiteDiagnosticCategory", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetSiteDiagnosticCategory prepares the GetSiteDiagnosticCategory request. -func (c DiagnosticsClient) preparerForGetSiteDiagnosticCategory(ctx context.Context, id DiagnosticId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetSiteDiagnosticCategory handles the response to the GetSiteDiagnosticCategory request. The method always -// closes the http.Response Body. -func (c DiagnosticsClient) responderForGetSiteDiagnosticCategory(resp *http.Response) (result GetSiteDiagnosticCategoryOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/diagnostics/method_getsitediagnosticcategoryslot.go b/resource-manager/web/2022-09-01/diagnostics/method_getsitediagnosticcategoryslot.go new file mode 100644 index 00000000000..2154c3563ec --- /dev/null +++ b/resource-manager/web/2022-09-01/diagnostics/method_getsitediagnosticcategoryslot.go @@ -0,0 +1,51 @@ +package diagnostics + +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 GetSiteDiagnosticCategorySlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DiagnosticCategory +} + +// GetSiteDiagnosticCategorySlot ... +func (c DiagnosticsClient) GetSiteDiagnosticCategorySlot(ctx context.Context, id SlotDiagnosticId) (result GetSiteDiagnosticCategorySlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/diagnostics/method_getsitediagnosticcategoryslot_autorest.go b/resource-manager/web/2022-09-01/diagnostics/method_getsitediagnosticcategoryslot_autorest.go deleted file mode 100644 index 32b554afb68..00000000000 --- a/resource-manager/web/2022-09-01/diagnostics/method_getsitediagnosticcategoryslot_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package diagnostics - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetSiteDiagnosticCategorySlotOperationResponse struct { - HttpResponse *http.Response - Model *DiagnosticCategory -} - -// GetSiteDiagnosticCategorySlot ... -func (c DiagnosticsClient) GetSiteDiagnosticCategorySlot(ctx context.Context, id SlotDiagnosticId) (result GetSiteDiagnosticCategorySlotOperationResponse, err error) { - req, err := c.preparerForGetSiteDiagnosticCategorySlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "GetSiteDiagnosticCategorySlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "GetSiteDiagnosticCategorySlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetSiteDiagnosticCategorySlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "GetSiteDiagnosticCategorySlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetSiteDiagnosticCategorySlot prepares the GetSiteDiagnosticCategorySlot request. -func (c DiagnosticsClient) preparerForGetSiteDiagnosticCategorySlot(ctx context.Context, id SlotDiagnosticId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetSiteDiagnosticCategorySlot handles the response to the GetSiteDiagnosticCategorySlot request. The method always -// closes the http.Response Body. -func (c DiagnosticsClient) responderForGetSiteDiagnosticCategorySlot(resp *http.Response) (result GetSiteDiagnosticCategorySlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/diagnostics/method_listhostingenvironmentdetectorresponses.go b/resource-manager/web/2022-09-01/diagnostics/method_listhostingenvironmentdetectorresponses.go new file mode 100644 index 00000000000..7641a9d8641 --- /dev/null +++ b/resource-manager/web/2022-09-01/diagnostics/method_listhostingenvironmentdetectorresponses.go @@ -0,0 +1,89 @@ +package diagnostics + +import ( + "context" + "fmt" + "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 ListHostingEnvironmentDetectorResponsesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DetectorResponse +} + +type ListHostingEnvironmentDetectorResponsesCompleteResult struct { + Items []DetectorResponse +} + +// ListHostingEnvironmentDetectorResponses ... +func (c DiagnosticsClient) ListHostingEnvironmentDetectorResponses(ctx context.Context, id HostingEnvironmentId) (result ListHostingEnvironmentDetectorResponsesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/detectors", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]DetectorResponse `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListHostingEnvironmentDetectorResponsesComplete retrieves all the results into a single object +func (c DiagnosticsClient) ListHostingEnvironmentDetectorResponsesComplete(ctx context.Context, id HostingEnvironmentId) (ListHostingEnvironmentDetectorResponsesCompleteResult, error) { + return c.ListHostingEnvironmentDetectorResponsesCompleteMatchingPredicate(ctx, id, DetectorResponseOperationPredicate{}) +} + +// ListHostingEnvironmentDetectorResponsesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DiagnosticsClient) ListHostingEnvironmentDetectorResponsesCompleteMatchingPredicate(ctx context.Context, id HostingEnvironmentId, predicate DetectorResponseOperationPredicate) (result ListHostingEnvironmentDetectorResponsesCompleteResult, err error) { + items := make([]DetectorResponse, 0) + + resp, err := c.ListHostingEnvironmentDetectorResponses(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListHostingEnvironmentDetectorResponsesCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/diagnostics/method_listhostingenvironmentdetectorresponses_autorest.go b/resource-manager/web/2022-09-01/diagnostics/method_listhostingenvironmentdetectorresponses_autorest.go deleted file mode 100644 index c98092cfb8a..00000000000 --- a/resource-manager/web/2022-09-01/diagnostics/method_listhostingenvironmentdetectorresponses_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package diagnostics - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListHostingEnvironmentDetectorResponsesOperationResponse struct { - HttpResponse *http.Response - Model *[]DetectorResponse - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListHostingEnvironmentDetectorResponsesOperationResponse, error) -} - -type ListHostingEnvironmentDetectorResponsesCompleteResult struct { - Items []DetectorResponse -} - -func (r ListHostingEnvironmentDetectorResponsesOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListHostingEnvironmentDetectorResponsesOperationResponse) LoadMore(ctx context.Context) (resp ListHostingEnvironmentDetectorResponsesOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListHostingEnvironmentDetectorResponses ... -func (c DiagnosticsClient) ListHostingEnvironmentDetectorResponses(ctx context.Context, id HostingEnvironmentId) (resp ListHostingEnvironmentDetectorResponsesOperationResponse, err error) { - req, err := c.preparerForListHostingEnvironmentDetectorResponses(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ListHostingEnvironmentDetectorResponses", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ListHostingEnvironmentDetectorResponses", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListHostingEnvironmentDetectorResponses(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ListHostingEnvironmentDetectorResponses", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListHostingEnvironmentDetectorResponses prepares the ListHostingEnvironmentDetectorResponses request. -func (c DiagnosticsClient) preparerForListHostingEnvironmentDetectorResponses(ctx context.Context, id HostingEnvironmentId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/detectors", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListHostingEnvironmentDetectorResponsesWithNextLink prepares the ListHostingEnvironmentDetectorResponses request with the given nextLink token. -func (c DiagnosticsClient) preparerForListHostingEnvironmentDetectorResponsesWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListHostingEnvironmentDetectorResponses handles the response to the ListHostingEnvironmentDetectorResponses request. The method always -// closes the http.Response Body. -func (c DiagnosticsClient) responderForListHostingEnvironmentDetectorResponses(resp *http.Response) (result ListHostingEnvironmentDetectorResponsesOperationResponse, err error) { - type page struct { - Values []DetectorResponse `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListHostingEnvironmentDetectorResponsesOperationResponse, err error) { - req, err := c.preparerForListHostingEnvironmentDetectorResponsesWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ListHostingEnvironmentDetectorResponses", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ListHostingEnvironmentDetectorResponses", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListHostingEnvironmentDetectorResponses(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ListHostingEnvironmentDetectorResponses", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListHostingEnvironmentDetectorResponsesComplete retrieves all of the results into a single object -func (c DiagnosticsClient) ListHostingEnvironmentDetectorResponsesComplete(ctx context.Context, id HostingEnvironmentId) (ListHostingEnvironmentDetectorResponsesCompleteResult, error) { - return c.ListHostingEnvironmentDetectorResponsesCompleteMatchingPredicate(ctx, id, DetectorResponseOperationPredicate{}) -} - -// ListHostingEnvironmentDetectorResponsesCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c DiagnosticsClient) ListHostingEnvironmentDetectorResponsesCompleteMatchingPredicate(ctx context.Context, id HostingEnvironmentId, predicate DetectorResponseOperationPredicate) (resp ListHostingEnvironmentDetectorResponsesCompleteResult, err error) { - items := make([]DetectorResponse, 0) - - page, err := c.ListHostingEnvironmentDetectorResponses(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListHostingEnvironmentDetectorResponsesCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/diagnostics/method_listsiteanalyses.go b/resource-manager/web/2022-09-01/diagnostics/method_listsiteanalyses.go new file mode 100644 index 00000000000..ee0eabf6636 --- /dev/null +++ b/resource-manager/web/2022-09-01/diagnostics/method_listsiteanalyses.go @@ -0,0 +1,89 @@ +package diagnostics + +import ( + "context" + "fmt" + "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 ListSiteAnalysesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AnalysisDefinition +} + +type ListSiteAnalysesCompleteResult struct { + Items []AnalysisDefinition +} + +// ListSiteAnalyses ... +func (c DiagnosticsClient) ListSiteAnalyses(ctx context.Context, id DiagnosticId) (result ListSiteAnalysesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/analyses", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AnalysisDefinition `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteAnalysesComplete retrieves all the results into a single object +func (c DiagnosticsClient) ListSiteAnalysesComplete(ctx context.Context, id DiagnosticId) (ListSiteAnalysesCompleteResult, error) { + return c.ListSiteAnalysesCompleteMatchingPredicate(ctx, id, AnalysisDefinitionOperationPredicate{}) +} + +// ListSiteAnalysesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DiagnosticsClient) ListSiteAnalysesCompleteMatchingPredicate(ctx context.Context, id DiagnosticId, predicate AnalysisDefinitionOperationPredicate) (result ListSiteAnalysesCompleteResult, err error) { + items := make([]AnalysisDefinition, 0) + + resp, err := c.ListSiteAnalyses(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListSiteAnalysesCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/diagnostics/method_listsiteanalyses_autorest.go b/resource-manager/web/2022-09-01/diagnostics/method_listsiteanalyses_autorest.go deleted file mode 100644 index a8e5ba3c1a3..00000000000 --- a/resource-manager/web/2022-09-01/diagnostics/method_listsiteanalyses_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package diagnostics - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListSiteAnalysesOperationResponse struct { - HttpResponse *http.Response - Model *[]AnalysisDefinition - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListSiteAnalysesOperationResponse, error) -} - -type ListSiteAnalysesCompleteResult struct { - Items []AnalysisDefinition -} - -func (r ListSiteAnalysesOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListSiteAnalysesOperationResponse) LoadMore(ctx context.Context) (resp ListSiteAnalysesOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListSiteAnalyses ... -func (c DiagnosticsClient) ListSiteAnalyses(ctx context.Context, id DiagnosticId) (resp ListSiteAnalysesOperationResponse, err error) { - req, err := c.preparerForListSiteAnalyses(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ListSiteAnalyses", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ListSiteAnalyses", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListSiteAnalyses(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ListSiteAnalyses", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListSiteAnalyses prepares the ListSiteAnalyses request. -func (c DiagnosticsClient) preparerForListSiteAnalyses(ctx context.Context, id DiagnosticId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/analyses", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListSiteAnalysesWithNextLink prepares the ListSiteAnalyses request with the given nextLink token. -func (c DiagnosticsClient) preparerForListSiteAnalysesWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListSiteAnalyses handles the response to the ListSiteAnalyses request. The method always -// closes the http.Response Body. -func (c DiagnosticsClient) responderForListSiteAnalyses(resp *http.Response) (result ListSiteAnalysesOperationResponse, err error) { - type page struct { - Values []AnalysisDefinition `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListSiteAnalysesOperationResponse, err error) { - req, err := c.preparerForListSiteAnalysesWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ListSiteAnalyses", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ListSiteAnalyses", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListSiteAnalyses(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ListSiteAnalyses", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListSiteAnalysesComplete retrieves all of the results into a single object -func (c DiagnosticsClient) ListSiteAnalysesComplete(ctx context.Context, id DiagnosticId) (ListSiteAnalysesCompleteResult, error) { - return c.ListSiteAnalysesCompleteMatchingPredicate(ctx, id, AnalysisDefinitionOperationPredicate{}) -} - -// ListSiteAnalysesCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c DiagnosticsClient) ListSiteAnalysesCompleteMatchingPredicate(ctx context.Context, id DiagnosticId, predicate AnalysisDefinitionOperationPredicate) (resp ListSiteAnalysesCompleteResult, err error) { - items := make([]AnalysisDefinition, 0) - - page, err := c.ListSiteAnalyses(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListSiteAnalysesCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/diagnostics/method_listsiteanalysesslot.go b/resource-manager/web/2022-09-01/diagnostics/method_listsiteanalysesslot.go new file mode 100644 index 00000000000..fdc93a945f2 --- /dev/null +++ b/resource-manager/web/2022-09-01/diagnostics/method_listsiteanalysesslot.go @@ -0,0 +1,89 @@ +package diagnostics + +import ( + "context" + "fmt" + "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 ListSiteAnalysesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AnalysisDefinition +} + +type ListSiteAnalysesSlotCompleteResult struct { + Items []AnalysisDefinition +} + +// ListSiteAnalysesSlot ... +func (c DiagnosticsClient) ListSiteAnalysesSlot(ctx context.Context, id SlotDiagnosticId) (result ListSiteAnalysesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/analyses", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AnalysisDefinition `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteAnalysesSlotComplete retrieves all the results into a single object +func (c DiagnosticsClient) ListSiteAnalysesSlotComplete(ctx context.Context, id SlotDiagnosticId) (ListSiteAnalysesSlotCompleteResult, error) { + return c.ListSiteAnalysesSlotCompleteMatchingPredicate(ctx, id, AnalysisDefinitionOperationPredicate{}) +} + +// ListSiteAnalysesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DiagnosticsClient) ListSiteAnalysesSlotCompleteMatchingPredicate(ctx context.Context, id SlotDiagnosticId, predicate AnalysisDefinitionOperationPredicate) (result ListSiteAnalysesSlotCompleteResult, err error) { + items := make([]AnalysisDefinition, 0) + + resp, err := c.ListSiteAnalysesSlot(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListSiteAnalysesSlotCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/diagnostics/method_listsiteanalysesslot_autorest.go b/resource-manager/web/2022-09-01/diagnostics/method_listsiteanalysesslot_autorest.go deleted file mode 100644 index c90adf2b2c5..00000000000 --- a/resource-manager/web/2022-09-01/diagnostics/method_listsiteanalysesslot_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package diagnostics - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListSiteAnalysesSlotOperationResponse struct { - HttpResponse *http.Response - Model *[]AnalysisDefinition - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListSiteAnalysesSlotOperationResponse, error) -} - -type ListSiteAnalysesSlotCompleteResult struct { - Items []AnalysisDefinition -} - -func (r ListSiteAnalysesSlotOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListSiteAnalysesSlotOperationResponse) LoadMore(ctx context.Context) (resp ListSiteAnalysesSlotOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListSiteAnalysesSlot ... -func (c DiagnosticsClient) ListSiteAnalysesSlot(ctx context.Context, id SlotDiagnosticId) (resp ListSiteAnalysesSlotOperationResponse, err error) { - req, err := c.preparerForListSiteAnalysesSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ListSiteAnalysesSlot", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ListSiteAnalysesSlot", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListSiteAnalysesSlot(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ListSiteAnalysesSlot", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListSiteAnalysesSlot prepares the ListSiteAnalysesSlot request. -func (c DiagnosticsClient) preparerForListSiteAnalysesSlot(ctx context.Context, id SlotDiagnosticId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/analyses", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListSiteAnalysesSlotWithNextLink prepares the ListSiteAnalysesSlot request with the given nextLink token. -func (c DiagnosticsClient) preparerForListSiteAnalysesSlotWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListSiteAnalysesSlot handles the response to the ListSiteAnalysesSlot request. The method always -// closes the http.Response Body. -func (c DiagnosticsClient) responderForListSiteAnalysesSlot(resp *http.Response) (result ListSiteAnalysesSlotOperationResponse, err error) { - type page struct { - Values []AnalysisDefinition `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListSiteAnalysesSlotOperationResponse, err error) { - req, err := c.preparerForListSiteAnalysesSlotWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ListSiteAnalysesSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ListSiteAnalysesSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListSiteAnalysesSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ListSiteAnalysesSlot", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListSiteAnalysesSlotComplete retrieves all of the results into a single object -func (c DiagnosticsClient) ListSiteAnalysesSlotComplete(ctx context.Context, id SlotDiagnosticId) (ListSiteAnalysesSlotCompleteResult, error) { - return c.ListSiteAnalysesSlotCompleteMatchingPredicate(ctx, id, AnalysisDefinitionOperationPredicate{}) -} - -// ListSiteAnalysesSlotCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c DiagnosticsClient) ListSiteAnalysesSlotCompleteMatchingPredicate(ctx context.Context, id SlotDiagnosticId, predicate AnalysisDefinitionOperationPredicate) (resp ListSiteAnalysesSlotCompleteResult, err error) { - items := make([]AnalysisDefinition, 0) - - page, err := c.ListSiteAnalysesSlot(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListSiteAnalysesSlotCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/diagnostics/method_listsitedetectorresponses.go b/resource-manager/web/2022-09-01/diagnostics/method_listsitedetectorresponses.go new file mode 100644 index 00000000000..4bcc3ad77e2 --- /dev/null +++ b/resource-manager/web/2022-09-01/diagnostics/method_listsitedetectorresponses.go @@ -0,0 +1,89 @@ +package diagnostics + +import ( + "context" + "fmt" + "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 ListSiteDetectorResponsesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DetectorResponse +} + +type ListSiteDetectorResponsesCompleteResult struct { + Items []DetectorResponse +} + +// ListSiteDetectorResponses ... +func (c DiagnosticsClient) ListSiteDetectorResponses(ctx context.Context, id SiteId) (result ListSiteDetectorResponsesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/detectors", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]DetectorResponse `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteDetectorResponsesComplete retrieves all the results into a single object +func (c DiagnosticsClient) ListSiteDetectorResponsesComplete(ctx context.Context, id SiteId) (ListSiteDetectorResponsesCompleteResult, error) { + return c.ListSiteDetectorResponsesCompleteMatchingPredicate(ctx, id, DetectorResponseOperationPredicate{}) +} + +// ListSiteDetectorResponsesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DiagnosticsClient) ListSiteDetectorResponsesCompleteMatchingPredicate(ctx context.Context, id SiteId, predicate DetectorResponseOperationPredicate) (result ListSiteDetectorResponsesCompleteResult, err error) { + items := make([]DetectorResponse, 0) + + resp, err := c.ListSiteDetectorResponses(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListSiteDetectorResponsesCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/diagnostics/method_listsitedetectorresponses_autorest.go b/resource-manager/web/2022-09-01/diagnostics/method_listsitedetectorresponses_autorest.go deleted file mode 100644 index 40855e3d0d8..00000000000 --- a/resource-manager/web/2022-09-01/diagnostics/method_listsitedetectorresponses_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package diagnostics - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListSiteDetectorResponsesOperationResponse struct { - HttpResponse *http.Response - Model *[]DetectorResponse - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListSiteDetectorResponsesOperationResponse, error) -} - -type ListSiteDetectorResponsesCompleteResult struct { - Items []DetectorResponse -} - -func (r ListSiteDetectorResponsesOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListSiteDetectorResponsesOperationResponse) LoadMore(ctx context.Context) (resp ListSiteDetectorResponsesOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListSiteDetectorResponses ... -func (c DiagnosticsClient) ListSiteDetectorResponses(ctx context.Context, id SiteId) (resp ListSiteDetectorResponsesOperationResponse, err error) { - req, err := c.preparerForListSiteDetectorResponses(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ListSiteDetectorResponses", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ListSiteDetectorResponses", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListSiteDetectorResponses(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ListSiteDetectorResponses", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListSiteDetectorResponses prepares the ListSiteDetectorResponses request. -func (c DiagnosticsClient) preparerForListSiteDetectorResponses(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/detectors", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListSiteDetectorResponsesWithNextLink prepares the ListSiteDetectorResponses request with the given nextLink token. -func (c DiagnosticsClient) preparerForListSiteDetectorResponsesWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListSiteDetectorResponses handles the response to the ListSiteDetectorResponses request. The method always -// closes the http.Response Body. -func (c DiagnosticsClient) responderForListSiteDetectorResponses(resp *http.Response) (result ListSiteDetectorResponsesOperationResponse, err error) { - type page struct { - Values []DetectorResponse `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListSiteDetectorResponsesOperationResponse, err error) { - req, err := c.preparerForListSiteDetectorResponsesWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ListSiteDetectorResponses", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ListSiteDetectorResponses", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListSiteDetectorResponses(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ListSiteDetectorResponses", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListSiteDetectorResponsesComplete retrieves all of the results into a single object -func (c DiagnosticsClient) ListSiteDetectorResponsesComplete(ctx context.Context, id SiteId) (ListSiteDetectorResponsesCompleteResult, error) { - return c.ListSiteDetectorResponsesCompleteMatchingPredicate(ctx, id, DetectorResponseOperationPredicate{}) -} - -// ListSiteDetectorResponsesCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c DiagnosticsClient) ListSiteDetectorResponsesCompleteMatchingPredicate(ctx context.Context, id SiteId, predicate DetectorResponseOperationPredicate) (resp ListSiteDetectorResponsesCompleteResult, err error) { - items := make([]DetectorResponse, 0) - - page, err := c.ListSiteDetectorResponses(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListSiteDetectorResponsesCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/diagnostics/method_listsitedetectorresponsesslot.go b/resource-manager/web/2022-09-01/diagnostics/method_listsitedetectorresponsesslot.go new file mode 100644 index 00000000000..81716cfa7a5 --- /dev/null +++ b/resource-manager/web/2022-09-01/diagnostics/method_listsitedetectorresponsesslot.go @@ -0,0 +1,89 @@ +package diagnostics + +import ( + "context" + "fmt" + "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 ListSiteDetectorResponsesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DetectorResponse +} + +type ListSiteDetectorResponsesSlotCompleteResult struct { + Items []DetectorResponse +} + +// ListSiteDetectorResponsesSlot ... +func (c DiagnosticsClient) ListSiteDetectorResponsesSlot(ctx context.Context, id SlotId) (result ListSiteDetectorResponsesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/detectors", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]DetectorResponse `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteDetectorResponsesSlotComplete retrieves all the results into a single object +func (c DiagnosticsClient) ListSiteDetectorResponsesSlotComplete(ctx context.Context, id SlotId) (ListSiteDetectorResponsesSlotCompleteResult, error) { + return c.ListSiteDetectorResponsesSlotCompleteMatchingPredicate(ctx, id, DetectorResponseOperationPredicate{}) +} + +// ListSiteDetectorResponsesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DiagnosticsClient) ListSiteDetectorResponsesSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate DetectorResponseOperationPredicate) (result ListSiteDetectorResponsesSlotCompleteResult, err error) { + items := make([]DetectorResponse, 0) + + resp, err := c.ListSiteDetectorResponsesSlot(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListSiteDetectorResponsesSlotCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/diagnostics/method_listsitedetectorresponsesslot_autorest.go b/resource-manager/web/2022-09-01/diagnostics/method_listsitedetectorresponsesslot_autorest.go deleted file mode 100644 index bd10ff51345..00000000000 --- a/resource-manager/web/2022-09-01/diagnostics/method_listsitedetectorresponsesslot_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package diagnostics - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListSiteDetectorResponsesSlotOperationResponse struct { - HttpResponse *http.Response - Model *[]DetectorResponse - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListSiteDetectorResponsesSlotOperationResponse, error) -} - -type ListSiteDetectorResponsesSlotCompleteResult struct { - Items []DetectorResponse -} - -func (r ListSiteDetectorResponsesSlotOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListSiteDetectorResponsesSlotOperationResponse) LoadMore(ctx context.Context) (resp ListSiteDetectorResponsesSlotOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListSiteDetectorResponsesSlot ... -func (c DiagnosticsClient) ListSiteDetectorResponsesSlot(ctx context.Context, id SlotId) (resp ListSiteDetectorResponsesSlotOperationResponse, err error) { - req, err := c.preparerForListSiteDetectorResponsesSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ListSiteDetectorResponsesSlot", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ListSiteDetectorResponsesSlot", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListSiteDetectorResponsesSlot(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ListSiteDetectorResponsesSlot", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListSiteDetectorResponsesSlot prepares the ListSiteDetectorResponsesSlot request. -func (c DiagnosticsClient) preparerForListSiteDetectorResponsesSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/detectors", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListSiteDetectorResponsesSlotWithNextLink prepares the ListSiteDetectorResponsesSlot request with the given nextLink token. -func (c DiagnosticsClient) preparerForListSiteDetectorResponsesSlotWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListSiteDetectorResponsesSlot handles the response to the ListSiteDetectorResponsesSlot request. The method always -// closes the http.Response Body. -func (c DiagnosticsClient) responderForListSiteDetectorResponsesSlot(resp *http.Response) (result ListSiteDetectorResponsesSlotOperationResponse, err error) { - type page struct { - Values []DetectorResponse `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListSiteDetectorResponsesSlotOperationResponse, err error) { - req, err := c.preparerForListSiteDetectorResponsesSlotWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ListSiteDetectorResponsesSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ListSiteDetectorResponsesSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListSiteDetectorResponsesSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ListSiteDetectorResponsesSlot", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListSiteDetectorResponsesSlotComplete retrieves all of the results into a single object -func (c DiagnosticsClient) ListSiteDetectorResponsesSlotComplete(ctx context.Context, id SlotId) (ListSiteDetectorResponsesSlotCompleteResult, error) { - return c.ListSiteDetectorResponsesSlotCompleteMatchingPredicate(ctx, id, DetectorResponseOperationPredicate{}) -} - -// ListSiteDetectorResponsesSlotCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c DiagnosticsClient) ListSiteDetectorResponsesSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate DetectorResponseOperationPredicate) (resp ListSiteDetectorResponsesSlotCompleteResult, err error) { - items := make([]DetectorResponse, 0) - - page, err := c.ListSiteDetectorResponsesSlot(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListSiteDetectorResponsesSlotCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/diagnostics/method_listsitedetectors.go b/resource-manager/web/2022-09-01/diagnostics/method_listsitedetectors.go new file mode 100644 index 00000000000..6ba99567246 --- /dev/null +++ b/resource-manager/web/2022-09-01/diagnostics/method_listsitedetectors.go @@ -0,0 +1,89 @@ +package diagnostics + +import ( + "context" + "fmt" + "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 ListSiteDetectorsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DetectorDefinitionResource +} + +type ListSiteDetectorsCompleteResult struct { + Items []DetectorDefinitionResource +} + +// ListSiteDetectors ... +func (c DiagnosticsClient) ListSiteDetectors(ctx context.Context, id DiagnosticId) (result ListSiteDetectorsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/detectors", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]DetectorDefinitionResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteDetectorsComplete retrieves all the results into a single object +func (c DiagnosticsClient) ListSiteDetectorsComplete(ctx context.Context, id DiagnosticId) (ListSiteDetectorsCompleteResult, error) { + return c.ListSiteDetectorsCompleteMatchingPredicate(ctx, id, DetectorDefinitionResourceOperationPredicate{}) +} + +// ListSiteDetectorsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DiagnosticsClient) ListSiteDetectorsCompleteMatchingPredicate(ctx context.Context, id DiagnosticId, predicate DetectorDefinitionResourceOperationPredicate) (result ListSiteDetectorsCompleteResult, err error) { + items := make([]DetectorDefinitionResource, 0) + + resp, err := c.ListSiteDetectors(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListSiteDetectorsCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/diagnostics/method_listsitedetectors_autorest.go b/resource-manager/web/2022-09-01/diagnostics/method_listsitedetectors_autorest.go deleted file mode 100644 index 6e30420b694..00000000000 --- a/resource-manager/web/2022-09-01/diagnostics/method_listsitedetectors_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package diagnostics - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListSiteDetectorsOperationResponse struct { - HttpResponse *http.Response - Model *[]DetectorDefinitionResource - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListSiteDetectorsOperationResponse, error) -} - -type ListSiteDetectorsCompleteResult struct { - Items []DetectorDefinitionResource -} - -func (r ListSiteDetectorsOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListSiteDetectorsOperationResponse) LoadMore(ctx context.Context) (resp ListSiteDetectorsOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListSiteDetectors ... -func (c DiagnosticsClient) ListSiteDetectors(ctx context.Context, id DiagnosticId) (resp ListSiteDetectorsOperationResponse, err error) { - req, err := c.preparerForListSiteDetectors(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ListSiteDetectors", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ListSiteDetectors", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListSiteDetectors(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ListSiteDetectors", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListSiteDetectors prepares the ListSiteDetectors request. -func (c DiagnosticsClient) preparerForListSiteDetectors(ctx context.Context, id DiagnosticId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/detectors", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListSiteDetectorsWithNextLink prepares the ListSiteDetectors request with the given nextLink token. -func (c DiagnosticsClient) preparerForListSiteDetectorsWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListSiteDetectors handles the response to the ListSiteDetectors request. The method always -// closes the http.Response Body. -func (c DiagnosticsClient) responderForListSiteDetectors(resp *http.Response) (result ListSiteDetectorsOperationResponse, err error) { - type page struct { - Values []DetectorDefinitionResource `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListSiteDetectorsOperationResponse, err error) { - req, err := c.preparerForListSiteDetectorsWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ListSiteDetectors", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ListSiteDetectors", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListSiteDetectors(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ListSiteDetectors", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListSiteDetectorsComplete retrieves all of the results into a single object -func (c DiagnosticsClient) ListSiteDetectorsComplete(ctx context.Context, id DiagnosticId) (ListSiteDetectorsCompleteResult, error) { - return c.ListSiteDetectorsCompleteMatchingPredicate(ctx, id, DetectorDefinitionResourceOperationPredicate{}) -} - -// ListSiteDetectorsCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c DiagnosticsClient) ListSiteDetectorsCompleteMatchingPredicate(ctx context.Context, id DiagnosticId, predicate DetectorDefinitionResourceOperationPredicate) (resp ListSiteDetectorsCompleteResult, err error) { - items := make([]DetectorDefinitionResource, 0) - - page, err := c.ListSiteDetectors(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListSiteDetectorsCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/diagnostics/method_listsitedetectorsslot.go b/resource-manager/web/2022-09-01/diagnostics/method_listsitedetectorsslot.go new file mode 100644 index 00000000000..7a6b3972904 --- /dev/null +++ b/resource-manager/web/2022-09-01/diagnostics/method_listsitedetectorsslot.go @@ -0,0 +1,89 @@ +package diagnostics + +import ( + "context" + "fmt" + "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 ListSiteDetectorsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DetectorDefinitionResource +} + +type ListSiteDetectorsSlotCompleteResult struct { + Items []DetectorDefinitionResource +} + +// ListSiteDetectorsSlot ... +func (c DiagnosticsClient) ListSiteDetectorsSlot(ctx context.Context, id SlotDiagnosticId) (result ListSiteDetectorsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/detectors", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]DetectorDefinitionResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteDetectorsSlotComplete retrieves all the results into a single object +func (c DiagnosticsClient) ListSiteDetectorsSlotComplete(ctx context.Context, id SlotDiagnosticId) (ListSiteDetectorsSlotCompleteResult, error) { + return c.ListSiteDetectorsSlotCompleteMatchingPredicate(ctx, id, DetectorDefinitionResourceOperationPredicate{}) +} + +// ListSiteDetectorsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DiagnosticsClient) ListSiteDetectorsSlotCompleteMatchingPredicate(ctx context.Context, id SlotDiagnosticId, predicate DetectorDefinitionResourceOperationPredicate) (result ListSiteDetectorsSlotCompleteResult, err error) { + items := make([]DetectorDefinitionResource, 0) + + resp, err := c.ListSiteDetectorsSlot(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListSiteDetectorsSlotCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/diagnostics/method_listsitedetectorsslot_autorest.go b/resource-manager/web/2022-09-01/diagnostics/method_listsitedetectorsslot_autorest.go deleted file mode 100644 index 1a5c04d53e6..00000000000 --- a/resource-manager/web/2022-09-01/diagnostics/method_listsitedetectorsslot_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package diagnostics - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListSiteDetectorsSlotOperationResponse struct { - HttpResponse *http.Response - Model *[]DetectorDefinitionResource - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListSiteDetectorsSlotOperationResponse, error) -} - -type ListSiteDetectorsSlotCompleteResult struct { - Items []DetectorDefinitionResource -} - -func (r ListSiteDetectorsSlotOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListSiteDetectorsSlotOperationResponse) LoadMore(ctx context.Context) (resp ListSiteDetectorsSlotOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListSiteDetectorsSlot ... -func (c DiagnosticsClient) ListSiteDetectorsSlot(ctx context.Context, id SlotDiagnosticId) (resp ListSiteDetectorsSlotOperationResponse, err error) { - req, err := c.preparerForListSiteDetectorsSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ListSiteDetectorsSlot", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ListSiteDetectorsSlot", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListSiteDetectorsSlot(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ListSiteDetectorsSlot", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListSiteDetectorsSlot prepares the ListSiteDetectorsSlot request. -func (c DiagnosticsClient) preparerForListSiteDetectorsSlot(ctx context.Context, id SlotDiagnosticId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/detectors", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListSiteDetectorsSlotWithNextLink prepares the ListSiteDetectorsSlot request with the given nextLink token. -func (c DiagnosticsClient) preparerForListSiteDetectorsSlotWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListSiteDetectorsSlot handles the response to the ListSiteDetectorsSlot request. The method always -// closes the http.Response Body. -func (c DiagnosticsClient) responderForListSiteDetectorsSlot(resp *http.Response) (result ListSiteDetectorsSlotOperationResponse, err error) { - type page struct { - Values []DetectorDefinitionResource `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListSiteDetectorsSlotOperationResponse, err error) { - req, err := c.preparerForListSiteDetectorsSlotWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ListSiteDetectorsSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ListSiteDetectorsSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListSiteDetectorsSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ListSiteDetectorsSlot", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListSiteDetectorsSlotComplete retrieves all of the results into a single object -func (c DiagnosticsClient) ListSiteDetectorsSlotComplete(ctx context.Context, id SlotDiagnosticId) (ListSiteDetectorsSlotCompleteResult, error) { - return c.ListSiteDetectorsSlotCompleteMatchingPredicate(ctx, id, DetectorDefinitionResourceOperationPredicate{}) -} - -// ListSiteDetectorsSlotCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c DiagnosticsClient) ListSiteDetectorsSlotCompleteMatchingPredicate(ctx context.Context, id SlotDiagnosticId, predicate DetectorDefinitionResourceOperationPredicate) (resp ListSiteDetectorsSlotCompleteResult, err error) { - items := make([]DetectorDefinitionResource, 0) - - page, err := c.ListSiteDetectorsSlot(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListSiteDetectorsSlotCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/diagnostics/method_listsitediagnosticcategories.go b/resource-manager/web/2022-09-01/diagnostics/method_listsitediagnosticcategories.go new file mode 100644 index 00000000000..6190468777f --- /dev/null +++ b/resource-manager/web/2022-09-01/diagnostics/method_listsitediagnosticcategories.go @@ -0,0 +1,89 @@ +package diagnostics + +import ( + "context" + "fmt" + "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 ListSiteDiagnosticCategoriesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DiagnosticCategory +} + +type ListSiteDiagnosticCategoriesCompleteResult struct { + Items []DiagnosticCategory +} + +// ListSiteDiagnosticCategories ... +func (c DiagnosticsClient) ListSiteDiagnosticCategories(ctx context.Context, id SiteId) (result ListSiteDiagnosticCategoriesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/diagnostics", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]DiagnosticCategory `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteDiagnosticCategoriesComplete retrieves all the results into a single object +func (c DiagnosticsClient) ListSiteDiagnosticCategoriesComplete(ctx context.Context, id SiteId) (ListSiteDiagnosticCategoriesCompleteResult, error) { + return c.ListSiteDiagnosticCategoriesCompleteMatchingPredicate(ctx, id, DiagnosticCategoryOperationPredicate{}) +} + +// ListSiteDiagnosticCategoriesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DiagnosticsClient) ListSiteDiagnosticCategoriesCompleteMatchingPredicate(ctx context.Context, id SiteId, predicate DiagnosticCategoryOperationPredicate) (result ListSiteDiagnosticCategoriesCompleteResult, err error) { + items := make([]DiagnosticCategory, 0) + + resp, err := c.ListSiteDiagnosticCategories(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListSiteDiagnosticCategoriesCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/diagnostics/method_listsitediagnosticcategories_autorest.go b/resource-manager/web/2022-09-01/diagnostics/method_listsitediagnosticcategories_autorest.go deleted file mode 100644 index 5fa701212b5..00000000000 --- a/resource-manager/web/2022-09-01/diagnostics/method_listsitediagnosticcategories_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package diagnostics - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListSiteDiagnosticCategoriesOperationResponse struct { - HttpResponse *http.Response - Model *[]DiagnosticCategory - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListSiteDiagnosticCategoriesOperationResponse, error) -} - -type ListSiteDiagnosticCategoriesCompleteResult struct { - Items []DiagnosticCategory -} - -func (r ListSiteDiagnosticCategoriesOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListSiteDiagnosticCategoriesOperationResponse) LoadMore(ctx context.Context) (resp ListSiteDiagnosticCategoriesOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListSiteDiagnosticCategories ... -func (c DiagnosticsClient) ListSiteDiagnosticCategories(ctx context.Context, id SiteId) (resp ListSiteDiagnosticCategoriesOperationResponse, err error) { - req, err := c.preparerForListSiteDiagnosticCategories(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ListSiteDiagnosticCategories", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ListSiteDiagnosticCategories", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListSiteDiagnosticCategories(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ListSiteDiagnosticCategories", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListSiteDiagnosticCategories prepares the ListSiteDiagnosticCategories request. -func (c DiagnosticsClient) preparerForListSiteDiagnosticCategories(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/diagnostics", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListSiteDiagnosticCategoriesWithNextLink prepares the ListSiteDiagnosticCategories request with the given nextLink token. -func (c DiagnosticsClient) preparerForListSiteDiagnosticCategoriesWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListSiteDiagnosticCategories handles the response to the ListSiteDiagnosticCategories request. The method always -// closes the http.Response Body. -func (c DiagnosticsClient) responderForListSiteDiagnosticCategories(resp *http.Response) (result ListSiteDiagnosticCategoriesOperationResponse, err error) { - type page struct { - Values []DiagnosticCategory `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListSiteDiagnosticCategoriesOperationResponse, err error) { - req, err := c.preparerForListSiteDiagnosticCategoriesWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ListSiteDiagnosticCategories", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ListSiteDiagnosticCategories", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListSiteDiagnosticCategories(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ListSiteDiagnosticCategories", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListSiteDiagnosticCategoriesComplete retrieves all of the results into a single object -func (c DiagnosticsClient) ListSiteDiagnosticCategoriesComplete(ctx context.Context, id SiteId) (ListSiteDiagnosticCategoriesCompleteResult, error) { - return c.ListSiteDiagnosticCategoriesCompleteMatchingPredicate(ctx, id, DiagnosticCategoryOperationPredicate{}) -} - -// ListSiteDiagnosticCategoriesCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c DiagnosticsClient) ListSiteDiagnosticCategoriesCompleteMatchingPredicate(ctx context.Context, id SiteId, predicate DiagnosticCategoryOperationPredicate) (resp ListSiteDiagnosticCategoriesCompleteResult, err error) { - items := make([]DiagnosticCategory, 0) - - page, err := c.ListSiteDiagnosticCategories(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListSiteDiagnosticCategoriesCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/diagnostics/method_listsitediagnosticcategoriesslot.go b/resource-manager/web/2022-09-01/diagnostics/method_listsitediagnosticcategoriesslot.go new file mode 100644 index 00000000000..80e2bad7047 --- /dev/null +++ b/resource-manager/web/2022-09-01/diagnostics/method_listsitediagnosticcategoriesslot.go @@ -0,0 +1,89 @@ +package diagnostics + +import ( + "context" + "fmt" + "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 ListSiteDiagnosticCategoriesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DiagnosticCategory +} + +type ListSiteDiagnosticCategoriesSlotCompleteResult struct { + Items []DiagnosticCategory +} + +// ListSiteDiagnosticCategoriesSlot ... +func (c DiagnosticsClient) ListSiteDiagnosticCategoriesSlot(ctx context.Context, id SlotId) (result ListSiteDiagnosticCategoriesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/diagnostics", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]DiagnosticCategory `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteDiagnosticCategoriesSlotComplete retrieves all the results into a single object +func (c DiagnosticsClient) ListSiteDiagnosticCategoriesSlotComplete(ctx context.Context, id SlotId) (ListSiteDiagnosticCategoriesSlotCompleteResult, error) { + return c.ListSiteDiagnosticCategoriesSlotCompleteMatchingPredicate(ctx, id, DiagnosticCategoryOperationPredicate{}) +} + +// ListSiteDiagnosticCategoriesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DiagnosticsClient) ListSiteDiagnosticCategoriesSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate DiagnosticCategoryOperationPredicate) (result ListSiteDiagnosticCategoriesSlotCompleteResult, err error) { + items := make([]DiagnosticCategory, 0) + + resp, err := c.ListSiteDiagnosticCategoriesSlot(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListSiteDiagnosticCategoriesSlotCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/diagnostics/method_listsitediagnosticcategoriesslot_autorest.go b/resource-manager/web/2022-09-01/diagnostics/method_listsitediagnosticcategoriesslot_autorest.go deleted file mode 100644 index c1e5761870e..00000000000 --- a/resource-manager/web/2022-09-01/diagnostics/method_listsitediagnosticcategoriesslot_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package diagnostics - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListSiteDiagnosticCategoriesSlotOperationResponse struct { - HttpResponse *http.Response - Model *[]DiagnosticCategory - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListSiteDiagnosticCategoriesSlotOperationResponse, error) -} - -type ListSiteDiagnosticCategoriesSlotCompleteResult struct { - Items []DiagnosticCategory -} - -func (r ListSiteDiagnosticCategoriesSlotOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListSiteDiagnosticCategoriesSlotOperationResponse) LoadMore(ctx context.Context) (resp ListSiteDiagnosticCategoriesSlotOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListSiteDiagnosticCategoriesSlot ... -func (c DiagnosticsClient) ListSiteDiagnosticCategoriesSlot(ctx context.Context, id SlotId) (resp ListSiteDiagnosticCategoriesSlotOperationResponse, err error) { - req, err := c.preparerForListSiteDiagnosticCategoriesSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ListSiteDiagnosticCategoriesSlot", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ListSiteDiagnosticCategoriesSlot", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListSiteDiagnosticCategoriesSlot(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ListSiteDiagnosticCategoriesSlot", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListSiteDiagnosticCategoriesSlot prepares the ListSiteDiagnosticCategoriesSlot request. -func (c DiagnosticsClient) preparerForListSiteDiagnosticCategoriesSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/diagnostics", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListSiteDiagnosticCategoriesSlotWithNextLink prepares the ListSiteDiagnosticCategoriesSlot request with the given nextLink token. -func (c DiagnosticsClient) preparerForListSiteDiagnosticCategoriesSlotWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListSiteDiagnosticCategoriesSlot handles the response to the ListSiteDiagnosticCategoriesSlot request. The method always -// closes the http.Response Body. -func (c DiagnosticsClient) responderForListSiteDiagnosticCategoriesSlot(resp *http.Response) (result ListSiteDiagnosticCategoriesSlotOperationResponse, err error) { - type page struct { - Values []DiagnosticCategory `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListSiteDiagnosticCategoriesSlotOperationResponse, err error) { - req, err := c.preparerForListSiteDiagnosticCategoriesSlotWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ListSiteDiagnosticCategoriesSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ListSiteDiagnosticCategoriesSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListSiteDiagnosticCategoriesSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "diagnostics.DiagnosticsClient", "ListSiteDiagnosticCategoriesSlot", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListSiteDiagnosticCategoriesSlotComplete retrieves all of the results into a single object -func (c DiagnosticsClient) ListSiteDiagnosticCategoriesSlotComplete(ctx context.Context, id SlotId) (ListSiteDiagnosticCategoriesSlotCompleteResult, error) { - return c.ListSiteDiagnosticCategoriesSlotCompleteMatchingPredicate(ctx, id, DiagnosticCategoryOperationPredicate{}) -} - -// ListSiteDiagnosticCategoriesSlotCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c DiagnosticsClient) ListSiteDiagnosticCategoriesSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate DiagnosticCategoryOperationPredicate) (resp ListSiteDiagnosticCategoriesSlotCompleteResult, err error) { - items := make([]DiagnosticCategory, 0) - - page, err := c.ListSiteDiagnosticCategoriesSlot(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListSiteDiagnosticCategoriesSlotCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/domains/client.go b/resource-manager/web/2022-09-01/domains/client.go index 95b5b283581..4816b188ae1 100644 --- a/resource-manager/web/2022-09-01/domains/client.go +++ b/resource-manager/web/2022-09-01/domains/client.go @@ -1,18 +1,26 @@ package domains -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 DomainsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewDomainsClientWithBaseURI(endpoint string) DomainsClient { - return DomainsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewDomainsClientWithBaseURI(api environments.Api) (*DomainsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "domains", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DomainsClient: %+v", err) } + + return &DomainsClient{ + Client: client, + }, nil } diff --git a/resource-manager/web/2022-09-01/domains/constants.go b/resource-manager/web/2022-09-01/domains/constants.go index 6280cd96164..a2302025ac5 100644 --- a/resource-manager/web/2022-09-01/domains/constants.go +++ b/resource-manager/web/2022-09-01/domains/constants.go @@ -1,6 +1,10 @@ package domains -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. @@ -19,6 +23,19 @@ func PossibleValuesForAzureResourceType() []string { } } +func (s *AzureResourceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureResourceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAzureResourceType(input string) (*AzureResourceType, error) { vals := map[string]AzureResourceType{ "trafficmanager": AzureResourceTypeTrafficManager, @@ -47,6 +64,19 @@ func PossibleValuesForCustomHostNameDnsRecordType() []string { } } +func (s *CustomHostNameDnsRecordType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCustomHostNameDnsRecordType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseCustomHostNameDnsRecordType(input string) (*CustomHostNameDnsRecordType, error) { vals := map[string]CustomHostNameDnsRecordType{ "a": CustomHostNameDnsRecordTypeA, @@ -75,6 +105,19 @@ func PossibleValuesForDnsType() []string { } } +func (s *DnsType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDnsType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseDnsType(input string) (*DnsType, error) { vals := map[string]DnsType{ "azuredns": DnsTypeAzureDns, @@ -141,6 +184,19 @@ func PossibleValuesForDomainStatus() []string { } } +func (s *DomainStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDomainStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseDomainStatus(input string) (*DomainStatus, error) { vals := map[string]DomainStatus{ "active": DomainStatusActive, @@ -188,6 +244,19 @@ func PossibleValuesForDomainType() []string { } } +func (s *DomainType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDomainType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseDomainType(input string) (*DomainType, error) { vals := map[string]DomainType{ "regular": DomainTypeRegular, @@ -216,6 +285,19 @@ func PossibleValuesForHostNameType() []string { } } +func (s *HostNameType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHostNameType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseHostNameType(input string) (*HostNameType, error) { vals := map[string]HostNameType{ "managed": HostNameTypeManaged, @@ -250,6 +332,19 @@ func PossibleValuesForProvisioningState() []string { } } +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseProvisioningState(input string) (*ProvisioningState, error) { vals := map[string]ProvisioningState{ "canceled": ProvisioningStateCanceled, @@ -283,6 +378,19 @@ func PossibleValuesForResourceNotRenewableReason() []string { } } +func (s *ResourceNotRenewableReason) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResourceNotRenewableReason(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseResourceNotRenewableReason(input string) (*ResourceNotRenewableReason, error) { vals := map[string]ResourceNotRenewableReason{ "expirationnotinrenewaltimerange": ResourceNotRenewableReasonExpirationNotInRenewalTimeRange, diff --git a/resource-manager/web/2022-09-01/domains/method_checkavailability.go b/resource-manager/web/2022-09-01/domains/method_checkavailability.go new file mode 100644 index 00000000000..a6c4cd9f121 --- /dev/null +++ b/resource-manager/web/2022-09-01/domains/method_checkavailability.go @@ -0,0 +1,57 @@ +package domains + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 CheckAvailabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DomainAvailabilityCheckResult +} + +// CheckAvailability ... +func (c DomainsClient) CheckAvailability(ctx context.Context, id commonids.SubscriptionId, input NameIdentifier) (result CheckAvailabilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.DomainRegistration/checkDomainAvailability", 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 +} diff --git a/resource-manager/web/2022-09-01/domains/method_checkavailability_autorest.go b/resource-manager/web/2022-09-01/domains/method_checkavailability_autorest.go deleted file mode 100644 index bb80f057b2c..00000000000 --- a/resource-manager/web/2022-09-01/domains/method_checkavailability_autorest.go +++ /dev/null @@ -1,71 +0,0 @@ -package domains - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CheckAvailabilityOperationResponse struct { - HttpResponse *http.Response - Model *DomainAvailabilityCheckResult -} - -// CheckAvailability ... -func (c DomainsClient) CheckAvailability(ctx context.Context, id commonids.SubscriptionId, input NameIdentifier) (result CheckAvailabilityOperationResponse, err error) { - req, err := c.preparerForCheckAvailability(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "CheckAvailability", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "CheckAvailability", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCheckAvailability(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "CheckAvailability", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCheckAvailability prepares the CheckAvailability request. -func (c DomainsClient) preparerForCheckAvailability(ctx context.Context, id commonids.SubscriptionId, input NameIdentifier) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.DomainRegistration/checkDomainAvailability", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCheckAvailability handles the response to the CheckAvailability request. The method always -// closes the http.Response Body. -func (c DomainsClient) responderForCheckAvailability(resp *http.Response) (result CheckAvailabilityOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/domains/method_createorupdate.go b/resource-manager/web/2022-09-01/domains/method_createorupdate.go new file mode 100644 index 00000000000..fb880ebeeeb --- /dev/null +++ b/resource-manager/web/2022-09-01/domains/method_createorupdate.go @@ -0,0 +1,74 @@ +package domains + +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 +} + +// CreateOrUpdate ... +func (c DomainsClient) CreateOrUpdate(ctx context.Context, id DomainId, input Domain) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 DomainsClient) CreateOrUpdateThenPoll(ctx context.Context, id DomainId, input Domain) 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 +} diff --git a/resource-manager/web/2022-09-01/domains/method_createorupdate_autorest.go b/resource-manager/web/2022-09-01/domains/method_createorupdate_autorest.go deleted file mode 100644 index eb4e047f347..00000000000 --- a/resource-manager/web/2022-09-01/domains/method_createorupdate_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package domains - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateOrUpdate ... -func (c DomainsClient) CreateOrUpdate(ctx context.Context, id DomainId, input Domain) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c DomainsClient) CreateOrUpdateThenPoll(ctx context.Context, id DomainId, input Domain) error { - result, err := c.CreateOrUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateOrUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateOrUpdate: %+v", err) - } - - return nil -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c DomainsClient) preparerForCreateOrUpdate(ctx context.Context, id DomainId, input Domain) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateOrUpdate sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c DomainsClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/domains/method_createorupdateownershipidentifier.go b/resource-manager/web/2022-09-01/domains/method_createorupdateownershipidentifier.go new file mode 100644 index 00000000000..48dee77a159 --- /dev/null +++ b/resource-manager/web/2022-09-01/domains/method_createorupdateownershipidentifier.go @@ -0,0 +1,55 @@ +package domains + +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 CreateOrUpdateOwnershipIdentifierOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DomainOwnershipIdentifier +} + +// CreateOrUpdateOwnershipIdentifier ... +func (c DomainsClient) CreateOrUpdateOwnershipIdentifier(ctx context.Context, id DomainOwnershipIdentifierId, input DomainOwnershipIdentifier) (result CreateOrUpdateOwnershipIdentifierOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 +} diff --git a/resource-manager/web/2022-09-01/domains/method_createorupdateownershipidentifier_autorest.go b/resource-manager/web/2022-09-01/domains/method_createorupdateownershipidentifier_autorest.go deleted file mode 100644 index 32a50b0ce1e..00000000000 --- a/resource-manager/web/2022-09-01/domains/method_createorupdateownershipidentifier_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package domains - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateOwnershipIdentifierOperationResponse struct { - HttpResponse *http.Response - Model *DomainOwnershipIdentifier -} - -// CreateOrUpdateOwnershipIdentifier ... -func (c DomainsClient) CreateOrUpdateOwnershipIdentifier(ctx context.Context, id DomainOwnershipIdentifierId, input DomainOwnershipIdentifier) (result CreateOrUpdateOwnershipIdentifierOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdateOwnershipIdentifier(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "CreateOrUpdateOwnershipIdentifier", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "CreateOrUpdateOwnershipIdentifier", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdateOwnershipIdentifier(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "CreateOrUpdateOwnershipIdentifier", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdateOwnershipIdentifier prepares the CreateOrUpdateOwnershipIdentifier request. -func (c DomainsClient) preparerForCreateOrUpdateOwnershipIdentifier(ctx context.Context, id DomainOwnershipIdentifierId, input DomainOwnershipIdentifier) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateOrUpdateOwnershipIdentifier handles the response to the CreateOrUpdateOwnershipIdentifier request. The method always -// closes the http.Response Body. -func (c DomainsClient) responderForCreateOrUpdateOwnershipIdentifier(resp *http.Response) (result CreateOrUpdateOwnershipIdentifierOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/domains/method_delete.go b/resource-manager/web/2022-09-01/domains/method_delete.go new file mode 100644 index 00000000000..3cf8679d08e --- /dev/null +++ b/resource-manager/web/2022-09-01/domains/method_delete.go @@ -0,0 +1,76 @@ +package domains + +import ( + "context" + "fmt" + "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 +} + +type DeleteOperationOptions struct { + ForceHardDeleteDomain *bool +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.ForceHardDeleteDomain != nil { + out.Append("forceHardDeleteDomain", fmt.Sprintf("%v", *o.ForceHardDeleteDomain)) + } + return &out +} + +// Delete ... +func (c DomainsClient) Delete(ctx context.Context, id DomainId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/domains/method_delete_autorest.go b/resource-manager/web/2022-09-01/domains/method_delete_autorest.go deleted file mode 100644 index 64fcba05133..00000000000 --- a/resource-manager/web/2022-09-01/domains/method_delete_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package domains - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// 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 -} - -type DeleteOperationOptions struct { - ForceHardDeleteDomain *bool -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.ForceHardDeleteDomain != nil { - out["forceHardDeleteDomain"] = *o.ForceHardDeleteDomain - } - - return out -} - -// Delete ... -func (c DomainsClient) Delete(ctx context.Context, id DomainId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c DomainsClient) preparerForDelete(ctx context.Context, id DomainId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c DomainsClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/domains/method_deleteownershipidentifier.go b/resource-manager/web/2022-09-01/domains/method_deleteownershipidentifier.go new file mode 100644 index 00000000000..a4af2506ea1 --- /dev/null +++ b/resource-manager/web/2022-09-01/domains/method_deleteownershipidentifier.go @@ -0,0 +1,47 @@ +package domains + +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 DeleteOwnershipIdentifierOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteOwnershipIdentifier ... +func (c DomainsClient) DeleteOwnershipIdentifier(ctx context.Context, id DomainOwnershipIdentifierId) (result DeleteOwnershipIdentifierOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/domains/method_deleteownershipidentifier_autorest.go b/resource-manager/web/2022-09-01/domains/method_deleteownershipidentifier_autorest.go deleted file mode 100644 index 63c2b228d70..00000000000 --- a/resource-manager/web/2022-09-01/domains/method_deleteownershipidentifier_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package domains - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteOwnershipIdentifierOperationResponse struct { - HttpResponse *http.Response -} - -// DeleteOwnershipIdentifier ... -func (c DomainsClient) DeleteOwnershipIdentifier(ctx context.Context, id DomainOwnershipIdentifierId) (result DeleteOwnershipIdentifierOperationResponse, err error) { - req, err := c.preparerForDeleteOwnershipIdentifier(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "DeleteOwnershipIdentifier", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "DeleteOwnershipIdentifier", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeleteOwnershipIdentifier(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "DeleteOwnershipIdentifier", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeleteOwnershipIdentifier prepares the DeleteOwnershipIdentifier request. -func (c DomainsClient) preparerForDeleteOwnershipIdentifier(ctx context.Context, id DomainOwnershipIdentifierId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeleteOwnershipIdentifier handles the response to the DeleteOwnershipIdentifier request. The method always -// closes the http.Response Body. -func (c DomainsClient) responderForDeleteOwnershipIdentifier(resp *http.Response) (result DeleteOwnershipIdentifierOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/domains/method_get.go b/resource-manager/web/2022-09-01/domains/method_get.go new file mode 100644 index 00000000000..b315579e11a --- /dev/null +++ b/resource-manager/web/2022-09-01/domains/method_get.go @@ -0,0 +1,51 @@ +package domains + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Domain +} + +// Get ... +func (c DomainsClient) Get(ctx context.Context, id DomainId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/domains/method_get_autorest.go b/resource-manager/web/2022-09-01/domains/method_get_autorest.go deleted file mode 100644 index 5d524c1b676..00000000000 --- a/resource-manager/web/2022-09-01/domains/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package domains - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *Domain -} - -// Get ... -func (c DomainsClient) Get(ctx context.Context, id DomainId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c DomainsClient) preparerForGet(ctx context.Context, id DomainId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c DomainsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/domains/method_getcontrolcenterssorequest.go b/resource-manager/web/2022-09-01/domains/method_getcontrolcenterssorequest.go new file mode 100644 index 00000000000..c6276c6c205 --- /dev/null +++ b/resource-manager/web/2022-09-01/domains/method_getcontrolcenterssorequest.go @@ -0,0 +1,53 @@ +package domains + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 GetControlCenterSsoRequestOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DomainControlCenterSsoRequest +} + +// GetControlCenterSsoRequest ... +func (c DomainsClient) GetControlCenterSsoRequest(ctx context.Context, id commonids.SubscriptionId) (result GetControlCenterSsoRequestOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.DomainRegistration/generateSsoRequest", 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 +} diff --git a/resource-manager/web/2022-09-01/domains/method_getcontrolcenterssorequest_autorest.go b/resource-manager/web/2022-09-01/domains/method_getcontrolcenterssorequest_autorest.go deleted file mode 100644 index 35635580b24..00000000000 --- a/resource-manager/web/2022-09-01/domains/method_getcontrolcenterssorequest_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package domains - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetControlCenterSsoRequestOperationResponse struct { - HttpResponse *http.Response - Model *DomainControlCenterSsoRequest -} - -// GetControlCenterSsoRequest ... -func (c DomainsClient) GetControlCenterSsoRequest(ctx context.Context, id commonids.SubscriptionId) (result GetControlCenterSsoRequestOperationResponse, err error) { - req, err := c.preparerForGetControlCenterSsoRequest(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "GetControlCenterSsoRequest", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "GetControlCenterSsoRequest", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetControlCenterSsoRequest(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "GetControlCenterSsoRequest", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetControlCenterSsoRequest prepares the GetControlCenterSsoRequest request. -func (c DomainsClient) preparerForGetControlCenterSsoRequest(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.DomainRegistration/generateSsoRequest", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetControlCenterSsoRequest handles the response to the GetControlCenterSsoRequest request. The method always -// closes the http.Response Body. -func (c DomainsClient) responderForGetControlCenterSsoRequest(resp *http.Response) (result GetControlCenterSsoRequestOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/domains/method_getownershipidentifier.go b/resource-manager/web/2022-09-01/domains/method_getownershipidentifier.go new file mode 100644 index 00000000000..6d55224ceba --- /dev/null +++ b/resource-manager/web/2022-09-01/domains/method_getownershipidentifier.go @@ -0,0 +1,51 @@ +package domains + +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 GetOwnershipIdentifierOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DomainOwnershipIdentifier +} + +// GetOwnershipIdentifier ... +func (c DomainsClient) GetOwnershipIdentifier(ctx context.Context, id DomainOwnershipIdentifierId) (result GetOwnershipIdentifierOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/domains/method_getownershipidentifier_autorest.go b/resource-manager/web/2022-09-01/domains/method_getownershipidentifier_autorest.go deleted file mode 100644 index 7c5484ad482..00000000000 --- a/resource-manager/web/2022-09-01/domains/method_getownershipidentifier_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package domains - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOwnershipIdentifierOperationResponse struct { - HttpResponse *http.Response - Model *DomainOwnershipIdentifier -} - -// GetOwnershipIdentifier ... -func (c DomainsClient) GetOwnershipIdentifier(ctx context.Context, id DomainOwnershipIdentifierId) (result GetOwnershipIdentifierOperationResponse, err error) { - req, err := c.preparerForGetOwnershipIdentifier(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "GetOwnershipIdentifier", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "GetOwnershipIdentifier", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetOwnershipIdentifier(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "GetOwnershipIdentifier", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetOwnershipIdentifier prepares the GetOwnershipIdentifier request. -func (c DomainsClient) preparerForGetOwnershipIdentifier(ctx context.Context, id DomainOwnershipIdentifierId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetOwnershipIdentifier handles the response to the GetOwnershipIdentifier request. The method always -// closes the http.Response Body. -func (c DomainsClient) responderForGetOwnershipIdentifier(resp *http.Response) (result GetOwnershipIdentifierOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/domains/method_list.go b/resource-manager/web/2022-09-01/domains/method_list.go new file mode 100644 index 00000000000..926c5edf37d --- /dev/null +++ b/resource-manager/web/2022-09-01/domains/method_list.go @@ -0,0 +1,90 @@ +package domains + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Domain +} + +type ListCompleteResult struct { + Items []Domain +} + +// List ... +func (c DomainsClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.DomainRegistration/domains", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Domain `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c DomainsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, DomainOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DomainsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate DomainOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Domain, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/domains/method_list_autorest.go b/resource-manager/web/2022-09-01/domains/method_list_autorest.go deleted file mode 100644 index c908e8aa370..00000000000 --- a/resource-manager/web/2022-09-01/domains/method_list_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package domains - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListOperationResponse struct { - HttpResponse *http.Response - Model *[]Domain - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []Domain -} - -func (r ListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// List ... -func (c DomainsClient) List(ctx context.Context, id commonids.SubscriptionId) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c DomainsClient) preparerForList(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.DomainRegistration/domains", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c DomainsClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForList handles the response to the List request. The method always -// closes the http.Response Body. -func (c DomainsClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []Domain `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { - req, err := c.preparerForListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c DomainsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, DomainOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c DomainsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate DomainOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]Domain, 0) - - page, err := c.List(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/domains/method_listbyresourcegroup.go b/resource-manager/web/2022-09-01/domains/method_listbyresourcegroup.go new file mode 100644 index 00000000000..12032d0ed07 --- /dev/null +++ b/resource-manager/web/2022-09-01/domains/method_listbyresourcegroup.go @@ -0,0 +1,90 @@ +package domains + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Domain +} + +type ListByResourceGroupCompleteResult struct { + Items []Domain +} + +// ListByResourceGroup ... +func (c DomainsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.DomainRegistration/domains", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Domain `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c DomainsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, DomainOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DomainsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate DomainOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]Domain, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/domains/method_listbyresourcegroup_autorest.go b/resource-manager/web/2022-09-01/domains/method_listbyresourcegroup_autorest.go deleted file mode 100644 index 4980e16b79b..00000000000 --- a/resource-manager/web/2022-09-01/domains/method_listbyresourcegroup_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package domains - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByResourceGroupOperationResponse struct { - HttpResponse *http.Response - Model *[]Domain - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByResourceGroupOperationResponse, error) -} - -type ListByResourceGroupCompleteResult struct { - Items []Domain -} - -func (r ListByResourceGroupOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByResourceGroupOperationResponse) LoadMore(ctx context.Context) (resp ListByResourceGroupOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByResourceGroup ... -func (c DomainsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (resp ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroup(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "ListByResourceGroup", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByResourceGroup(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "ListByResourceGroup", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByResourceGroup prepares the ListByResourceGroup request. -func (c DomainsClient) preparerForListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.DomainRegistration/domains", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByResourceGroupWithNextLink prepares the ListByResourceGroup request with the given nextLink token. -func (c DomainsClient) preparerForListByResourceGroupWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByResourceGroup handles the response to the ListByResourceGroup request. The method always -// closes the http.Response Body. -func (c DomainsClient) responderForListByResourceGroup(resp *http.Response) (result ListByResourceGroupOperationResponse, err error) { - type page struct { - Values []Domain `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroupWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "ListByResourceGroup", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByResourceGroup(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "ListByResourceGroup", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByResourceGroupComplete retrieves all of the results into a single object -func (c DomainsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { - return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, DomainOperationPredicate{}) -} - -// ListByResourceGroupCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c DomainsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate DomainOperationPredicate) (resp ListByResourceGroupCompleteResult, err error) { - items := make([]Domain, 0) - - page, err := c.ListByResourceGroup(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByResourceGroupCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/domains/method_listownershipidentifiers.go b/resource-manager/web/2022-09-01/domains/method_listownershipidentifiers.go new file mode 100644 index 00000000000..3839f9a6d94 --- /dev/null +++ b/resource-manager/web/2022-09-01/domains/method_listownershipidentifiers.go @@ -0,0 +1,89 @@ +package domains + +import ( + "context" + "fmt" + "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 ListOwnershipIdentifiersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DomainOwnershipIdentifier +} + +type ListOwnershipIdentifiersCompleteResult struct { + Items []DomainOwnershipIdentifier +} + +// ListOwnershipIdentifiers ... +func (c DomainsClient) ListOwnershipIdentifiers(ctx context.Context, id DomainId) (result ListOwnershipIdentifiersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/domainOwnershipIdentifiers", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]DomainOwnershipIdentifier `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListOwnershipIdentifiersComplete retrieves all the results into a single object +func (c DomainsClient) ListOwnershipIdentifiersComplete(ctx context.Context, id DomainId) (ListOwnershipIdentifiersCompleteResult, error) { + return c.ListOwnershipIdentifiersCompleteMatchingPredicate(ctx, id, DomainOwnershipIdentifierOperationPredicate{}) +} + +// ListOwnershipIdentifiersCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DomainsClient) ListOwnershipIdentifiersCompleteMatchingPredicate(ctx context.Context, id DomainId, predicate DomainOwnershipIdentifierOperationPredicate) (result ListOwnershipIdentifiersCompleteResult, err error) { + items := make([]DomainOwnershipIdentifier, 0) + + resp, err := c.ListOwnershipIdentifiers(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListOwnershipIdentifiersCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/domains/method_listownershipidentifiers_autorest.go b/resource-manager/web/2022-09-01/domains/method_listownershipidentifiers_autorest.go deleted file mode 100644 index 572868faba1..00000000000 --- a/resource-manager/web/2022-09-01/domains/method_listownershipidentifiers_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package domains - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListOwnershipIdentifiersOperationResponse struct { - HttpResponse *http.Response - Model *[]DomainOwnershipIdentifier - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOwnershipIdentifiersOperationResponse, error) -} - -type ListOwnershipIdentifiersCompleteResult struct { - Items []DomainOwnershipIdentifier -} - -func (r ListOwnershipIdentifiersOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOwnershipIdentifiersOperationResponse) LoadMore(ctx context.Context) (resp ListOwnershipIdentifiersOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListOwnershipIdentifiers ... -func (c DomainsClient) ListOwnershipIdentifiers(ctx context.Context, id DomainId) (resp ListOwnershipIdentifiersOperationResponse, err error) { - req, err := c.preparerForListOwnershipIdentifiers(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "ListOwnershipIdentifiers", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "ListOwnershipIdentifiers", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListOwnershipIdentifiers(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "ListOwnershipIdentifiers", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListOwnershipIdentifiers prepares the ListOwnershipIdentifiers request. -func (c DomainsClient) preparerForListOwnershipIdentifiers(ctx context.Context, id DomainId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/domainOwnershipIdentifiers", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListOwnershipIdentifiersWithNextLink prepares the ListOwnershipIdentifiers request with the given nextLink token. -func (c DomainsClient) preparerForListOwnershipIdentifiersWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListOwnershipIdentifiers handles the response to the ListOwnershipIdentifiers request. The method always -// closes the http.Response Body. -func (c DomainsClient) responderForListOwnershipIdentifiers(resp *http.Response) (result ListOwnershipIdentifiersOperationResponse, err error) { - type page struct { - Values []DomainOwnershipIdentifier `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOwnershipIdentifiersOperationResponse, err error) { - req, err := c.preparerForListOwnershipIdentifiersWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "ListOwnershipIdentifiers", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "ListOwnershipIdentifiers", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListOwnershipIdentifiers(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "ListOwnershipIdentifiers", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListOwnershipIdentifiersComplete retrieves all of the results into a single object -func (c DomainsClient) ListOwnershipIdentifiersComplete(ctx context.Context, id DomainId) (ListOwnershipIdentifiersCompleteResult, error) { - return c.ListOwnershipIdentifiersCompleteMatchingPredicate(ctx, id, DomainOwnershipIdentifierOperationPredicate{}) -} - -// ListOwnershipIdentifiersCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c DomainsClient) ListOwnershipIdentifiersCompleteMatchingPredicate(ctx context.Context, id DomainId, predicate DomainOwnershipIdentifierOperationPredicate) (resp ListOwnershipIdentifiersCompleteResult, err error) { - items := make([]DomainOwnershipIdentifier, 0) - - page, err := c.ListOwnershipIdentifiers(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListOwnershipIdentifiersCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/domains/method_listrecommendations.go b/resource-manager/web/2022-09-01/domains/method_listrecommendations.go new file mode 100644 index 00000000000..8942a4fb1a7 --- /dev/null +++ b/resource-manager/web/2022-09-01/domains/method_listrecommendations.go @@ -0,0 +1,90 @@ +package domains + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListRecommendationsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NameIdentifier +} + +type ListRecommendationsCompleteResult struct { + Items []NameIdentifier +} + +// ListRecommendations ... +func (c DomainsClient) ListRecommendations(ctx context.Context, id commonids.SubscriptionId, input DomainRecommendationSearchParameters) (result ListRecommendationsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.DomainRegistration/listDomainRecommendations", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]NameIdentifier `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListRecommendationsComplete retrieves all the results into a single object +func (c DomainsClient) ListRecommendationsComplete(ctx context.Context, id commonids.SubscriptionId, input DomainRecommendationSearchParameters) (ListRecommendationsCompleteResult, error) { + return c.ListRecommendationsCompleteMatchingPredicate(ctx, id, input, NameIdentifierOperationPredicate{}) +} + +// ListRecommendationsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DomainsClient) ListRecommendationsCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, input DomainRecommendationSearchParameters, predicate NameIdentifierOperationPredicate) (result ListRecommendationsCompleteResult, err error) { + items := make([]NameIdentifier, 0) + + resp, err := c.ListRecommendations(ctx, id, input) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListRecommendationsCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/domains/method_listrecommendations_autorest.go b/resource-manager/web/2022-09-01/domains/method_listrecommendations_autorest.go deleted file mode 100644 index 2b2fd3afab3..00000000000 --- a/resource-manager/web/2022-09-01/domains/method_listrecommendations_autorest.go +++ /dev/null @@ -1,188 +0,0 @@ -package domains - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListRecommendationsOperationResponse struct { - HttpResponse *http.Response - Model *[]NameIdentifier - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListRecommendationsOperationResponse, error) -} - -type ListRecommendationsCompleteResult struct { - Items []NameIdentifier -} - -func (r ListRecommendationsOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListRecommendationsOperationResponse) LoadMore(ctx context.Context) (resp ListRecommendationsOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListRecommendations ... -func (c DomainsClient) ListRecommendations(ctx context.Context, id commonids.SubscriptionId, input DomainRecommendationSearchParameters) (resp ListRecommendationsOperationResponse, err error) { - req, err := c.preparerForListRecommendations(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "ListRecommendations", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "ListRecommendations", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListRecommendations(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "ListRecommendations", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListRecommendations prepares the ListRecommendations request. -func (c DomainsClient) preparerForListRecommendations(ctx context.Context, id commonids.SubscriptionId, input DomainRecommendationSearchParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.DomainRegistration/listDomainRecommendations", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListRecommendationsWithNextLink prepares the ListRecommendations request with the given nextLink token. -func (c DomainsClient) preparerForListRecommendationsWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListRecommendations handles the response to the ListRecommendations request. The method always -// closes the http.Response Body. -func (c DomainsClient) responderForListRecommendations(resp *http.Response) (result ListRecommendationsOperationResponse, err error) { - type page struct { - Values []NameIdentifier `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListRecommendationsOperationResponse, err error) { - req, err := c.preparerForListRecommendationsWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "ListRecommendations", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "ListRecommendations", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListRecommendations(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "ListRecommendations", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListRecommendationsComplete retrieves all of the results into a single object -func (c DomainsClient) ListRecommendationsComplete(ctx context.Context, id commonids.SubscriptionId, input DomainRecommendationSearchParameters) (ListRecommendationsCompleteResult, error) { - return c.ListRecommendationsCompleteMatchingPredicate(ctx, id, input, NameIdentifierOperationPredicate{}) -} - -// ListRecommendationsCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c DomainsClient) ListRecommendationsCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, input DomainRecommendationSearchParameters, predicate NameIdentifierOperationPredicate) (resp ListRecommendationsCompleteResult, err error) { - items := make([]NameIdentifier, 0) - - page, err := c.ListRecommendations(ctx, id, input) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListRecommendationsCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/domains/method_renew.go b/resource-manager/web/2022-09-01/domains/method_renew.go new file mode 100644 index 00000000000..be8be4f04af --- /dev/null +++ b/resource-manager/web/2022-09-01/domains/method_renew.go @@ -0,0 +1,49 @@ +package domains + +import ( + "context" + "fmt" + "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 RenewOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Renew ... +func (c DomainsClient) Renew(ctx context.Context, id DomainId) (result RenewOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/renew", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/domains/method_renew_autorest.go b/resource-manager/web/2022-09-01/domains/method_renew_autorest.go deleted file mode 100644 index 19b6a1b5078..00000000000 --- a/resource-manager/web/2022-09-01/domains/method_renew_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package domains - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type RenewOperationResponse struct { - HttpResponse *http.Response -} - -// Renew ... -func (c DomainsClient) Renew(ctx context.Context, id DomainId) (result RenewOperationResponse, err error) { - req, err := c.preparerForRenew(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "Renew", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "Renew", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForRenew(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "Renew", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForRenew prepares the Renew request. -func (c DomainsClient) preparerForRenew(ctx context.Context, id DomainId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/renew", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForRenew handles the response to the Renew request. The method always -// closes the http.Response Body. -func (c DomainsClient) responderForRenew(resp *http.Response) (result RenewOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/domains/method_transferout.go b/resource-manager/web/2022-09-01/domains/method_transferout.go new file mode 100644 index 00000000000..2ccf752cd96 --- /dev/null +++ b/resource-manager/web/2022-09-01/domains/method_transferout.go @@ -0,0 +1,52 @@ +package domains + +import ( + "context" + "fmt" + "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 TransferOutOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Domain +} + +// TransferOut ... +func (c DomainsClient) TransferOut(ctx context.Context, id DomainId) (result TransferOutOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/transferOut", 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 +} diff --git a/resource-manager/web/2022-09-01/domains/method_transferout_autorest.go b/resource-manager/web/2022-09-01/domains/method_transferout_autorest.go deleted file mode 100644 index 7d8dc443a35..00000000000 --- a/resource-manager/web/2022-09-01/domains/method_transferout_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package domains - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type TransferOutOperationResponse struct { - HttpResponse *http.Response - Model *Domain -} - -// TransferOut ... -func (c DomainsClient) TransferOut(ctx context.Context, id DomainId) (result TransferOutOperationResponse, err error) { - req, err := c.preparerForTransferOut(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "TransferOut", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "TransferOut", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForTransferOut(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "TransferOut", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForTransferOut prepares the TransferOut request. -func (c DomainsClient) preparerForTransferOut(ctx context.Context, id DomainId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/transferOut", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForTransferOut handles the response to the TransferOut request. The method always -// closes the http.Response Body. -func (c DomainsClient) responderForTransferOut(resp *http.Response) (result TransferOutOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/domains/method_update.go b/resource-manager/web/2022-09-01/domains/method_update.go new file mode 100644 index 00000000000..b79156013b3 --- /dev/null +++ b/resource-manager/web/2022-09-01/domains/method_update.go @@ -0,0 +1,56 @@ +package domains + +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 UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Domain +} + +// Update ... +func (c DomainsClient) Update(ctx context.Context, id DomainId, input DomainPatchResource) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + 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 +} diff --git a/resource-manager/web/2022-09-01/domains/method_update_autorest.go b/resource-manager/web/2022-09-01/domains/method_update_autorest.go deleted file mode 100644 index 62eea9369a4..00000000000 --- a/resource-manager/web/2022-09-01/domains/method_update_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package domains - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateOperationResponse struct { - HttpResponse *http.Response - Model *Domain -} - -// Update ... -func (c DomainsClient) Update(ctx context.Context, id DomainId, input DomainPatchResource) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c DomainsClient) preparerForUpdate(ctx context.Context, id DomainId, input DomainPatchResource) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdate handles the response to the Update request. The method always -// closes the http.Response Body. -func (c DomainsClient) responderForUpdate(resp *http.Response) (result UpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/domains/method_updateownershipidentifier.go b/resource-manager/web/2022-09-01/domains/method_updateownershipidentifier.go new file mode 100644 index 00000000000..8fbc96a4bf9 --- /dev/null +++ b/resource-manager/web/2022-09-01/domains/method_updateownershipidentifier.go @@ -0,0 +1,55 @@ +package domains + +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 UpdateOwnershipIdentifierOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DomainOwnershipIdentifier +} + +// UpdateOwnershipIdentifier ... +func (c DomainsClient) UpdateOwnershipIdentifier(ctx context.Context, id DomainOwnershipIdentifierId, input DomainOwnershipIdentifier) (result UpdateOwnershipIdentifierOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + 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 +} diff --git a/resource-manager/web/2022-09-01/domains/method_updateownershipidentifier_autorest.go b/resource-manager/web/2022-09-01/domains/method_updateownershipidentifier_autorest.go deleted file mode 100644 index 031de261635..00000000000 --- a/resource-manager/web/2022-09-01/domains/method_updateownershipidentifier_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package domains - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateOwnershipIdentifierOperationResponse struct { - HttpResponse *http.Response - Model *DomainOwnershipIdentifier -} - -// UpdateOwnershipIdentifier ... -func (c DomainsClient) UpdateOwnershipIdentifier(ctx context.Context, id DomainOwnershipIdentifierId, input DomainOwnershipIdentifier) (result UpdateOwnershipIdentifierOperationResponse, err error) { - req, err := c.preparerForUpdateOwnershipIdentifier(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "UpdateOwnershipIdentifier", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "UpdateOwnershipIdentifier", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateOwnershipIdentifier(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "domains.DomainsClient", "UpdateOwnershipIdentifier", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateOwnershipIdentifier prepares the UpdateOwnershipIdentifier request. -func (c DomainsClient) preparerForUpdateOwnershipIdentifier(ctx context.Context, id DomainOwnershipIdentifierId, input DomainOwnershipIdentifier) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateOwnershipIdentifier handles the response to the UpdateOwnershipIdentifier request. The method always -// closes the http.Response Body. -func (c DomainsClient) responderForUpdateOwnershipIdentifier(resp *http.Response) (result UpdateOwnershipIdentifierOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/global/client.go b/resource-manager/web/2022-09-01/global/client.go index f2933d80c37..54e6697df83 100644 --- a/resource-manager/web/2022-09-01/global/client.go +++ b/resource-manager/web/2022-09-01/global/client.go @@ -1,18 +1,26 @@ package global -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 GlobalClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewGlobalClientWithBaseURI(endpoint string) GlobalClient { - return GlobalClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewGlobalClientWithBaseURI(api environments.Api) (*GlobalClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "global", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating GlobalClient: %+v", err) } + + return &GlobalClient{ + Client: client, + }, nil } diff --git a/resource-manager/web/2022-09-01/global/method_getdeletedwebapp.go b/resource-manager/web/2022-09-01/global/method_getdeletedwebapp.go new file mode 100644 index 00000000000..30a5a9e118d --- /dev/null +++ b/resource-manager/web/2022-09-01/global/method_getdeletedwebapp.go @@ -0,0 +1,51 @@ +package global + +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 GetDeletedWebAppOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DeletedSite +} + +// GetDeletedWebApp ... +func (c GlobalClient) GetDeletedWebApp(ctx context.Context, id DeletedSiteId) (result GetDeletedWebAppOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/global/method_getdeletedwebapp_autorest.go b/resource-manager/web/2022-09-01/global/method_getdeletedwebapp_autorest.go deleted file mode 100644 index 59c08730549..00000000000 --- a/resource-manager/web/2022-09-01/global/method_getdeletedwebapp_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package global - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetDeletedWebAppOperationResponse struct { - HttpResponse *http.Response - Model *DeletedSite -} - -// GetDeletedWebApp ... -func (c GlobalClient) GetDeletedWebApp(ctx context.Context, id DeletedSiteId) (result GetDeletedWebAppOperationResponse, err error) { - req, err := c.preparerForGetDeletedWebApp(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "global.GlobalClient", "GetDeletedWebApp", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "global.GlobalClient", "GetDeletedWebApp", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetDeletedWebApp(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "global.GlobalClient", "GetDeletedWebApp", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetDeletedWebApp prepares the GetDeletedWebApp request. -func (c GlobalClient) preparerForGetDeletedWebApp(ctx context.Context, id DeletedSiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetDeletedWebApp handles the response to the GetDeletedWebApp request. The method always -// closes the http.Response Body. -func (c GlobalClient) responderForGetDeletedWebApp(resp *http.Response) (result GetDeletedWebAppOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/global/method_getdeletedwebappsnapshots.go b/resource-manager/web/2022-09-01/global/method_getdeletedwebappsnapshots.go new file mode 100644 index 00000000000..f3a075a0db9 --- /dev/null +++ b/resource-manager/web/2022-09-01/global/method_getdeletedwebappsnapshots.go @@ -0,0 +1,52 @@ +package global + +import ( + "context" + "fmt" + "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 GetDeletedWebAppSnapshotsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Snapshot +} + +// GetDeletedWebAppSnapshots ... +func (c GlobalClient) GetDeletedWebAppSnapshots(ctx context.Context, id DeletedSiteId) (result GetDeletedWebAppSnapshotsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/snapshots", 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 +} diff --git a/resource-manager/web/2022-09-01/global/method_getdeletedwebappsnapshots_autorest.go b/resource-manager/web/2022-09-01/global/method_getdeletedwebappsnapshots_autorest.go deleted file mode 100644 index eedbd954119..00000000000 --- a/resource-manager/web/2022-09-01/global/method_getdeletedwebappsnapshots_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package global - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetDeletedWebAppSnapshotsOperationResponse struct { - HttpResponse *http.Response - Model *[]Snapshot -} - -// GetDeletedWebAppSnapshots ... -func (c GlobalClient) GetDeletedWebAppSnapshots(ctx context.Context, id DeletedSiteId) (result GetDeletedWebAppSnapshotsOperationResponse, err error) { - req, err := c.preparerForGetDeletedWebAppSnapshots(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "global.GlobalClient", "GetDeletedWebAppSnapshots", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "global.GlobalClient", "GetDeletedWebAppSnapshots", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetDeletedWebAppSnapshots(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "global.GlobalClient", "GetDeletedWebAppSnapshots", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetDeletedWebAppSnapshots prepares the GetDeletedWebAppSnapshots request. -func (c GlobalClient) preparerForGetDeletedWebAppSnapshots(ctx context.Context, id DeletedSiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/snapshots", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetDeletedWebAppSnapshots handles the response to the GetDeletedWebAppSnapshots request. The method always -// closes the http.Response Body. -func (c GlobalClient) responderForGetDeletedWebAppSnapshots(resp *http.Response) (result GetDeletedWebAppSnapshotsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/kubeenvironments/client.go b/resource-manager/web/2022-09-01/kubeenvironments/client.go index 7a4a32c0a13..271b96b5d26 100644 --- a/resource-manager/web/2022-09-01/kubeenvironments/client.go +++ b/resource-manager/web/2022-09-01/kubeenvironments/client.go @@ -1,18 +1,26 @@ package kubeenvironments -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 KubeEnvironmentsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewKubeEnvironmentsClientWithBaseURI(endpoint string) KubeEnvironmentsClient { - return KubeEnvironmentsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewKubeEnvironmentsClientWithBaseURI(api environments.Api) (*KubeEnvironmentsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "kubeenvironments", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating KubeEnvironmentsClient: %+v", err) } + + return &KubeEnvironmentsClient{ + Client: client, + }, nil } diff --git a/resource-manager/web/2022-09-01/kubeenvironments/constants.go b/resource-manager/web/2022-09-01/kubeenvironments/constants.go index 1f1dd7c54c4..7aaae27eece 100644 --- a/resource-manager/web/2022-09-01/kubeenvironments/constants.go +++ b/resource-manager/web/2022-09-01/kubeenvironments/constants.go @@ -1,6 +1,10 @@ package kubeenvironments -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. @@ -19,6 +23,19 @@ func PossibleValuesForFrontEndServiceType() []string { } } +func (s *FrontEndServiceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFrontEndServiceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseFrontEndServiceType(input string) (*FrontEndServiceType, error) { vals := map[string]FrontEndServiceType{ "loadbalancer": FrontEndServiceTypeLoadBalancer, @@ -63,6 +80,19 @@ func PossibleValuesForKubeEnvironmentProvisioningState() []string { } } +func (s *KubeEnvironmentProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKubeEnvironmentProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseKubeEnvironmentProvisioningState(input string) (*KubeEnvironmentProvisioningState, error) { vals := map[string]KubeEnvironmentProvisioningState{ "canceled": KubeEnvironmentProvisioningStateCanceled, @@ -99,6 +129,19 @@ func PossibleValuesForStorageType() []string { } } +func (s *StorageType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStorageType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseStorageType(input string) (*StorageType, error) { vals := map[string]StorageType{ "localnode": StorageTypeLocalNode, diff --git a/resource-manager/web/2022-09-01/kubeenvironments/method_createorupdate.go b/resource-manager/web/2022-09-01/kubeenvironments/method_createorupdate.go new file mode 100644 index 00000000000..9b38bf9528b --- /dev/null +++ b/resource-manager/web/2022-09-01/kubeenvironments/method_createorupdate.go @@ -0,0 +1,74 @@ +package kubeenvironments + +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 +} + +// CreateOrUpdate ... +func (c KubeEnvironmentsClient) CreateOrUpdate(ctx context.Context, id KubeEnvironmentId, input KubeEnvironment) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 KubeEnvironmentsClient) CreateOrUpdateThenPoll(ctx context.Context, id KubeEnvironmentId, input KubeEnvironment) 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 +} diff --git a/resource-manager/web/2022-09-01/kubeenvironments/method_createorupdate_autorest.go b/resource-manager/web/2022-09-01/kubeenvironments/method_createorupdate_autorest.go deleted file mode 100644 index 68a0d7d0b3d..00000000000 --- a/resource-manager/web/2022-09-01/kubeenvironments/method_createorupdate_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package kubeenvironments - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateOrUpdate ... -func (c KubeEnvironmentsClient) CreateOrUpdate(ctx context.Context, id KubeEnvironmentId, input KubeEnvironment) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "kubeenvironments.KubeEnvironmentsClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "kubeenvironments.KubeEnvironmentsClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c KubeEnvironmentsClient) CreateOrUpdateThenPoll(ctx context.Context, id KubeEnvironmentId, input KubeEnvironment) error { - result, err := c.CreateOrUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateOrUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateOrUpdate: %+v", err) - } - - return nil -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c KubeEnvironmentsClient) preparerForCreateOrUpdate(ctx context.Context, id KubeEnvironmentId, input KubeEnvironment) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateOrUpdate sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c KubeEnvironmentsClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/kubeenvironments/method_delete.go b/resource-manager/web/2022-09-01/kubeenvironments/method_delete.go new file mode 100644 index 00000000000..4bd2c3b3d81 --- /dev/null +++ b/resource-manager/web/2022-09-01/kubeenvironments/method_delete.go @@ -0,0 +1,71 @@ +package kubeenvironments + +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 KubeEnvironmentsClient) Delete(ctx context.Context, id KubeEnvironmentId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 KubeEnvironmentsClient) DeleteThenPoll(ctx context.Context, id KubeEnvironmentId) 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 +} diff --git a/resource-manager/web/2022-09-01/kubeenvironments/method_delete_autorest.go b/resource-manager/web/2022-09-01/kubeenvironments/method_delete_autorest.go deleted file mode 100644 index 7cceb417513..00000000000 --- a/resource-manager/web/2022-09-01/kubeenvironments/method_delete_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package kubeenvironments - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// Delete ... -func (c KubeEnvironmentsClient) Delete(ctx context.Context, id KubeEnvironmentId) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "kubeenvironments.KubeEnvironmentsClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = c.senderForDelete(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "kubeenvironments.KubeEnvironmentsClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c KubeEnvironmentsClient) DeleteThenPoll(ctx context.Context, id KubeEnvironmentId) error { - result, err := c.Delete(ctx, id) - if err != nil { - return fmt.Errorf("performing Delete: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Delete: %+v", err) - } - - return nil -} - -// preparerForDelete prepares the Delete request. -func (c KubeEnvironmentsClient) preparerForDelete(ctx context.Context, id KubeEnvironmentId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDelete sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (c KubeEnvironmentsClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/kubeenvironments/method_get.go b/resource-manager/web/2022-09-01/kubeenvironments/method_get.go new file mode 100644 index 00000000000..bbe497d29d1 --- /dev/null +++ b/resource-manager/web/2022-09-01/kubeenvironments/method_get.go @@ -0,0 +1,51 @@ +package kubeenvironments + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *KubeEnvironment +} + +// Get ... +func (c KubeEnvironmentsClient) Get(ctx context.Context, id KubeEnvironmentId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/kubeenvironments/method_get_autorest.go b/resource-manager/web/2022-09-01/kubeenvironments/method_get_autorest.go deleted file mode 100644 index e6154439456..00000000000 --- a/resource-manager/web/2022-09-01/kubeenvironments/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package kubeenvironments - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *KubeEnvironment -} - -// Get ... -func (c KubeEnvironmentsClient) Get(ctx context.Context, id KubeEnvironmentId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "kubeenvironments.KubeEnvironmentsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "kubeenvironments.KubeEnvironmentsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "kubeenvironments.KubeEnvironmentsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c KubeEnvironmentsClient) preparerForGet(ctx context.Context, id KubeEnvironmentId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c KubeEnvironmentsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/kubeenvironments/method_listbyresourcegroup.go b/resource-manager/web/2022-09-01/kubeenvironments/method_listbyresourcegroup.go new file mode 100644 index 00000000000..1b4cf1323a5 --- /dev/null +++ b/resource-manager/web/2022-09-01/kubeenvironments/method_listbyresourcegroup.go @@ -0,0 +1,90 @@ +package kubeenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]KubeEnvironment +} + +type ListByResourceGroupCompleteResult struct { + Items []KubeEnvironment +} + +// ListByResourceGroup ... +func (c KubeEnvironmentsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/kubeEnvironments", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]KubeEnvironment `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c KubeEnvironmentsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, KubeEnvironmentOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c KubeEnvironmentsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate KubeEnvironmentOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]KubeEnvironment, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/kubeenvironments/method_listbyresourcegroup_autorest.go b/resource-manager/web/2022-09-01/kubeenvironments/method_listbyresourcegroup_autorest.go deleted file mode 100644 index 72e05b6ac74..00000000000 --- a/resource-manager/web/2022-09-01/kubeenvironments/method_listbyresourcegroup_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package kubeenvironments - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByResourceGroupOperationResponse struct { - HttpResponse *http.Response - Model *[]KubeEnvironment - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByResourceGroupOperationResponse, error) -} - -type ListByResourceGroupCompleteResult struct { - Items []KubeEnvironment -} - -func (r ListByResourceGroupOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByResourceGroupOperationResponse) LoadMore(ctx context.Context) (resp ListByResourceGroupOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByResourceGroup ... -func (c KubeEnvironmentsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (resp ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroup(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "kubeenvironments.KubeEnvironmentsClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "kubeenvironments.KubeEnvironmentsClient", "ListByResourceGroup", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByResourceGroup(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "kubeenvironments.KubeEnvironmentsClient", "ListByResourceGroup", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByResourceGroup prepares the ListByResourceGroup request. -func (c KubeEnvironmentsClient) preparerForListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Web/kubeEnvironments", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByResourceGroupWithNextLink prepares the ListByResourceGroup request with the given nextLink token. -func (c KubeEnvironmentsClient) preparerForListByResourceGroupWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByResourceGroup handles the response to the ListByResourceGroup request. The method always -// closes the http.Response Body. -func (c KubeEnvironmentsClient) responderForListByResourceGroup(resp *http.Response) (result ListByResourceGroupOperationResponse, err error) { - type page struct { - Values []KubeEnvironment `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroupWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "kubeenvironments.KubeEnvironmentsClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "kubeenvironments.KubeEnvironmentsClient", "ListByResourceGroup", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByResourceGroup(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "kubeenvironments.KubeEnvironmentsClient", "ListByResourceGroup", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByResourceGroupComplete retrieves all of the results into a single object -func (c KubeEnvironmentsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { - return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, KubeEnvironmentOperationPredicate{}) -} - -// ListByResourceGroupCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c KubeEnvironmentsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate KubeEnvironmentOperationPredicate) (resp ListByResourceGroupCompleteResult, err error) { - items := make([]KubeEnvironment, 0) - - page, err := c.ListByResourceGroup(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByResourceGroupCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/kubeenvironments/method_listbysubscription.go b/resource-manager/web/2022-09-01/kubeenvironments/method_listbysubscription.go new file mode 100644 index 00000000000..2ba99897ad0 --- /dev/null +++ b/resource-manager/web/2022-09-01/kubeenvironments/method_listbysubscription.go @@ -0,0 +1,90 @@ +package kubeenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]KubeEnvironment +} + +type ListBySubscriptionCompleteResult struct { + Items []KubeEnvironment +} + +// ListBySubscription ... +func (c KubeEnvironmentsClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/kubeEnvironments", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]KubeEnvironment `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c KubeEnvironmentsClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, KubeEnvironmentOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c KubeEnvironmentsClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate KubeEnvironmentOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]KubeEnvironment, 0) + + resp, err := c.ListBySubscription(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListBySubscriptionCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/kubeenvironments/method_listbysubscription_autorest.go b/resource-manager/web/2022-09-01/kubeenvironments/method_listbysubscription_autorest.go deleted file mode 100644 index ef732d08443..00000000000 --- a/resource-manager/web/2022-09-01/kubeenvironments/method_listbysubscription_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package kubeenvironments - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListBySubscriptionOperationResponse struct { - HttpResponse *http.Response - Model *[]KubeEnvironment - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListBySubscriptionOperationResponse, error) -} - -type ListBySubscriptionCompleteResult struct { - Items []KubeEnvironment -} - -func (r ListBySubscriptionOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListBySubscriptionOperationResponse) LoadMore(ctx context.Context) (resp ListBySubscriptionOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListBySubscription ... -func (c KubeEnvironmentsClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (resp ListBySubscriptionOperationResponse, err error) { - req, err := c.preparerForListBySubscription(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "kubeenvironments.KubeEnvironmentsClient", "ListBySubscription", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "kubeenvironments.KubeEnvironmentsClient", "ListBySubscription", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListBySubscription(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "kubeenvironments.KubeEnvironmentsClient", "ListBySubscription", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListBySubscription prepares the ListBySubscription request. -func (c KubeEnvironmentsClient) preparerForListBySubscription(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Web/kubeEnvironments", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListBySubscriptionWithNextLink prepares the ListBySubscription request with the given nextLink token. -func (c KubeEnvironmentsClient) preparerForListBySubscriptionWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListBySubscription handles the response to the ListBySubscription request. The method always -// closes the http.Response Body. -func (c KubeEnvironmentsClient) responderForListBySubscription(resp *http.Response) (result ListBySubscriptionOperationResponse, err error) { - type page struct { - Values []KubeEnvironment `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListBySubscriptionOperationResponse, err error) { - req, err := c.preparerForListBySubscriptionWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "kubeenvironments.KubeEnvironmentsClient", "ListBySubscription", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "kubeenvironments.KubeEnvironmentsClient", "ListBySubscription", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListBySubscription(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "kubeenvironments.KubeEnvironmentsClient", "ListBySubscription", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListBySubscriptionComplete retrieves all of the results into a single object -func (c KubeEnvironmentsClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { - return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, KubeEnvironmentOperationPredicate{}) -} - -// ListBySubscriptionCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c KubeEnvironmentsClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate KubeEnvironmentOperationPredicate) (resp ListBySubscriptionCompleteResult, err error) { - items := make([]KubeEnvironment, 0) - - page, err := c.ListBySubscription(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListBySubscriptionCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/kubeenvironments/method_update.go b/resource-manager/web/2022-09-01/kubeenvironments/method_update.go new file mode 100644 index 00000000000..1e590c15803 --- /dev/null +++ b/resource-manager/web/2022-09-01/kubeenvironments/method_update.go @@ -0,0 +1,56 @@ +package kubeenvironments + +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 UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *KubeEnvironment +} + +// Update ... +func (c KubeEnvironmentsClient) Update(ctx context.Context, id KubeEnvironmentId, input KubeEnvironmentPatchResource) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + 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 +} diff --git a/resource-manager/web/2022-09-01/kubeenvironments/method_update_autorest.go b/resource-manager/web/2022-09-01/kubeenvironments/method_update_autorest.go deleted file mode 100644 index 1253cb5b530..00000000000 --- a/resource-manager/web/2022-09-01/kubeenvironments/method_update_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package kubeenvironments - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateOperationResponse struct { - HttpResponse *http.Response - Model *KubeEnvironment -} - -// Update ... -func (c KubeEnvironmentsClient) Update(ctx context.Context, id KubeEnvironmentId, input KubeEnvironmentPatchResource) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "kubeenvironments.KubeEnvironmentsClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "kubeenvironments.KubeEnvironmentsClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "kubeenvironments.KubeEnvironmentsClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c KubeEnvironmentsClient) preparerForUpdate(ctx context.Context, id KubeEnvironmentId, input KubeEnvironmentPatchResource) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdate handles the response to the Update request. The method always -// closes the http.Response Body. -func (c KubeEnvironmentsClient) responderForUpdate(resp *http.Response) (result UpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/provider/client.go b/resource-manager/web/2022-09-01/provider/client.go index bb6bd224461..d4c5b5c24aa 100644 --- a/resource-manager/web/2022-09-01/provider/client.go +++ b/resource-manager/web/2022-09-01/provider/client.go @@ -1,18 +1,26 @@ package provider -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 ProviderClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewProviderClientWithBaseURI(endpoint string) ProviderClient { - return ProviderClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewProviderClientWithBaseURI(api environments.Api) (*ProviderClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "provider", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ProviderClient: %+v", err) } + + return &ProviderClient{ + Client: client, + }, nil } diff --git a/resource-manager/web/2022-09-01/provider/constants.go b/resource-manager/web/2022-09-01/provider/constants.go index afe018a8ac7..27444d5870f 100644 --- a/resource-manager/web/2022-09-01/provider/constants.go +++ b/resource-manager/web/2022-09-01/provider/constants.go @@ -1,6 +1,10 @@ package provider -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. @@ -25,6 +29,19 @@ func PossibleValuesForProviderOsTypeSelected() []string { } } +func (s *ProviderOsTypeSelected) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProviderOsTypeSelected(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseProviderOsTypeSelected(input string) (*ProviderOsTypeSelected, error) { vals := map[string]ProviderOsTypeSelected{ "all": ProviderOsTypeSelectedAll, @@ -58,6 +75,19 @@ func PossibleValuesForProviderStackOsType() []string { } } +func (s *ProviderStackOsType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProviderStackOsType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseProviderStackOsType(input string) (*ProviderStackOsType, error) { vals := map[string]ProviderStackOsType{ "all": ProviderStackOsTypeAll, @@ -87,6 +117,19 @@ func PossibleValuesForStackPreferredOs() []string { } } +func (s *StackPreferredOs) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStackPreferredOs(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseStackPreferredOs(input string) (*StackPreferredOs, error) { vals := map[string]StackPreferredOs{ "linux": StackPreferredOsLinux, diff --git a/resource-manager/web/2022-09-01/provider/method_getavailablestacks.go b/resource-manager/web/2022-09-01/provider/method_getavailablestacks.go new file mode 100644 index 00000000000..9eb75d990b8 --- /dev/null +++ b/resource-manager/web/2022-09-01/provider/method_getavailablestacks.go @@ -0,0 +1,117 @@ +package provider + +import ( + "context" + "fmt" + "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 GetAvailableStacksOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ApplicationStackResource +} + +type GetAvailableStacksCompleteResult struct { + Items []ApplicationStackResource +} + +type GetAvailableStacksOperationOptions struct { + OsTypeSelected *ProviderOsTypeSelected +} + +func DefaultGetAvailableStacksOperationOptions() GetAvailableStacksOperationOptions { + return GetAvailableStacksOperationOptions{} +} + +func (o GetAvailableStacksOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetAvailableStacksOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o GetAvailableStacksOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.OsTypeSelected != nil { + out.Append("osTypeSelected", fmt.Sprintf("%v", *o.OsTypeSelected)) + } + return &out +} + +// GetAvailableStacks ... +func (c ProviderClient) GetAvailableStacks(ctx context.Context, options GetAvailableStacksOperationOptions) (result GetAvailableStacksOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: "/providers/Microsoft.Web/availableStacks", + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ApplicationStackResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetAvailableStacksComplete retrieves all the results into a single object +func (c ProviderClient) GetAvailableStacksComplete(ctx context.Context, options GetAvailableStacksOperationOptions) (GetAvailableStacksCompleteResult, error) { + return c.GetAvailableStacksCompleteMatchingPredicate(ctx, options, ApplicationStackResourceOperationPredicate{}) +} + +// GetAvailableStacksCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ProviderClient) GetAvailableStacksCompleteMatchingPredicate(ctx context.Context, options GetAvailableStacksOperationOptions, predicate ApplicationStackResourceOperationPredicate) (result GetAvailableStacksCompleteResult, err error) { + items := make([]ApplicationStackResource, 0) + + resp, err := c.GetAvailableStacks(ctx, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetAvailableStacksCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/provider/method_getavailablestacks_autorest.go b/resource-manager/web/2022-09-01/provider/method_getavailablestacks_autorest.go deleted file mode 100644 index 098b0774c48..00000000000 --- a/resource-manager/web/2022-09-01/provider/method_getavailablestacks_autorest.go +++ /dev/null @@ -1,215 +0,0 @@ -package provider - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetAvailableStacksOperationResponse struct { - HttpResponse *http.Response - Model *[]ApplicationStackResource - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (GetAvailableStacksOperationResponse, error) -} - -type GetAvailableStacksCompleteResult struct { - Items []ApplicationStackResource -} - -func (r GetAvailableStacksOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r GetAvailableStacksOperationResponse) LoadMore(ctx context.Context) (resp GetAvailableStacksOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type GetAvailableStacksOperationOptions struct { - OsTypeSelected *ProviderOsTypeSelected -} - -func DefaultGetAvailableStacksOperationOptions() GetAvailableStacksOperationOptions { - return GetAvailableStacksOperationOptions{} -} - -func (o GetAvailableStacksOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o GetAvailableStacksOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.OsTypeSelected != nil { - out["osTypeSelected"] = *o.OsTypeSelected - } - - return out -} - -// GetAvailableStacks ... -func (c ProviderClient) GetAvailableStacks(ctx context.Context, options GetAvailableStacksOperationOptions) (resp GetAvailableStacksOperationResponse, err error) { - req, err := c.preparerForGetAvailableStacks(ctx, options) - if err != nil { - err = autorest.NewErrorWithError(err, "provider.ProviderClient", "GetAvailableStacks", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "provider.ProviderClient", "GetAvailableStacks", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForGetAvailableStacks(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "provider.ProviderClient", "GetAvailableStacks", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForGetAvailableStacks prepares the GetAvailableStacks request. -func (c ProviderClient) preparerForGetAvailableStacks(ctx context.Context, options GetAvailableStacksOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath("/providers/Microsoft.Web/availableStacks"), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForGetAvailableStacksWithNextLink prepares the GetAvailableStacks request with the given nextLink token. -func (c ProviderClient) preparerForGetAvailableStacksWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetAvailableStacks handles the response to the GetAvailableStacks request. The method always -// closes the http.Response Body. -func (c ProviderClient) responderForGetAvailableStacks(resp *http.Response) (result GetAvailableStacksOperationResponse, err error) { - type page struct { - Values []ApplicationStackResource `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result GetAvailableStacksOperationResponse, err error) { - req, err := c.preparerForGetAvailableStacksWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "provider.ProviderClient", "GetAvailableStacks", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "provider.ProviderClient", "GetAvailableStacks", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetAvailableStacks(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "provider.ProviderClient", "GetAvailableStacks", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// GetAvailableStacksComplete retrieves all of the results into a single object -func (c ProviderClient) GetAvailableStacksComplete(ctx context.Context, options GetAvailableStacksOperationOptions) (GetAvailableStacksCompleteResult, error) { - return c.GetAvailableStacksCompleteMatchingPredicate(ctx, options, ApplicationStackResourceOperationPredicate{}) -} - -// GetAvailableStacksCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ProviderClient) GetAvailableStacksCompleteMatchingPredicate(ctx context.Context, options GetAvailableStacksOperationOptions, predicate ApplicationStackResourceOperationPredicate) (resp GetAvailableStacksCompleteResult, err error) { - items := make([]ApplicationStackResource, 0) - - page, err := c.GetAvailableStacks(ctx, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := GetAvailableStacksCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/provider/method_getavailablestacksonprem.go b/resource-manager/web/2022-09-01/provider/method_getavailablestacksonprem.go new file mode 100644 index 00000000000..f227bc6d862 --- /dev/null +++ b/resource-manager/web/2022-09-01/provider/method_getavailablestacksonprem.go @@ -0,0 +1,118 @@ +package provider + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 GetAvailableStacksOnPremOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ApplicationStackResource +} + +type GetAvailableStacksOnPremCompleteResult struct { + Items []ApplicationStackResource +} + +type GetAvailableStacksOnPremOperationOptions struct { + OsTypeSelected *ProviderOsTypeSelected +} + +func DefaultGetAvailableStacksOnPremOperationOptions() GetAvailableStacksOnPremOperationOptions { + return GetAvailableStacksOnPremOperationOptions{} +} + +func (o GetAvailableStacksOnPremOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetAvailableStacksOnPremOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o GetAvailableStacksOnPremOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.OsTypeSelected != nil { + out.Append("osTypeSelected", fmt.Sprintf("%v", *o.OsTypeSelected)) + } + return &out +} + +// GetAvailableStacksOnPrem ... +func (c ProviderClient) GetAvailableStacksOnPrem(ctx context.Context, id commonids.SubscriptionId, options GetAvailableStacksOnPremOperationOptions) (result GetAvailableStacksOnPremOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/availableStacks", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ApplicationStackResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetAvailableStacksOnPremComplete retrieves all the results into a single object +func (c ProviderClient) GetAvailableStacksOnPremComplete(ctx context.Context, id commonids.SubscriptionId, options GetAvailableStacksOnPremOperationOptions) (GetAvailableStacksOnPremCompleteResult, error) { + return c.GetAvailableStacksOnPremCompleteMatchingPredicate(ctx, id, options, ApplicationStackResourceOperationPredicate{}) +} + +// GetAvailableStacksOnPremCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ProviderClient) GetAvailableStacksOnPremCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options GetAvailableStacksOnPremOperationOptions, predicate ApplicationStackResourceOperationPredicate) (result GetAvailableStacksOnPremCompleteResult, err error) { + items := make([]ApplicationStackResource, 0) + + resp, err := c.GetAvailableStacksOnPrem(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetAvailableStacksOnPremCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/provider/method_getavailablestacksonprem_autorest.go b/resource-manager/web/2022-09-01/provider/method_getavailablestacksonprem_autorest.go deleted file mode 100644 index 06938956b5c..00000000000 --- a/resource-manager/web/2022-09-01/provider/method_getavailablestacksonprem_autorest.go +++ /dev/null @@ -1,216 +0,0 @@ -package provider - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetAvailableStacksOnPremOperationResponse struct { - HttpResponse *http.Response - Model *[]ApplicationStackResource - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (GetAvailableStacksOnPremOperationResponse, error) -} - -type GetAvailableStacksOnPremCompleteResult struct { - Items []ApplicationStackResource -} - -func (r GetAvailableStacksOnPremOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r GetAvailableStacksOnPremOperationResponse) LoadMore(ctx context.Context) (resp GetAvailableStacksOnPremOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type GetAvailableStacksOnPremOperationOptions struct { - OsTypeSelected *ProviderOsTypeSelected -} - -func DefaultGetAvailableStacksOnPremOperationOptions() GetAvailableStacksOnPremOperationOptions { - return GetAvailableStacksOnPremOperationOptions{} -} - -func (o GetAvailableStacksOnPremOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o GetAvailableStacksOnPremOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.OsTypeSelected != nil { - out["osTypeSelected"] = *o.OsTypeSelected - } - - return out -} - -// GetAvailableStacksOnPrem ... -func (c ProviderClient) GetAvailableStacksOnPrem(ctx context.Context, id commonids.SubscriptionId, options GetAvailableStacksOnPremOperationOptions) (resp GetAvailableStacksOnPremOperationResponse, err error) { - req, err := c.preparerForGetAvailableStacksOnPrem(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "provider.ProviderClient", "GetAvailableStacksOnPrem", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "provider.ProviderClient", "GetAvailableStacksOnPrem", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForGetAvailableStacksOnPrem(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "provider.ProviderClient", "GetAvailableStacksOnPrem", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForGetAvailableStacksOnPrem prepares the GetAvailableStacksOnPrem request. -func (c ProviderClient) preparerForGetAvailableStacksOnPrem(ctx context.Context, id commonids.SubscriptionId, options GetAvailableStacksOnPremOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Web/availableStacks", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForGetAvailableStacksOnPremWithNextLink prepares the GetAvailableStacksOnPrem request with the given nextLink token. -func (c ProviderClient) preparerForGetAvailableStacksOnPremWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetAvailableStacksOnPrem handles the response to the GetAvailableStacksOnPrem request. The method always -// closes the http.Response Body. -func (c ProviderClient) responderForGetAvailableStacksOnPrem(resp *http.Response) (result GetAvailableStacksOnPremOperationResponse, err error) { - type page struct { - Values []ApplicationStackResource `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result GetAvailableStacksOnPremOperationResponse, err error) { - req, err := c.preparerForGetAvailableStacksOnPremWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "provider.ProviderClient", "GetAvailableStacksOnPrem", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "provider.ProviderClient", "GetAvailableStacksOnPrem", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetAvailableStacksOnPrem(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "provider.ProviderClient", "GetAvailableStacksOnPrem", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// GetAvailableStacksOnPremComplete retrieves all of the results into a single object -func (c ProviderClient) GetAvailableStacksOnPremComplete(ctx context.Context, id commonids.SubscriptionId, options GetAvailableStacksOnPremOperationOptions) (GetAvailableStacksOnPremCompleteResult, error) { - return c.GetAvailableStacksOnPremCompleteMatchingPredicate(ctx, id, options, ApplicationStackResourceOperationPredicate{}) -} - -// GetAvailableStacksOnPremCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ProviderClient) GetAvailableStacksOnPremCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options GetAvailableStacksOnPremOperationOptions, predicate ApplicationStackResourceOperationPredicate) (resp GetAvailableStacksOnPremCompleteResult, err error) { - items := make([]ApplicationStackResource, 0) - - page, err := c.GetAvailableStacksOnPrem(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := GetAvailableStacksOnPremCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/provider/method_getfunctionappstacks.go b/resource-manager/web/2022-09-01/provider/method_getfunctionappstacks.go new file mode 100644 index 00000000000..8d0a6904fda --- /dev/null +++ b/resource-manager/web/2022-09-01/provider/method_getfunctionappstacks.go @@ -0,0 +1,117 @@ +package provider + +import ( + "context" + "fmt" + "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 GetFunctionAppStacksOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]FunctionAppStack +} + +type GetFunctionAppStacksCompleteResult struct { + Items []FunctionAppStack +} + +type GetFunctionAppStacksOperationOptions struct { + StackOsType *ProviderStackOsType +} + +func DefaultGetFunctionAppStacksOperationOptions() GetFunctionAppStacksOperationOptions { + return GetFunctionAppStacksOperationOptions{} +} + +func (o GetFunctionAppStacksOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetFunctionAppStacksOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o GetFunctionAppStacksOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.StackOsType != nil { + out.Append("stackOsType", fmt.Sprintf("%v", *o.StackOsType)) + } + return &out +} + +// GetFunctionAppStacks ... +func (c ProviderClient) GetFunctionAppStacks(ctx context.Context, options GetFunctionAppStacksOperationOptions) (result GetFunctionAppStacksOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: "/providers/Microsoft.Web/functionAppStacks", + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]FunctionAppStack `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetFunctionAppStacksComplete retrieves all the results into a single object +func (c ProviderClient) GetFunctionAppStacksComplete(ctx context.Context, options GetFunctionAppStacksOperationOptions) (GetFunctionAppStacksCompleteResult, error) { + return c.GetFunctionAppStacksCompleteMatchingPredicate(ctx, options, FunctionAppStackOperationPredicate{}) +} + +// GetFunctionAppStacksCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ProviderClient) GetFunctionAppStacksCompleteMatchingPredicate(ctx context.Context, options GetFunctionAppStacksOperationOptions, predicate FunctionAppStackOperationPredicate) (result GetFunctionAppStacksCompleteResult, err error) { + items := make([]FunctionAppStack, 0) + + resp, err := c.GetFunctionAppStacks(ctx, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetFunctionAppStacksCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/provider/method_getfunctionappstacks_autorest.go b/resource-manager/web/2022-09-01/provider/method_getfunctionappstacks_autorest.go deleted file mode 100644 index c3f6cf5b4a1..00000000000 --- a/resource-manager/web/2022-09-01/provider/method_getfunctionappstacks_autorest.go +++ /dev/null @@ -1,215 +0,0 @@ -package provider - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetFunctionAppStacksOperationResponse struct { - HttpResponse *http.Response - Model *[]FunctionAppStack - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (GetFunctionAppStacksOperationResponse, error) -} - -type GetFunctionAppStacksCompleteResult struct { - Items []FunctionAppStack -} - -func (r GetFunctionAppStacksOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r GetFunctionAppStacksOperationResponse) LoadMore(ctx context.Context) (resp GetFunctionAppStacksOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type GetFunctionAppStacksOperationOptions struct { - StackOsType *ProviderStackOsType -} - -func DefaultGetFunctionAppStacksOperationOptions() GetFunctionAppStacksOperationOptions { - return GetFunctionAppStacksOperationOptions{} -} - -func (o GetFunctionAppStacksOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o GetFunctionAppStacksOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.StackOsType != nil { - out["stackOsType"] = *o.StackOsType - } - - return out -} - -// GetFunctionAppStacks ... -func (c ProviderClient) GetFunctionAppStacks(ctx context.Context, options GetFunctionAppStacksOperationOptions) (resp GetFunctionAppStacksOperationResponse, err error) { - req, err := c.preparerForGetFunctionAppStacks(ctx, options) - if err != nil { - err = autorest.NewErrorWithError(err, "provider.ProviderClient", "GetFunctionAppStacks", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "provider.ProviderClient", "GetFunctionAppStacks", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForGetFunctionAppStacks(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "provider.ProviderClient", "GetFunctionAppStacks", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForGetFunctionAppStacks prepares the GetFunctionAppStacks request. -func (c ProviderClient) preparerForGetFunctionAppStacks(ctx context.Context, options GetFunctionAppStacksOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath("/providers/Microsoft.Web/functionAppStacks"), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForGetFunctionAppStacksWithNextLink prepares the GetFunctionAppStacks request with the given nextLink token. -func (c ProviderClient) preparerForGetFunctionAppStacksWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetFunctionAppStacks handles the response to the GetFunctionAppStacks request. The method always -// closes the http.Response Body. -func (c ProviderClient) responderForGetFunctionAppStacks(resp *http.Response) (result GetFunctionAppStacksOperationResponse, err error) { - type page struct { - Values []FunctionAppStack `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result GetFunctionAppStacksOperationResponse, err error) { - req, err := c.preparerForGetFunctionAppStacksWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "provider.ProviderClient", "GetFunctionAppStacks", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "provider.ProviderClient", "GetFunctionAppStacks", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetFunctionAppStacks(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "provider.ProviderClient", "GetFunctionAppStacks", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// GetFunctionAppStacksComplete retrieves all of the results into a single object -func (c ProviderClient) GetFunctionAppStacksComplete(ctx context.Context, options GetFunctionAppStacksOperationOptions) (GetFunctionAppStacksCompleteResult, error) { - return c.GetFunctionAppStacksCompleteMatchingPredicate(ctx, options, FunctionAppStackOperationPredicate{}) -} - -// GetFunctionAppStacksCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ProviderClient) GetFunctionAppStacksCompleteMatchingPredicate(ctx context.Context, options GetFunctionAppStacksOperationOptions, predicate FunctionAppStackOperationPredicate) (resp GetFunctionAppStacksCompleteResult, err error) { - items := make([]FunctionAppStack, 0) - - page, err := c.GetFunctionAppStacks(ctx, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := GetFunctionAppStacksCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/provider/method_getfunctionappstacksforlocation.go b/resource-manager/web/2022-09-01/provider/method_getfunctionappstacksforlocation.go new file mode 100644 index 00000000000..6fb593e3a8f --- /dev/null +++ b/resource-manager/web/2022-09-01/provider/method_getfunctionappstacksforlocation.go @@ -0,0 +1,117 @@ +package provider + +import ( + "context" + "fmt" + "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 GetFunctionAppStacksForLocationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]FunctionAppStack +} + +type GetFunctionAppStacksForLocationCompleteResult struct { + Items []FunctionAppStack +} + +type GetFunctionAppStacksForLocationOperationOptions struct { + StackOsType *ProviderStackOsType +} + +func DefaultGetFunctionAppStacksForLocationOperationOptions() GetFunctionAppStacksForLocationOperationOptions { + return GetFunctionAppStacksForLocationOperationOptions{} +} + +func (o GetFunctionAppStacksForLocationOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetFunctionAppStacksForLocationOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o GetFunctionAppStacksForLocationOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.StackOsType != nil { + out.Append("stackOsType", fmt.Sprintf("%v", *o.StackOsType)) + } + return &out +} + +// GetFunctionAppStacksForLocation ... +func (c ProviderClient) GetFunctionAppStacksForLocation(ctx context.Context, id LocationId, options GetFunctionAppStacksForLocationOperationOptions) (result GetFunctionAppStacksForLocationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/functionAppStacks", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]FunctionAppStack `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetFunctionAppStacksForLocationComplete retrieves all the results into a single object +func (c ProviderClient) GetFunctionAppStacksForLocationComplete(ctx context.Context, id LocationId, options GetFunctionAppStacksForLocationOperationOptions) (GetFunctionAppStacksForLocationCompleteResult, error) { + return c.GetFunctionAppStacksForLocationCompleteMatchingPredicate(ctx, id, options, FunctionAppStackOperationPredicate{}) +} + +// GetFunctionAppStacksForLocationCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ProviderClient) GetFunctionAppStacksForLocationCompleteMatchingPredicate(ctx context.Context, id LocationId, options GetFunctionAppStacksForLocationOperationOptions, predicate FunctionAppStackOperationPredicate) (result GetFunctionAppStacksForLocationCompleteResult, err error) { + items := make([]FunctionAppStack, 0) + + resp, err := c.GetFunctionAppStacksForLocation(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetFunctionAppStacksForLocationCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/provider/method_getfunctionappstacksforlocation_autorest.go b/resource-manager/web/2022-09-01/provider/method_getfunctionappstacksforlocation_autorest.go deleted file mode 100644 index 0e2fc72bb0d..00000000000 --- a/resource-manager/web/2022-09-01/provider/method_getfunctionappstacksforlocation_autorest.go +++ /dev/null @@ -1,215 +0,0 @@ -package provider - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetFunctionAppStacksForLocationOperationResponse struct { - HttpResponse *http.Response - Model *[]FunctionAppStack - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (GetFunctionAppStacksForLocationOperationResponse, error) -} - -type GetFunctionAppStacksForLocationCompleteResult struct { - Items []FunctionAppStack -} - -func (r GetFunctionAppStacksForLocationOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r GetFunctionAppStacksForLocationOperationResponse) LoadMore(ctx context.Context) (resp GetFunctionAppStacksForLocationOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type GetFunctionAppStacksForLocationOperationOptions struct { - StackOsType *ProviderStackOsType -} - -func DefaultGetFunctionAppStacksForLocationOperationOptions() GetFunctionAppStacksForLocationOperationOptions { - return GetFunctionAppStacksForLocationOperationOptions{} -} - -func (o GetFunctionAppStacksForLocationOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o GetFunctionAppStacksForLocationOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.StackOsType != nil { - out["stackOsType"] = *o.StackOsType - } - - return out -} - -// GetFunctionAppStacksForLocation ... -func (c ProviderClient) GetFunctionAppStacksForLocation(ctx context.Context, id LocationId, options GetFunctionAppStacksForLocationOperationOptions) (resp GetFunctionAppStacksForLocationOperationResponse, err error) { - req, err := c.preparerForGetFunctionAppStacksForLocation(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "provider.ProviderClient", "GetFunctionAppStacksForLocation", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "provider.ProviderClient", "GetFunctionAppStacksForLocation", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForGetFunctionAppStacksForLocation(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "provider.ProviderClient", "GetFunctionAppStacksForLocation", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForGetFunctionAppStacksForLocation prepares the GetFunctionAppStacksForLocation request. -func (c ProviderClient) preparerForGetFunctionAppStacksForLocation(ctx context.Context, id LocationId, options GetFunctionAppStacksForLocationOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/functionAppStacks", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForGetFunctionAppStacksForLocationWithNextLink prepares the GetFunctionAppStacksForLocation request with the given nextLink token. -func (c ProviderClient) preparerForGetFunctionAppStacksForLocationWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetFunctionAppStacksForLocation handles the response to the GetFunctionAppStacksForLocation request. The method always -// closes the http.Response Body. -func (c ProviderClient) responderForGetFunctionAppStacksForLocation(resp *http.Response) (result GetFunctionAppStacksForLocationOperationResponse, err error) { - type page struct { - Values []FunctionAppStack `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result GetFunctionAppStacksForLocationOperationResponse, err error) { - req, err := c.preparerForGetFunctionAppStacksForLocationWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "provider.ProviderClient", "GetFunctionAppStacksForLocation", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "provider.ProviderClient", "GetFunctionAppStacksForLocation", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetFunctionAppStacksForLocation(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "provider.ProviderClient", "GetFunctionAppStacksForLocation", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// GetFunctionAppStacksForLocationComplete retrieves all of the results into a single object -func (c ProviderClient) GetFunctionAppStacksForLocationComplete(ctx context.Context, id LocationId, options GetFunctionAppStacksForLocationOperationOptions) (GetFunctionAppStacksForLocationCompleteResult, error) { - return c.GetFunctionAppStacksForLocationCompleteMatchingPredicate(ctx, id, options, FunctionAppStackOperationPredicate{}) -} - -// GetFunctionAppStacksForLocationCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ProviderClient) GetFunctionAppStacksForLocationCompleteMatchingPredicate(ctx context.Context, id LocationId, options GetFunctionAppStacksForLocationOperationOptions, predicate FunctionAppStackOperationPredicate) (resp GetFunctionAppStacksForLocationCompleteResult, err error) { - items := make([]FunctionAppStack, 0) - - page, err := c.GetFunctionAppStacksForLocation(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := GetFunctionAppStacksForLocationCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/provider/method_getwebappstacks.go b/resource-manager/web/2022-09-01/provider/method_getwebappstacks.go new file mode 100644 index 00000000000..31f898b9d7e --- /dev/null +++ b/resource-manager/web/2022-09-01/provider/method_getwebappstacks.go @@ -0,0 +1,117 @@ +package provider + +import ( + "context" + "fmt" + "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 GetWebAppStacksOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WebAppStack +} + +type GetWebAppStacksCompleteResult struct { + Items []WebAppStack +} + +type GetWebAppStacksOperationOptions struct { + StackOsType *ProviderStackOsType +} + +func DefaultGetWebAppStacksOperationOptions() GetWebAppStacksOperationOptions { + return GetWebAppStacksOperationOptions{} +} + +func (o GetWebAppStacksOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetWebAppStacksOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o GetWebAppStacksOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.StackOsType != nil { + out.Append("stackOsType", fmt.Sprintf("%v", *o.StackOsType)) + } + return &out +} + +// GetWebAppStacks ... +func (c ProviderClient) GetWebAppStacks(ctx context.Context, options GetWebAppStacksOperationOptions) (result GetWebAppStacksOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: "/providers/Microsoft.Web/webAppStacks", + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]WebAppStack `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetWebAppStacksComplete retrieves all the results into a single object +func (c ProviderClient) GetWebAppStacksComplete(ctx context.Context, options GetWebAppStacksOperationOptions) (GetWebAppStacksCompleteResult, error) { + return c.GetWebAppStacksCompleteMatchingPredicate(ctx, options, WebAppStackOperationPredicate{}) +} + +// GetWebAppStacksCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ProviderClient) GetWebAppStacksCompleteMatchingPredicate(ctx context.Context, options GetWebAppStacksOperationOptions, predicate WebAppStackOperationPredicate) (result GetWebAppStacksCompleteResult, err error) { + items := make([]WebAppStack, 0) + + resp, err := c.GetWebAppStacks(ctx, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetWebAppStacksCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/provider/method_getwebappstacks_autorest.go b/resource-manager/web/2022-09-01/provider/method_getwebappstacks_autorest.go deleted file mode 100644 index e90921bb071..00000000000 --- a/resource-manager/web/2022-09-01/provider/method_getwebappstacks_autorest.go +++ /dev/null @@ -1,215 +0,0 @@ -package provider - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetWebAppStacksOperationResponse struct { - HttpResponse *http.Response - Model *[]WebAppStack - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (GetWebAppStacksOperationResponse, error) -} - -type GetWebAppStacksCompleteResult struct { - Items []WebAppStack -} - -func (r GetWebAppStacksOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r GetWebAppStacksOperationResponse) LoadMore(ctx context.Context) (resp GetWebAppStacksOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type GetWebAppStacksOperationOptions struct { - StackOsType *ProviderStackOsType -} - -func DefaultGetWebAppStacksOperationOptions() GetWebAppStacksOperationOptions { - return GetWebAppStacksOperationOptions{} -} - -func (o GetWebAppStacksOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o GetWebAppStacksOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.StackOsType != nil { - out["stackOsType"] = *o.StackOsType - } - - return out -} - -// GetWebAppStacks ... -func (c ProviderClient) GetWebAppStacks(ctx context.Context, options GetWebAppStacksOperationOptions) (resp GetWebAppStacksOperationResponse, err error) { - req, err := c.preparerForGetWebAppStacks(ctx, options) - if err != nil { - err = autorest.NewErrorWithError(err, "provider.ProviderClient", "GetWebAppStacks", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "provider.ProviderClient", "GetWebAppStacks", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForGetWebAppStacks(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "provider.ProviderClient", "GetWebAppStacks", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForGetWebAppStacks prepares the GetWebAppStacks request. -func (c ProviderClient) preparerForGetWebAppStacks(ctx context.Context, options GetWebAppStacksOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath("/providers/Microsoft.Web/webAppStacks"), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForGetWebAppStacksWithNextLink prepares the GetWebAppStacks request with the given nextLink token. -func (c ProviderClient) preparerForGetWebAppStacksWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetWebAppStacks handles the response to the GetWebAppStacks request. The method always -// closes the http.Response Body. -func (c ProviderClient) responderForGetWebAppStacks(resp *http.Response) (result GetWebAppStacksOperationResponse, err error) { - type page struct { - Values []WebAppStack `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result GetWebAppStacksOperationResponse, err error) { - req, err := c.preparerForGetWebAppStacksWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "provider.ProviderClient", "GetWebAppStacks", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "provider.ProviderClient", "GetWebAppStacks", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetWebAppStacks(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "provider.ProviderClient", "GetWebAppStacks", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// GetWebAppStacksComplete retrieves all of the results into a single object -func (c ProviderClient) GetWebAppStacksComplete(ctx context.Context, options GetWebAppStacksOperationOptions) (GetWebAppStacksCompleteResult, error) { - return c.GetWebAppStacksCompleteMatchingPredicate(ctx, options, WebAppStackOperationPredicate{}) -} - -// GetWebAppStacksCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ProviderClient) GetWebAppStacksCompleteMatchingPredicate(ctx context.Context, options GetWebAppStacksOperationOptions, predicate WebAppStackOperationPredicate) (resp GetWebAppStacksCompleteResult, err error) { - items := make([]WebAppStack, 0) - - page, err := c.GetWebAppStacks(ctx, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := GetWebAppStacksCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/provider/method_getwebappstacksforlocation.go b/resource-manager/web/2022-09-01/provider/method_getwebappstacksforlocation.go new file mode 100644 index 00000000000..91013176445 --- /dev/null +++ b/resource-manager/web/2022-09-01/provider/method_getwebappstacksforlocation.go @@ -0,0 +1,117 @@ +package provider + +import ( + "context" + "fmt" + "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 GetWebAppStacksForLocationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WebAppStack +} + +type GetWebAppStacksForLocationCompleteResult struct { + Items []WebAppStack +} + +type GetWebAppStacksForLocationOperationOptions struct { + StackOsType *ProviderStackOsType +} + +func DefaultGetWebAppStacksForLocationOperationOptions() GetWebAppStacksForLocationOperationOptions { + return GetWebAppStacksForLocationOperationOptions{} +} + +func (o GetWebAppStacksForLocationOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetWebAppStacksForLocationOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o GetWebAppStacksForLocationOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.StackOsType != nil { + out.Append("stackOsType", fmt.Sprintf("%v", *o.StackOsType)) + } + return &out +} + +// GetWebAppStacksForLocation ... +func (c ProviderClient) GetWebAppStacksForLocation(ctx context.Context, id LocationId, options GetWebAppStacksForLocationOperationOptions) (result GetWebAppStacksForLocationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/webAppStacks", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]WebAppStack `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetWebAppStacksForLocationComplete retrieves all the results into a single object +func (c ProviderClient) GetWebAppStacksForLocationComplete(ctx context.Context, id LocationId, options GetWebAppStacksForLocationOperationOptions) (GetWebAppStacksForLocationCompleteResult, error) { + return c.GetWebAppStacksForLocationCompleteMatchingPredicate(ctx, id, options, WebAppStackOperationPredicate{}) +} + +// GetWebAppStacksForLocationCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ProviderClient) GetWebAppStacksForLocationCompleteMatchingPredicate(ctx context.Context, id LocationId, options GetWebAppStacksForLocationOperationOptions, predicate WebAppStackOperationPredicate) (result GetWebAppStacksForLocationCompleteResult, err error) { + items := make([]WebAppStack, 0) + + resp, err := c.GetWebAppStacksForLocation(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetWebAppStacksForLocationCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/provider/method_getwebappstacksforlocation_autorest.go b/resource-manager/web/2022-09-01/provider/method_getwebappstacksforlocation_autorest.go deleted file mode 100644 index d856da22373..00000000000 --- a/resource-manager/web/2022-09-01/provider/method_getwebappstacksforlocation_autorest.go +++ /dev/null @@ -1,215 +0,0 @@ -package provider - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetWebAppStacksForLocationOperationResponse struct { - HttpResponse *http.Response - Model *[]WebAppStack - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (GetWebAppStacksForLocationOperationResponse, error) -} - -type GetWebAppStacksForLocationCompleteResult struct { - Items []WebAppStack -} - -func (r GetWebAppStacksForLocationOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r GetWebAppStacksForLocationOperationResponse) LoadMore(ctx context.Context) (resp GetWebAppStacksForLocationOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type GetWebAppStacksForLocationOperationOptions struct { - StackOsType *ProviderStackOsType -} - -func DefaultGetWebAppStacksForLocationOperationOptions() GetWebAppStacksForLocationOperationOptions { - return GetWebAppStacksForLocationOperationOptions{} -} - -func (o GetWebAppStacksForLocationOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o GetWebAppStacksForLocationOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.StackOsType != nil { - out["stackOsType"] = *o.StackOsType - } - - return out -} - -// GetWebAppStacksForLocation ... -func (c ProviderClient) GetWebAppStacksForLocation(ctx context.Context, id LocationId, options GetWebAppStacksForLocationOperationOptions) (resp GetWebAppStacksForLocationOperationResponse, err error) { - req, err := c.preparerForGetWebAppStacksForLocation(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "provider.ProviderClient", "GetWebAppStacksForLocation", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "provider.ProviderClient", "GetWebAppStacksForLocation", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForGetWebAppStacksForLocation(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "provider.ProviderClient", "GetWebAppStacksForLocation", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForGetWebAppStacksForLocation prepares the GetWebAppStacksForLocation request. -func (c ProviderClient) preparerForGetWebAppStacksForLocation(ctx context.Context, id LocationId, options GetWebAppStacksForLocationOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/webAppStacks", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForGetWebAppStacksForLocationWithNextLink prepares the GetWebAppStacksForLocation request with the given nextLink token. -func (c ProviderClient) preparerForGetWebAppStacksForLocationWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetWebAppStacksForLocation handles the response to the GetWebAppStacksForLocation request. The method always -// closes the http.Response Body. -func (c ProviderClient) responderForGetWebAppStacksForLocation(resp *http.Response) (result GetWebAppStacksForLocationOperationResponse, err error) { - type page struct { - Values []WebAppStack `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result GetWebAppStacksForLocationOperationResponse, err error) { - req, err := c.preparerForGetWebAppStacksForLocationWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "provider.ProviderClient", "GetWebAppStacksForLocation", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "provider.ProviderClient", "GetWebAppStacksForLocation", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetWebAppStacksForLocation(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "provider.ProviderClient", "GetWebAppStacksForLocation", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// GetWebAppStacksForLocationComplete retrieves all of the results into a single object -func (c ProviderClient) GetWebAppStacksForLocationComplete(ctx context.Context, id LocationId, options GetWebAppStacksForLocationOperationOptions) (GetWebAppStacksForLocationCompleteResult, error) { - return c.GetWebAppStacksForLocationCompleteMatchingPredicate(ctx, id, options, WebAppStackOperationPredicate{}) -} - -// GetWebAppStacksForLocationCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ProviderClient) GetWebAppStacksForLocationCompleteMatchingPredicate(ctx context.Context, id LocationId, options GetWebAppStacksForLocationOperationOptions, predicate WebAppStackOperationPredicate) (resp GetWebAppStacksForLocationCompleteResult, err error) { - items := make([]WebAppStack, 0) - - page, err := c.GetWebAppStacksForLocation(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := GetWebAppStacksForLocationCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/recommendations/client.go b/resource-manager/web/2022-09-01/recommendations/client.go index 1950db6b664..7195d64b891 100644 --- a/resource-manager/web/2022-09-01/recommendations/client.go +++ b/resource-manager/web/2022-09-01/recommendations/client.go @@ -1,18 +1,26 @@ package recommendations -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 RecommendationsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewRecommendationsClientWithBaseURI(endpoint string) RecommendationsClient { - return RecommendationsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewRecommendationsClientWithBaseURI(api environments.Api) (*RecommendationsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "recommendations", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating RecommendationsClient: %+v", err) } + + return &RecommendationsClient{ + Client: client, + }, nil } diff --git a/resource-manager/web/2022-09-01/recommendations/constants.go b/resource-manager/web/2022-09-01/recommendations/constants.go index 26bfc54cab8..207c2a4c8a5 100644 --- a/resource-manager/web/2022-09-01/recommendations/constants.go +++ b/resource-manager/web/2022-09-01/recommendations/constants.go @@ -1,6 +1,10 @@ package recommendations -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. @@ -25,6 +29,19 @@ func PossibleValuesForChannels() []string { } } +func (s *Channels) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseChannels(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseChannels(input string) (*Channels, error) { vals := map[string]Channels{ "all": ChannelsAll, @@ -60,6 +77,19 @@ func PossibleValuesForNotificationLevel() []string { } } +func (s *NotificationLevel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNotificationLevel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseNotificationLevel(input string) (*NotificationLevel, error) { vals := map[string]NotificationLevel{ "critical": NotificationLevelCritical, @@ -92,6 +122,19 @@ func PossibleValuesForResourceScopeType() []string { } } +func (s *ResourceScopeType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResourceScopeType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseResourceScopeType(input string) (*ResourceScopeType, error) { vals := map[string]ResourceScopeType{ "serverfarm": ResourceScopeTypeServerFarm, diff --git a/resource-manager/web/2022-09-01/recommendations/method_disableallforhostingenvironment.go b/resource-manager/web/2022-09-01/recommendations/method_disableallforhostingenvironment.go new file mode 100644 index 00000000000..74dea9b9dc3 --- /dev/null +++ b/resource-manager/web/2022-09-01/recommendations/method_disableallforhostingenvironment.go @@ -0,0 +1,75 @@ +package recommendations + +import ( + "context" + "fmt" + "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 DisableAllForHostingEnvironmentOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DisableAllForHostingEnvironmentOperationOptions struct { + EnvironmentName *string +} + +func DefaultDisableAllForHostingEnvironmentOperationOptions() DisableAllForHostingEnvironmentOperationOptions { + return DisableAllForHostingEnvironmentOperationOptions{} +} + +func (o DisableAllForHostingEnvironmentOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DisableAllForHostingEnvironmentOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DisableAllForHostingEnvironmentOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.EnvironmentName != nil { + out.Append("environmentName", fmt.Sprintf("%v", *o.EnvironmentName)) + } + return &out +} + +// DisableAllForHostingEnvironment ... +func (c RecommendationsClient) DisableAllForHostingEnvironment(ctx context.Context, id HostingEnvironmentId, options DisableAllForHostingEnvironmentOperationOptions) (result DisableAllForHostingEnvironmentOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/recommendations/disable", id.ID()), + OptionsObject: options, + } + + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/recommendations/method_disableallforhostingenvironment_autorest.go b/resource-manager/web/2022-09-01/recommendations/method_disableallforhostingenvironment_autorest.go deleted file mode 100644 index 68f558b5f46..00000000000 --- a/resource-manager/web/2022-09-01/recommendations/method_disableallforhostingenvironment_autorest.go +++ /dev/null @@ -1,96 +0,0 @@ -package recommendations - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DisableAllForHostingEnvironmentOperationResponse struct { - HttpResponse *http.Response -} - -type DisableAllForHostingEnvironmentOperationOptions struct { - EnvironmentName *string -} - -func DefaultDisableAllForHostingEnvironmentOperationOptions() DisableAllForHostingEnvironmentOperationOptions { - return DisableAllForHostingEnvironmentOperationOptions{} -} - -func (o DisableAllForHostingEnvironmentOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o DisableAllForHostingEnvironmentOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.EnvironmentName != nil { - out["environmentName"] = *o.EnvironmentName - } - - return out -} - -// DisableAllForHostingEnvironment ... -func (c RecommendationsClient) DisableAllForHostingEnvironment(ctx context.Context, id HostingEnvironmentId, options DisableAllForHostingEnvironmentOperationOptions) (result DisableAllForHostingEnvironmentOperationResponse, err error) { - req, err := c.preparerForDisableAllForHostingEnvironment(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "DisableAllForHostingEnvironment", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "DisableAllForHostingEnvironment", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDisableAllForHostingEnvironment(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "DisableAllForHostingEnvironment", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDisableAllForHostingEnvironment prepares the DisableAllForHostingEnvironment request. -func (c RecommendationsClient) preparerForDisableAllForHostingEnvironment(ctx context.Context, id HostingEnvironmentId, options DisableAllForHostingEnvironmentOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/recommendations/disable", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDisableAllForHostingEnvironment handles the response to the DisableAllForHostingEnvironment request. The method always -// closes the http.Response Body. -func (c RecommendationsClient) responderForDisableAllForHostingEnvironment(resp *http.Response) (result DisableAllForHostingEnvironmentOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/recommendations/method_disableallforwebapp.go b/resource-manager/web/2022-09-01/recommendations/method_disableallforwebapp.go new file mode 100644 index 00000000000..fc5f14b5063 --- /dev/null +++ b/resource-manager/web/2022-09-01/recommendations/method_disableallforwebapp.go @@ -0,0 +1,47 @@ +package recommendations + +import ( + "context" + "fmt" + "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 DisableAllForWebAppOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DisableAllForWebApp ... +func (c RecommendationsClient) DisableAllForWebApp(ctx context.Context, id SiteId) (result DisableAllForWebAppOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/recommendations/disable", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/recommendations/method_disableallforwebapp_autorest.go b/resource-manager/web/2022-09-01/recommendations/method_disableallforwebapp_autorest.go deleted file mode 100644 index a58b1db2e4b..00000000000 --- a/resource-manager/web/2022-09-01/recommendations/method_disableallforwebapp_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package recommendations - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DisableAllForWebAppOperationResponse struct { - HttpResponse *http.Response -} - -// DisableAllForWebApp ... -func (c RecommendationsClient) DisableAllForWebApp(ctx context.Context, id SiteId) (result DisableAllForWebAppOperationResponse, err error) { - req, err := c.preparerForDisableAllForWebApp(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "DisableAllForWebApp", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "DisableAllForWebApp", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDisableAllForWebApp(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "DisableAllForWebApp", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDisableAllForWebApp prepares the DisableAllForWebApp request. -func (c RecommendationsClient) preparerForDisableAllForWebApp(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/recommendations/disable", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDisableAllForWebApp handles the response to the DisableAllForWebApp request. The method always -// closes the http.Response Body. -func (c RecommendationsClient) responderForDisableAllForWebApp(resp *http.Response) (result DisableAllForWebAppOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/recommendations/method_disablerecommendationforhostingenvironment.go b/resource-manager/web/2022-09-01/recommendations/method_disablerecommendationforhostingenvironment.go new file mode 100644 index 00000000000..cd6467f971b --- /dev/null +++ b/resource-manager/web/2022-09-01/recommendations/method_disablerecommendationforhostingenvironment.go @@ -0,0 +1,75 @@ +package recommendations + +import ( + "context" + "fmt" + "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 DisableRecommendationForHostingEnvironmentOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DisableRecommendationForHostingEnvironmentOperationOptions struct { + EnvironmentName *string +} + +func DefaultDisableRecommendationForHostingEnvironmentOperationOptions() DisableRecommendationForHostingEnvironmentOperationOptions { + return DisableRecommendationForHostingEnvironmentOperationOptions{} +} + +func (o DisableRecommendationForHostingEnvironmentOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DisableRecommendationForHostingEnvironmentOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DisableRecommendationForHostingEnvironmentOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.EnvironmentName != nil { + out.Append("environmentName", fmt.Sprintf("%v", *o.EnvironmentName)) + } + return &out +} + +// DisableRecommendationForHostingEnvironment ... +func (c RecommendationsClient) DisableRecommendationForHostingEnvironment(ctx context.Context, id HostingEnvironmentRecommendationId, options DisableRecommendationForHostingEnvironmentOperationOptions) (result DisableRecommendationForHostingEnvironmentOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/disable", id.ID()), + OptionsObject: options, + } + + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/recommendations/method_disablerecommendationforhostingenvironment_autorest.go b/resource-manager/web/2022-09-01/recommendations/method_disablerecommendationforhostingenvironment_autorest.go deleted file mode 100644 index cd31ad316d0..00000000000 --- a/resource-manager/web/2022-09-01/recommendations/method_disablerecommendationforhostingenvironment_autorest.go +++ /dev/null @@ -1,96 +0,0 @@ -package recommendations - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DisableRecommendationForHostingEnvironmentOperationResponse struct { - HttpResponse *http.Response -} - -type DisableRecommendationForHostingEnvironmentOperationOptions struct { - EnvironmentName *string -} - -func DefaultDisableRecommendationForHostingEnvironmentOperationOptions() DisableRecommendationForHostingEnvironmentOperationOptions { - return DisableRecommendationForHostingEnvironmentOperationOptions{} -} - -func (o DisableRecommendationForHostingEnvironmentOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o DisableRecommendationForHostingEnvironmentOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.EnvironmentName != nil { - out["environmentName"] = *o.EnvironmentName - } - - return out -} - -// DisableRecommendationForHostingEnvironment ... -func (c RecommendationsClient) DisableRecommendationForHostingEnvironment(ctx context.Context, id HostingEnvironmentRecommendationId, options DisableRecommendationForHostingEnvironmentOperationOptions) (result DisableRecommendationForHostingEnvironmentOperationResponse, err error) { - req, err := c.preparerForDisableRecommendationForHostingEnvironment(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "DisableRecommendationForHostingEnvironment", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "DisableRecommendationForHostingEnvironment", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDisableRecommendationForHostingEnvironment(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "DisableRecommendationForHostingEnvironment", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDisableRecommendationForHostingEnvironment prepares the DisableRecommendationForHostingEnvironment request. -func (c RecommendationsClient) preparerForDisableRecommendationForHostingEnvironment(ctx context.Context, id HostingEnvironmentRecommendationId, options DisableRecommendationForHostingEnvironmentOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/disable", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDisableRecommendationForHostingEnvironment handles the response to the DisableRecommendationForHostingEnvironment request. The method always -// closes the http.Response Body. -func (c RecommendationsClient) responderForDisableRecommendationForHostingEnvironment(resp *http.Response) (result DisableRecommendationForHostingEnvironmentOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/recommendations/method_disablerecommendationforsite.go b/resource-manager/web/2022-09-01/recommendations/method_disablerecommendationforsite.go new file mode 100644 index 00000000000..503dbd8dce8 --- /dev/null +++ b/resource-manager/web/2022-09-01/recommendations/method_disablerecommendationforsite.go @@ -0,0 +1,47 @@ +package recommendations + +import ( + "context" + "fmt" + "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 DisableRecommendationForSiteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DisableRecommendationForSite ... +func (c RecommendationsClient) DisableRecommendationForSite(ctx context.Context, id SiteRecommendationId) (result DisableRecommendationForSiteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/disable", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/recommendations/method_disablerecommendationforsite_autorest.go b/resource-manager/web/2022-09-01/recommendations/method_disablerecommendationforsite_autorest.go deleted file mode 100644 index baa32582782..00000000000 --- a/resource-manager/web/2022-09-01/recommendations/method_disablerecommendationforsite_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package recommendations - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DisableRecommendationForSiteOperationResponse struct { - HttpResponse *http.Response -} - -// DisableRecommendationForSite ... -func (c RecommendationsClient) DisableRecommendationForSite(ctx context.Context, id SiteRecommendationId) (result DisableRecommendationForSiteOperationResponse, err error) { - req, err := c.preparerForDisableRecommendationForSite(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "DisableRecommendationForSite", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "DisableRecommendationForSite", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDisableRecommendationForSite(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "DisableRecommendationForSite", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDisableRecommendationForSite prepares the DisableRecommendationForSite request. -func (c RecommendationsClient) preparerForDisableRecommendationForSite(ctx context.Context, id SiteRecommendationId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/disable", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDisableRecommendationForSite handles the response to the DisableRecommendationForSite request. The method always -// closes the http.Response Body. -func (c RecommendationsClient) responderForDisableRecommendationForSite(resp *http.Response) (result DisableRecommendationForSiteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/recommendations/method_disablerecommendationforsubscription.go b/resource-manager/web/2022-09-01/recommendations/method_disablerecommendationforsubscription.go new file mode 100644 index 00000000000..668dbc492be --- /dev/null +++ b/resource-manager/web/2022-09-01/recommendations/method_disablerecommendationforsubscription.go @@ -0,0 +1,47 @@ +package recommendations + +import ( + "context" + "fmt" + "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 DisableRecommendationForSubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DisableRecommendationForSubscription ... +func (c RecommendationsClient) DisableRecommendationForSubscription(ctx context.Context, id RecommendationId) (result DisableRecommendationForSubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/disable", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/recommendations/method_disablerecommendationforsubscription_autorest.go b/resource-manager/web/2022-09-01/recommendations/method_disablerecommendationforsubscription_autorest.go deleted file mode 100644 index a8a4c4c4fe6..00000000000 --- a/resource-manager/web/2022-09-01/recommendations/method_disablerecommendationforsubscription_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package recommendations - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DisableRecommendationForSubscriptionOperationResponse struct { - HttpResponse *http.Response -} - -// DisableRecommendationForSubscription ... -func (c RecommendationsClient) DisableRecommendationForSubscription(ctx context.Context, id RecommendationId) (result DisableRecommendationForSubscriptionOperationResponse, err error) { - req, err := c.preparerForDisableRecommendationForSubscription(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "DisableRecommendationForSubscription", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "DisableRecommendationForSubscription", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDisableRecommendationForSubscription(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "DisableRecommendationForSubscription", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDisableRecommendationForSubscription prepares the DisableRecommendationForSubscription request. -func (c RecommendationsClient) preparerForDisableRecommendationForSubscription(ctx context.Context, id RecommendationId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/disable", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDisableRecommendationForSubscription handles the response to the DisableRecommendationForSubscription request. The method always -// closes the http.Response Body. -func (c RecommendationsClient) responderForDisableRecommendationForSubscription(resp *http.Response) (result DisableRecommendationForSubscriptionOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/recommendations/method_getruledetailsbyhostingenvironment.go b/resource-manager/web/2022-09-01/recommendations/method_getruledetailsbyhostingenvironment.go new file mode 100644 index 00000000000..b64812d098b --- /dev/null +++ b/resource-manager/web/2022-09-01/recommendations/method_getruledetailsbyhostingenvironment.go @@ -0,0 +1,84 @@ +package recommendations + +import ( + "context" + "fmt" + "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 GetRuleDetailsByHostingEnvironmentOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RecommendationRule +} + +type GetRuleDetailsByHostingEnvironmentOperationOptions struct { + RecommendationId *string + UpdateSeen *bool +} + +func DefaultGetRuleDetailsByHostingEnvironmentOperationOptions() GetRuleDetailsByHostingEnvironmentOperationOptions { + return GetRuleDetailsByHostingEnvironmentOperationOptions{} +} + +func (o GetRuleDetailsByHostingEnvironmentOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetRuleDetailsByHostingEnvironmentOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o GetRuleDetailsByHostingEnvironmentOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.RecommendationId != nil { + out.Append("recommendationId", fmt.Sprintf("%v", *o.RecommendationId)) + } + if o.UpdateSeen != nil { + out.Append("updateSeen", fmt.Sprintf("%v", *o.UpdateSeen)) + } + return &out +} + +// GetRuleDetailsByHostingEnvironment ... +func (c RecommendationsClient) GetRuleDetailsByHostingEnvironment(ctx context.Context, id HostingEnvironmentRecommendationId, options GetRuleDetailsByHostingEnvironmentOperationOptions) (result GetRuleDetailsByHostingEnvironmentOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + OptionsObject: options, + } + + 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 +} diff --git a/resource-manager/web/2022-09-01/recommendations/method_getruledetailsbyhostingenvironment_autorest.go b/resource-manager/web/2022-09-01/recommendations/method_getruledetailsbyhostingenvironment_autorest.go deleted file mode 100644 index ee3556e4717..00000000000 --- a/resource-manager/web/2022-09-01/recommendations/method_getruledetailsbyhostingenvironment_autorest.go +++ /dev/null @@ -1,102 +0,0 @@ -package recommendations - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetRuleDetailsByHostingEnvironmentOperationResponse struct { - HttpResponse *http.Response - Model *RecommendationRule -} - -type GetRuleDetailsByHostingEnvironmentOperationOptions struct { - RecommendationId *string - UpdateSeen *bool -} - -func DefaultGetRuleDetailsByHostingEnvironmentOperationOptions() GetRuleDetailsByHostingEnvironmentOperationOptions { - return GetRuleDetailsByHostingEnvironmentOperationOptions{} -} - -func (o GetRuleDetailsByHostingEnvironmentOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o GetRuleDetailsByHostingEnvironmentOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.RecommendationId != nil { - out["recommendationId"] = *o.RecommendationId - } - - if o.UpdateSeen != nil { - out["updateSeen"] = *o.UpdateSeen - } - - return out -} - -// GetRuleDetailsByHostingEnvironment ... -func (c RecommendationsClient) GetRuleDetailsByHostingEnvironment(ctx context.Context, id HostingEnvironmentRecommendationId, options GetRuleDetailsByHostingEnvironmentOperationOptions) (result GetRuleDetailsByHostingEnvironmentOperationResponse, err error) { - req, err := c.preparerForGetRuleDetailsByHostingEnvironment(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "GetRuleDetailsByHostingEnvironment", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "GetRuleDetailsByHostingEnvironment", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetRuleDetailsByHostingEnvironment(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "GetRuleDetailsByHostingEnvironment", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetRuleDetailsByHostingEnvironment prepares the GetRuleDetailsByHostingEnvironment request. -func (c RecommendationsClient) preparerForGetRuleDetailsByHostingEnvironment(ctx context.Context, id HostingEnvironmentRecommendationId, options GetRuleDetailsByHostingEnvironmentOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetRuleDetailsByHostingEnvironment handles the response to the GetRuleDetailsByHostingEnvironment request. The method always -// closes the http.Response Body. -func (c RecommendationsClient) responderForGetRuleDetailsByHostingEnvironment(resp *http.Response) (result GetRuleDetailsByHostingEnvironmentOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/recommendations/method_getruledetailsbywebapp.go b/resource-manager/web/2022-09-01/recommendations/method_getruledetailsbywebapp.go new file mode 100644 index 00000000000..d7bff1f897d --- /dev/null +++ b/resource-manager/web/2022-09-01/recommendations/method_getruledetailsbywebapp.go @@ -0,0 +1,84 @@ +package recommendations + +import ( + "context" + "fmt" + "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 GetRuleDetailsByWebAppOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RecommendationRule +} + +type GetRuleDetailsByWebAppOperationOptions struct { + RecommendationId *string + UpdateSeen *bool +} + +func DefaultGetRuleDetailsByWebAppOperationOptions() GetRuleDetailsByWebAppOperationOptions { + return GetRuleDetailsByWebAppOperationOptions{} +} + +func (o GetRuleDetailsByWebAppOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetRuleDetailsByWebAppOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o GetRuleDetailsByWebAppOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.RecommendationId != nil { + out.Append("recommendationId", fmt.Sprintf("%v", *o.RecommendationId)) + } + if o.UpdateSeen != nil { + out.Append("updateSeen", fmt.Sprintf("%v", *o.UpdateSeen)) + } + return &out +} + +// GetRuleDetailsByWebApp ... +func (c RecommendationsClient) GetRuleDetailsByWebApp(ctx context.Context, id SiteRecommendationId, options GetRuleDetailsByWebAppOperationOptions) (result GetRuleDetailsByWebAppOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + OptionsObject: options, + } + + 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 +} diff --git a/resource-manager/web/2022-09-01/recommendations/method_getruledetailsbywebapp_autorest.go b/resource-manager/web/2022-09-01/recommendations/method_getruledetailsbywebapp_autorest.go deleted file mode 100644 index a60047d5b64..00000000000 --- a/resource-manager/web/2022-09-01/recommendations/method_getruledetailsbywebapp_autorest.go +++ /dev/null @@ -1,102 +0,0 @@ -package recommendations - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetRuleDetailsByWebAppOperationResponse struct { - HttpResponse *http.Response - Model *RecommendationRule -} - -type GetRuleDetailsByWebAppOperationOptions struct { - RecommendationId *string - UpdateSeen *bool -} - -func DefaultGetRuleDetailsByWebAppOperationOptions() GetRuleDetailsByWebAppOperationOptions { - return GetRuleDetailsByWebAppOperationOptions{} -} - -func (o GetRuleDetailsByWebAppOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o GetRuleDetailsByWebAppOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.RecommendationId != nil { - out["recommendationId"] = *o.RecommendationId - } - - if o.UpdateSeen != nil { - out["updateSeen"] = *o.UpdateSeen - } - - return out -} - -// GetRuleDetailsByWebApp ... -func (c RecommendationsClient) GetRuleDetailsByWebApp(ctx context.Context, id SiteRecommendationId, options GetRuleDetailsByWebAppOperationOptions) (result GetRuleDetailsByWebAppOperationResponse, err error) { - req, err := c.preparerForGetRuleDetailsByWebApp(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "GetRuleDetailsByWebApp", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "GetRuleDetailsByWebApp", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetRuleDetailsByWebApp(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "GetRuleDetailsByWebApp", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetRuleDetailsByWebApp prepares the GetRuleDetailsByWebApp request. -func (c RecommendationsClient) preparerForGetRuleDetailsByWebApp(ctx context.Context, id SiteRecommendationId, options GetRuleDetailsByWebAppOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetRuleDetailsByWebApp handles the response to the GetRuleDetailsByWebApp request. The method always -// closes the http.Response Body. -func (c RecommendationsClient) responderForGetRuleDetailsByWebApp(resp *http.Response) (result GetRuleDetailsByWebAppOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/recommendations/method_list.go b/resource-manager/web/2022-09-01/recommendations/method_list.go new file mode 100644 index 00000000000..4c8811006ab --- /dev/null +++ b/resource-manager/web/2022-09-01/recommendations/method_list.go @@ -0,0 +1,122 @@ +package recommendations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Recommendation +} + +type ListCompleteResult struct { + Items []Recommendation +} + +type ListOperationOptions struct { + Featured *bool + Filter *string +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Featured != nil { + out.Append("featured", fmt.Sprintf("%v", *o.Featured)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +// List ... +func (c RecommendationsClient) List(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/recommendations", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Recommendation `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c RecommendationsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, RecommendationOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RecommendationsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions, predicate RecommendationOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Recommendation, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/recommendations/method_list_autorest.go b/resource-manager/web/2022-09-01/recommendations/method_list_autorest.go deleted file mode 100644 index 3dfba0ef6ef..00000000000 --- a/resource-manager/web/2022-09-01/recommendations/method_list_autorest.go +++ /dev/null @@ -1,221 +0,0 @@ -package recommendations - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListOperationResponse struct { - HttpResponse *http.Response - Model *[]Recommendation - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []Recommendation -} - -func (r ListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListOperationOptions struct { - Featured *bool - Filter *string -} - -func DefaultListOperationOptions() ListOperationOptions { - return ListOperationOptions{} -} - -func (o ListOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Featured != nil { - out["featured"] = *o.Featured - } - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - return out -} - -// List ... -func (c RecommendationsClient) List(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c RecommendationsClient) preparerForList(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Web/recommendations", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c RecommendationsClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForList handles the response to the List request. The method always -// closes the http.Response Body. -func (c RecommendationsClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []Recommendation `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { - req, err := c.preparerForListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c RecommendationsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, options, RecommendationOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c RecommendationsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions, predicate RecommendationOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]Recommendation, 0) - - page, err := c.List(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/recommendations/method_listhistoryforhostingenvironment.go b/resource-manager/web/2022-09-01/recommendations/method_listhistoryforhostingenvironment.go new file mode 100644 index 00000000000..5d19413d5fc --- /dev/null +++ b/resource-manager/web/2022-09-01/recommendations/method_listhistoryforhostingenvironment.go @@ -0,0 +1,121 @@ +package recommendations + +import ( + "context" + "fmt" + "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 ListHistoryForHostingEnvironmentOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Recommendation +} + +type ListHistoryForHostingEnvironmentCompleteResult struct { + Items []Recommendation +} + +type ListHistoryForHostingEnvironmentOperationOptions struct { + ExpiredOnly *bool + Filter *string +} + +func DefaultListHistoryForHostingEnvironmentOperationOptions() ListHistoryForHostingEnvironmentOperationOptions { + return ListHistoryForHostingEnvironmentOperationOptions{} +} + +func (o ListHistoryForHostingEnvironmentOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListHistoryForHostingEnvironmentOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListHistoryForHostingEnvironmentOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.ExpiredOnly != nil { + out.Append("expiredOnly", fmt.Sprintf("%v", *o.ExpiredOnly)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +// ListHistoryForHostingEnvironment ... +func (c RecommendationsClient) ListHistoryForHostingEnvironment(ctx context.Context, id HostingEnvironmentId, options ListHistoryForHostingEnvironmentOperationOptions) (result ListHistoryForHostingEnvironmentOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/recommendationHistory", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Recommendation `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListHistoryForHostingEnvironmentComplete retrieves all the results into a single object +func (c RecommendationsClient) ListHistoryForHostingEnvironmentComplete(ctx context.Context, id HostingEnvironmentId, options ListHistoryForHostingEnvironmentOperationOptions) (ListHistoryForHostingEnvironmentCompleteResult, error) { + return c.ListHistoryForHostingEnvironmentCompleteMatchingPredicate(ctx, id, options, RecommendationOperationPredicate{}) +} + +// ListHistoryForHostingEnvironmentCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RecommendationsClient) ListHistoryForHostingEnvironmentCompleteMatchingPredicate(ctx context.Context, id HostingEnvironmentId, options ListHistoryForHostingEnvironmentOperationOptions, predicate RecommendationOperationPredicate) (result ListHistoryForHostingEnvironmentCompleteResult, err error) { + items := make([]Recommendation, 0) + + resp, err := c.ListHistoryForHostingEnvironment(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListHistoryForHostingEnvironmentCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/recommendations/method_listhistoryforhostingenvironment_autorest.go b/resource-manager/web/2022-09-01/recommendations/method_listhistoryforhostingenvironment_autorest.go deleted file mode 100644 index 18f9fece2b5..00000000000 --- a/resource-manager/web/2022-09-01/recommendations/method_listhistoryforhostingenvironment_autorest.go +++ /dev/null @@ -1,220 +0,0 @@ -package recommendations - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListHistoryForHostingEnvironmentOperationResponse struct { - HttpResponse *http.Response - Model *[]Recommendation - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListHistoryForHostingEnvironmentOperationResponse, error) -} - -type ListHistoryForHostingEnvironmentCompleteResult struct { - Items []Recommendation -} - -func (r ListHistoryForHostingEnvironmentOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListHistoryForHostingEnvironmentOperationResponse) LoadMore(ctx context.Context) (resp ListHistoryForHostingEnvironmentOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListHistoryForHostingEnvironmentOperationOptions struct { - ExpiredOnly *bool - Filter *string -} - -func DefaultListHistoryForHostingEnvironmentOperationOptions() ListHistoryForHostingEnvironmentOperationOptions { - return ListHistoryForHostingEnvironmentOperationOptions{} -} - -func (o ListHistoryForHostingEnvironmentOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListHistoryForHostingEnvironmentOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.ExpiredOnly != nil { - out["expiredOnly"] = *o.ExpiredOnly - } - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - return out -} - -// ListHistoryForHostingEnvironment ... -func (c RecommendationsClient) ListHistoryForHostingEnvironment(ctx context.Context, id HostingEnvironmentId, options ListHistoryForHostingEnvironmentOperationOptions) (resp ListHistoryForHostingEnvironmentOperationResponse, err error) { - req, err := c.preparerForListHistoryForHostingEnvironment(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "ListHistoryForHostingEnvironment", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "ListHistoryForHostingEnvironment", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListHistoryForHostingEnvironment(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "ListHistoryForHostingEnvironment", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListHistoryForHostingEnvironment prepares the ListHistoryForHostingEnvironment request. -func (c RecommendationsClient) preparerForListHistoryForHostingEnvironment(ctx context.Context, id HostingEnvironmentId, options ListHistoryForHostingEnvironmentOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/recommendationHistory", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListHistoryForHostingEnvironmentWithNextLink prepares the ListHistoryForHostingEnvironment request with the given nextLink token. -func (c RecommendationsClient) preparerForListHistoryForHostingEnvironmentWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListHistoryForHostingEnvironment handles the response to the ListHistoryForHostingEnvironment request. The method always -// closes the http.Response Body. -func (c RecommendationsClient) responderForListHistoryForHostingEnvironment(resp *http.Response) (result ListHistoryForHostingEnvironmentOperationResponse, err error) { - type page struct { - Values []Recommendation `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListHistoryForHostingEnvironmentOperationResponse, err error) { - req, err := c.preparerForListHistoryForHostingEnvironmentWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "ListHistoryForHostingEnvironment", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "ListHistoryForHostingEnvironment", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListHistoryForHostingEnvironment(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "ListHistoryForHostingEnvironment", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListHistoryForHostingEnvironmentComplete retrieves all of the results into a single object -func (c RecommendationsClient) ListHistoryForHostingEnvironmentComplete(ctx context.Context, id HostingEnvironmentId, options ListHistoryForHostingEnvironmentOperationOptions) (ListHistoryForHostingEnvironmentCompleteResult, error) { - return c.ListHistoryForHostingEnvironmentCompleteMatchingPredicate(ctx, id, options, RecommendationOperationPredicate{}) -} - -// ListHistoryForHostingEnvironmentCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c RecommendationsClient) ListHistoryForHostingEnvironmentCompleteMatchingPredicate(ctx context.Context, id HostingEnvironmentId, options ListHistoryForHostingEnvironmentOperationOptions, predicate RecommendationOperationPredicate) (resp ListHistoryForHostingEnvironmentCompleteResult, err error) { - items := make([]Recommendation, 0) - - page, err := c.ListHistoryForHostingEnvironment(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListHistoryForHostingEnvironmentCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/recommendations/method_listhistoryforwebapp.go b/resource-manager/web/2022-09-01/recommendations/method_listhistoryforwebapp.go new file mode 100644 index 00000000000..af129416c5d --- /dev/null +++ b/resource-manager/web/2022-09-01/recommendations/method_listhistoryforwebapp.go @@ -0,0 +1,121 @@ +package recommendations + +import ( + "context" + "fmt" + "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 ListHistoryForWebAppOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Recommendation +} + +type ListHistoryForWebAppCompleteResult struct { + Items []Recommendation +} + +type ListHistoryForWebAppOperationOptions struct { + ExpiredOnly *bool + Filter *string +} + +func DefaultListHistoryForWebAppOperationOptions() ListHistoryForWebAppOperationOptions { + return ListHistoryForWebAppOperationOptions{} +} + +func (o ListHistoryForWebAppOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListHistoryForWebAppOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListHistoryForWebAppOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.ExpiredOnly != nil { + out.Append("expiredOnly", fmt.Sprintf("%v", *o.ExpiredOnly)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +// ListHistoryForWebApp ... +func (c RecommendationsClient) ListHistoryForWebApp(ctx context.Context, id SiteId, options ListHistoryForWebAppOperationOptions) (result ListHistoryForWebAppOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/recommendationHistory", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Recommendation `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListHistoryForWebAppComplete retrieves all the results into a single object +func (c RecommendationsClient) ListHistoryForWebAppComplete(ctx context.Context, id SiteId, options ListHistoryForWebAppOperationOptions) (ListHistoryForWebAppCompleteResult, error) { + return c.ListHistoryForWebAppCompleteMatchingPredicate(ctx, id, options, RecommendationOperationPredicate{}) +} + +// ListHistoryForWebAppCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RecommendationsClient) ListHistoryForWebAppCompleteMatchingPredicate(ctx context.Context, id SiteId, options ListHistoryForWebAppOperationOptions, predicate RecommendationOperationPredicate) (result ListHistoryForWebAppCompleteResult, err error) { + items := make([]Recommendation, 0) + + resp, err := c.ListHistoryForWebApp(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListHistoryForWebAppCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/recommendations/method_listhistoryforwebapp_autorest.go b/resource-manager/web/2022-09-01/recommendations/method_listhistoryforwebapp_autorest.go deleted file mode 100644 index 6203059fabc..00000000000 --- a/resource-manager/web/2022-09-01/recommendations/method_listhistoryforwebapp_autorest.go +++ /dev/null @@ -1,220 +0,0 @@ -package recommendations - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListHistoryForWebAppOperationResponse struct { - HttpResponse *http.Response - Model *[]Recommendation - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListHistoryForWebAppOperationResponse, error) -} - -type ListHistoryForWebAppCompleteResult struct { - Items []Recommendation -} - -func (r ListHistoryForWebAppOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListHistoryForWebAppOperationResponse) LoadMore(ctx context.Context) (resp ListHistoryForWebAppOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListHistoryForWebAppOperationOptions struct { - ExpiredOnly *bool - Filter *string -} - -func DefaultListHistoryForWebAppOperationOptions() ListHistoryForWebAppOperationOptions { - return ListHistoryForWebAppOperationOptions{} -} - -func (o ListHistoryForWebAppOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListHistoryForWebAppOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.ExpiredOnly != nil { - out["expiredOnly"] = *o.ExpiredOnly - } - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - return out -} - -// ListHistoryForWebApp ... -func (c RecommendationsClient) ListHistoryForWebApp(ctx context.Context, id SiteId, options ListHistoryForWebAppOperationOptions) (resp ListHistoryForWebAppOperationResponse, err error) { - req, err := c.preparerForListHistoryForWebApp(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "ListHistoryForWebApp", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "ListHistoryForWebApp", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListHistoryForWebApp(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "ListHistoryForWebApp", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListHistoryForWebApp prepares the ListHistoryForWebApp request. -func (c RecommendationsClient) preparerForListHistoryForWebApp(ctx context.Context, id SiteId, options ListHistoryForWebAppOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/recommendationHistory", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListHistoryForWebAppWithNextLink prepares the ListHistoryForWebApp request with the given nextLink token. -func (c RecommendationsClient) preparerForListHistoryForWebAppWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListHistoryForWebApp handles the response to the ListHistoryForWebApp request. The method always -// closes the http.Response Body. -func (c RecommendationsClient) responderForListHistoryForWebApp(resp *http.Response) (result ListHistoryForWebAppOperationResponse, err error) { - type page struct { - Values []Recommendation `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListHistoryForWebAppOperationResponse, err error) { - req, err := c.preparerForListHistoryForWebAppWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "ListHistoryForWebApp", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "ListHistoryForWebApp", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListHistoryForWebApp(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "ListHistoryForWebApp", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListHistoryForWebAppComplete retrieves all of the results into a single object -func (c RecommendationsClient) ListHistoryForWebAppComplete(ctx context.Context, id SiteId, options ListHistoryForWebAppOperationOptions) (ListHistoryForWebAppCompleteResult, error) { - return c.ListHistoryForWebAppCompleteMatchingPredicate(ctx, id, options, RecommendationOperationPredicate{}) -} - -// ListHistoryForWebAppCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c RecommendationsClient) ListHistoryForWebAppCompleteMatchingPredicate(ctx context.Context, id SiteId, options ListHistoryForWebAppOperationOptions, predicate RecommendationOperationPredicate) (resp ListHistoryForWebAppCompleteResult, err error) { - items := make([]Recommendation, 0) - - page, err := c.ListHistoryForWebApp(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListHistoryForWebAppCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/recommendations/method_listrecommendedrulesforhostingenvironment.go b/resource-manager/web/2022-09-01/recommendations/method_listrecommendedrulesforhostingenvironment.go new file mode 100644 index 00000000000..1bc921339c7 --- /dev/null +++ b/resource-manager/web/2022-09-01/recommendations/method_listrecommendedrulesforhostingenvironment.go @@ -0,0 +1,121 @@ +package recommendations + +import ( + "context" + "fmt" + "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 ListRecommendedRulesForHostingEnvironmentOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Recommendation +} + +type ListRecommendedRulesForHostingEnvironmentCompleteResult struct { + Items []Recommendation +} + +type ListRecommendedRulesForHostingEnvironmentOperationOptions struct { + Featured *bool + Filter *string +} + +func DefaultListRecommendedRulesForHostingEnvironmentOperationOptions() ListRecommendedRulesForHostingEnvironmentOperationOptions { + return ListRecommendedRulesForHostingEnvironmentOperationOptions{} +} + +func (o ListRecommendedRulesForHostingEnvironmentOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListRecommendedRulesForHostingEnvironmentOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListRecommendedRulesForHostingEnvironmentOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Featured != nil { + out.Append("featured", fmt.Sprintf("%v", *o.Featured)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +// ListRecommendedRulesForHostingEnvironment ... +func (c RecommendationsClient) ListRecommendedRulesForHostingEnvironment(ctx context.Context, id HostingEnvironmentId, options ListRecommendedRulesForHostingEnvironmentOperationOptions) (result ListRecommendedRulesForHostingEnvironmentOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/recommendations", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Recommendation `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListRecommendedRulesForHostingEnvironmentComplete retrieves all the results into a single object +func (c RecommendationsClient) ListRecommendedRulesForHostingEnvironmentComplete(ctx context.Context, id HostingEnvironmentId, options ListRecommendedRulesForHostingEnvironmentOperationOptions) (ListRecommendedRulesForHostingEnvironmentCompleteResult, error) { + return c.ListRecommendedRulesForHostingEnvironmentCompleteMatchingPredicate(ctx, id, options, RecommendationOperationPredicate{}) +} + +// ListRecommendedRulesForHostingEnvironmentCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RecommendationsClient) ListRecommendedRulesForHostingEnvironmentCompleteMatchingPredicate(ctx context.Context, id HostingEnvironmentId, options ListRecommendedRulesForHostingEnvironmentOperationOptions, predicate RecommendationOperationPredicate) (result ListRecommendedRulesForHostingEnvironmentCompleteResult, err error) { + items := make([]Recommendation, 0) + + resp, err := c.ListRecommendedRulesForHostingEnvironment(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListRecommendedRulesForHostingEnvironmentCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/recommendations/method_listrecommendedrulesforhostingenvironment_autorest.go b/resource-manager/web/2022-09-01/recommendations/method_listrecommendedrulesforhostingenvironment_autorest.go deleted file mode 100644 index 030206542a9..00000000000 --- a/resource-manager/web/2022-09-01/recommendations/method_listrecommendedrulesforhostingenvironment_autorest.go +++ /dev/null @@ -1,220 +0,0 @@ -package recommendations - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListRecommendedRulesForHostingEnvironmentOperationResponse struct { - HttpResponse *http.Response - Model *[]Recommendation - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListRecommendedRulesForHostingEnvironmentOperationResponse, error) -} - -type ListRecommendedRulesForHostingEnvironmentCompleteResult struct { - Items []Recommendation -} - -func (r ListRecommendedRulesForHostingEnvironmentOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListRecommendedRulesForHostingEnvironmentOperationResponse) LoadMore(ctx context.Context) (resp ListRecommendedRulesForHostingEnvironmentOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListRecommendedRulesForHostingEnvironmentOperationOptions struct { - Featured *bool - Filter *string -} - -func DefaultListRecommendedRulesForHostingEnvironmentOperationOptions() ListRecommendedRulesForHostingEnvironmentOperationOptions { - return ListRecommendedRulesForHostingEnvironmentOperationOptions{} -} - -func (o ListRecommendedRulesForHostingEnvironmentOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListRecommendedRulesForHostingEnvironmentOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Featured != nil { - out["featured"] = *o.Featured - } - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - return out -} - -// ListRecommendedRulesForHostingEnvironment ... -func (c RecommendationsClient) ListRecommendedRulesForHostingEnvironment(ctx context.Context, id HostingEnvironmentId, options ListRecommendedRulesForHostingEnvironmentOperationOptions) (resp ListRecommendedRulesForHostingEnvironmentOperationResponse, err error) { - req, err := c.preparerForListRecommendedRulesForHostingEnvironment(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "ListRecommendedRulesForHostingEnvironment", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "ListRecommendedRulesForHostingEnvironment", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListRecommendedRulesForHostingEnvironment(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "ListRecommendedRulesForHostingEnvironment", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListRecommendedRulesForHostingEnvironment prepares the ListRecommendedRulesForHostingEnvironment request. -func (c RecommendationsClient) preparerForListRecommendedRulesForHostingEnvironment(ctx context.Context, id HostingEnvironmentId, options ListRecommendedRulesForHostingEnvironmentOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/recommendations", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListRecommendedRulesForHostingEnvironmentWithNextLink prepares the ListRecommendedRulesForHostingEnvironment request with the given nextLink token. -func (c RecommendationsClient) preparerForListRecommendedRulesForHostingEnvironmentWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListRecommendedRulesForHostingEnvironment handles the response to the ListRecommendedRulesForHostingEnvironment request. The method always -// closes the http.Response Body. -func (c RecommendationsClient) responderForListRecommendedRulesForHostingEnvironment(resp *http.Response) (result ListRecommendedRulesForHostingEnvironmentOperationResponse, err error) { - type page struct { - Values []Recommendation `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListRecommendedRulesForHostingEnvironmentOperationResponse, err error) { - req, err := c.preparerForListRecommendedRulesForHostingEnvironmentWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "ListRecommendedRulesForHostingEnvironment", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "ListRecommendedRulesForHostingEnvironment", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListRecommendedRulesForHostingEnvironment(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "ListRecommendedRulesForHostingEnvironment", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListRecommendedRulesForHostingEnvironmentComplete retrieves all of the results into a single object -func (c RecommendationsClient) ListRecommendedRulesForHostingEnvironmentComplete(ctx context.Context, id HostingEnvironmentId, options ListRecommendedRulesForHostingEnvironmentOperationOptions) (ListRecommendedRulesForHostingEnvironmentCompleteResult, error) { - return c.ListRecommendedRulesForHostingEnvironmentCompleteMatchingPredicate(ctx, id, options, RecommendationOperationPredicate{}) -} - -// ListRecommendedRulesForHostingEnvironmentCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c RecommendationsClient) ListRecommendedRulesForHostingEnvironmentCompleteMatchingPredicate(ctx context.Context, id HostingEnvironmentId, options ListRecommendedRulesForHostingEnvironmentOperationOptions, predicate RecommendationOperationPredicate) (resp ListRecommendedRulesForHostingEnvironmentCompleteResult, err error) { - items := make([]Recommendation, 0) - - page, err := c.ListRecommendedRulesForHostingEnvironment(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListRecommendedRulesForHostingEnvironmentCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/recommendations/method_listrecommendedrulesforwebapp.go b/resource-manager/web/2022-09-01/recommendations/method_listrecommendedrulesforwebapp.go new file mode 100644 index 00000000000..ab66901344f --- /dev/null +++ b/resource-manager/web/2022-09-01/recommendations/method_listrecommendedrulesforwebapp.go @@ -0,0 +1,121 @@ +package recommendations + +import ( + "context" + "fmt" + "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 ListRecommendedRulesForWebAppOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Recommendation +} + +type ListRecommendedRulesForWebAppCompleteResult struct { + Items []Recommendation +} + +type ListRecommendedRulesForWebAppOperationOptions struct { + Featured *bool + Filter *string +} + +func DefaultListRecommendedRulesForWebAppOperationOptions() ListRecommendedRulesForWebAppOperationOptions { + return ListRecommendedRulesForWebAppOperationOptions{} +} + +func (o ListRecommendedRulesForWebAppOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListRecommendedRulesForWebAppOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListRecommendedRulesForWebAppOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Featured != nil { + out.Append("featured", fmt.Sprintf("%v", *o.Featured)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +// ListRecommendedRulesForWebApp ... +func (c RecommendationsClient) ListRecommendedRulesForWebApp(ctx context.Context, id SiteId, options ListRecommendedRulesForWebAppOperationOptions) (result ListRecommendedRulesForWebAppOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/recommendations", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Recommendation `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListRecommendedRulesForWebAppComplete retrieves all the results into a single object +func (c RecommendationsClient) ListRecommendedRulesForWebAppComplete(ctx context.Context, id SiteId, options ListRecommendedRulesForWebAppOperationOptions) (ListRecommendedRulesForWebAppCompleteResult, error) { + return c.ListRecommendedRulesForWebAppCompleteMatchingPredicate(ctx, id, options, RecommendationOperationPredicate{}) +} + +// ListRecommendedRulesForWebAppCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RecommendationsClient) ListRecommendedRulesForWebAppCompleteMatchingPredicate(ctx context.Context, id SiteId, options ListRecommendedRulesForWebAppOperationOptions, predicate RecommendationOperationPredicate) (result ListRecommendedRulesForWebAppCompleteResult, err error) { + items := make([]Recommendation, 0) + + resp, err := c.ListRecommendedRulesForWebApp(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListRecommendedRulesForWebAppCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/recommendations/method_listrecommendedrulesforwebapp_autorest.go b/resource-manager/web/2022-09-01/recommendations/method_listrecommendedrulesforwebapp_autorest.go deleted file mode 100644 index 2de3a056149..00000000000 --- a/resource-manager/web/2022-09-01/recommendations/method_listrecommendedrulesforwebapp_autorest.go +++ /dev/null @@ -1,220 +0,0 @@ -package recommendations - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListRecommendedRulesForWebAppOperationResponse struct { - HttpResponse *http.Response - Model *[]Recommendation - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListRecommendedRulesForWebAppOperationResponse, error) -} - -type ListRecommendedRulesForWebAppCompleteResult struct { - Items []Recommendation -} - -func (r ListRecommendedRulesForWebAppOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListRecommendedRulesForWebAppOperationResponse) LoadMore(ctx context.Context) (resp ListRecommendedRulesForWebAppOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListRecommendedRulesForWebAppOperationOptions struct { - Featured *bool - Filter *string -} - -func DefaultListRecommendedRulesForWebAppOperationOptions() ListRecommendedRulesForWebAppOperationOptions { - return ListRecommendedRulesForWebAppOperationOptions{} -} - -func (o ListRecommendedRulesForWebAppOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListRecommendedRulesForWebAppOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Featured != nil { - out["featured"] = *o.Featured - } - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - return out -} - -// ListRecommendedRulesForWebApp ... -func (c RecommendationsClient) ListRecommendedRulesForWebApp(ctx context.Context, id SiteId, options ListRecommendedRulesForWebAppOperationOptions) (resp ListRecommendedRulesForWebAppOperationResponse, err error) { - req, err := c.preparerForListRecommendedRulesForWebApp(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "ListRecommendedRulesForWebApp", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "ListRecommendedRulesForWebApp", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListRecommendedRulesForWebApp(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "ListRecommendedRulesForWebApp", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListRecommendedRulesForWebApp prepares the ListRecommendedRulesForWebApp request. -func (c RecommendationsClient) preparerForListRecommendedRulesForWebApp(ctx context.Context, id SiteId, options ListRecommendedRulesForWebAppOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/recommendations", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListRecommendedRulesForWebAppWithNextLink prepares the ListRecommendedRulesForWebApp request with the given nextLink token. -func (c RecommendationsClient) preparerForListRecommendedRulesForWebAppWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListRecommendedRulesForWebApp handles the response to the ListRecommendedRulesForWebApp request. The method always -// closes the http.Response Body. -func (c RecommendationsClient) responderForListRecommendedRulesForWebApp(resp *http.Response) (result ListRecommendedRulesForWebAppOperationResponse, err error) { - type page struct { - Values []Recommendation `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListRecommendedRulesForWebAppOperationResponse, err error) { - req, err := c.preparerForListRecommendedRulesForWebAppWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "ListRecommendedRulesForWebApp", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "ListRecommendedRulesForWebApp", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListRecommendedRulesForWebApp(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "ListRecommendedRulesForWebApp", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListRecommendedRulesForWebAppComplete retrieves all of the results into a single object -func (c RecommendationsClient) ListRecommendedRulesForWebAppComplete(ctx context.Context, id SiteId, options ListRecommendedRulesForWebAppOperationOptions) (ListRecommendedRulesForWebAppCompleteResult, error) { - return c.ListRecommendedRulesForWebAppCompleteMatchingPredicate(ctx, id, options, RecommendationOperationPredicate{}) -} - -// ListRecommendedRulesForWebAppCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c RecommendationsClient) ListRecommendedRulesForWebAppCompleteMatchingPredicate(ctx context.Context, id SiteId, options ListRecommendedRulesForWebAppOperationOptions, predicate RecommendationOperationPredicate) (resp ListRecommendedRulesForWebAppCompleteResult, err error) { - items := make([]Recommendation, 0) - - page, err := c.ListRecommendedRulesForWebApp(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListRecommendedRulesForWebAppCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/recommendations/method_resetallfilters.go b/resource-manager/web/2022-09-01/recommendations/method_resetallfilters.go new file mode 100644 index 00000000000..7eeb282a732 --- /dev/null +++ b/resource-manager/web/2022-09-01/recommendations/method_resetallfilters.go @@ -0,0 +1,48 @@ +package recommendations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ResetAllFiltersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ResetAllFilters ... +func (c RecommendationsClient) ResetAllFilters(ctx context.Context, id commonids.SubscriptionId) (result ResetAllFiltersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/recommendations/reset", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/recommendations/method_resetallfilters_autorest.go b/resource-manager/web/2022-09-01/recommendations/method_resetallfilters_autorest.go deleted file mode 100644 index 339628b4b2b..00000000000 --- a/resource-manager/web/2022-09-01/recommendations/method_resetallfilters_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package recommendations - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ResetAllFiltersOperationResponse struct { - HttpResponse *http.Response -} - -// ResetAllFilters ... -func (c RecommendationsClient) ResetAllFilters(ctx context.Context, id commonids.SubscriptionId) (result ResetAllFiltersOperationResponse, err error) { - req, err := c.preparerForResetAllFilters(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "ResetAllFilters", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "ResetAllFilters", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForResetAllFilters(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "ResetAllFilters", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForResetAllFilters prepares the ResetAllFilters request. -func (c RecommendationsClient) preparerForResetAllFilters(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Web/recommendations/reset", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForResetAllFilters handles the response to the ResetAllFilters request. The method always -// closes the http.Response Body. -func (c RecommendationsClient) responderForResetAllFilters(resp *http.Response) (result ResetAllFiltersOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/recommendations/method_resetallfiltersforhostingenvironment.go b/resource-manager/web/2022-09-01/recommendations/method_resetallfiltersforhostingenvironment.go new file mode 100644 index 00000000000..458930015bb --- /dev/null +++ b/resource-manager/web/2022-09-01/recommendations/method_resetallfiltersforhostingenvironment.go @@ -0,0 +1,75 @@ +package recommendations + +import ( + "context" + "fmt" + "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 ResetAllFiltersForHostingEnvironmentOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type ResetAllFiltersForHostingEnvironmentOperationOptions struct { + EnvironmentName *string +} + +func DefaultResetAllFiltersForHostingEnvironmentOperationOptions() ResetAllFiltersForHostingEnvironmentOperationOptions { + return ResetAllFiltersForHostingEnvironmentOperationOptions{} +} + +func (o ResetAllFiltersForHostingEnvironmentOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ResetAllFiltersForHostingEnvironmentOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ResetAllFiltersForHostingEnvironmentOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.EnvironmentName != nil { + out.Append("environmentName", fmt.Sprintf("%v", *o.EnvironmentName)) + } + return &out +} + +// ResetAllFiltersForHostingEnvironment ... +func (c RecommendationsClient) ResetAllFiltersForHostingEnvironment(ctx context.Context, id HostingEnvironmentId, options ResetAllFiltersForHostingEnvironmentOperationOptions) (result ResetAllFiltersForHostingEnvironmentOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/recommendations/reset", id.ID()), + OptionsObject: options, + } + + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/recommendations/method_resetallfiltersforhostingenvironment_autorest.go b/resource-manager/web/2022-09-01/recommendations/method_resetallfiltersforhostingenvironment_autorest.go deleted file mode 100644 index 4c9a65b878a..00000000000 --- a/resource-manager/web/2022-09-01/recommendations/method_resetallfiltersforhostingenvironment_autorest.go +++ /dev/null @@ -1,96 +0,0 @@ -package recommendations - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ResetAllFiltersForHostingEnvironmentOperationResponse struct { - HttpResponse *http.Response -} - -type ResetAllFiltersForHostingEnvironmentOperationOptions struct { - EnvironmentName *string -} - -func DefaultResetAllFiltersForHostingEnvironmentOperationOptions() ResetAllFiltersForHostingEnvironmentOperationOptions { - return ResetAllFiltersForHostingEnvironmentOperationOptions{} -} - -func (o ResetAllFiltersForHostingEnvironmentOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ResetAllFiltersForHostingEnvironmentOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.EnvironmentName != nil { - out["environmentName"] = *o.EnvironmentName - } - - return out -} - -// ResetAllFiltersForHostingEnvironment ... -func (c RecommendationsClient) ResetAllFiltersForHostingEnvironment(ctx context.Context, id HostingEnvironmentId, options ResetAllFiltersForHostingEnvironmentOperationOptions) (result ResetAllFiltersForHostingEnvironmentOperationResponse, err error) { - req, err := c.preparerForResetAllFiltersForHostingEnvironment(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "ResetAllFiltersForHostingEnvironment", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "ResetAllFiltersForHostingEnvironment", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForResetAllFiltersForHostingEnvironment(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "ResetAllFiltersForHostingEnvironment", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForResetAllFiltersForHostingEnvironment prepares the ResetAllFiltersForHostingEnvironment request. -func (c RecommendationsClient) preparerForResetAllFiltersForHostingEnvironment(ctx context.Context, id HostingEnvironmentId, options ResetAllFiltersForHostingEnvironmentOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/recommendations/reset", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForResetAllFiltersForHostingEnvironment handles the response to the ResetAllFiltersForHostingEnvironment request. The method always -// closes the http.Response Body. -func (c RecommendationsClient) responderForResetAllFiltersForHostingEnvironment(resp *http.Response) (result ResetAllFiltersForHostingEnvironmentOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/recommendations/method_resetallfiltersforwebapp.go b/resource-manager/web/2022-09-01/recommendations/method_resetallfiltersforwebapp.go new file mode 100644 index 00000000000..12466aec1d6 --- /dev/null +++ b/resource-manager/web/2022-09-01/recommendations/method_resetallfiltersforwebapp.go @@ -0,0 +1,47 @@ +package recommendations + +import ( + "context" + "fmt" + "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 ResetAllFiltersForWebAppOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ResetAllFiltersForWebApp ... +func (c RecommendationsClient) ResetAllFiltersForWebApp(ctx context.Context, id SiteId) (result ResetAllFiltersForWebAppOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/recommendations/reset", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/recommendations/method_resetallfiltersforwebapp_autorest.go b/resource-manager/web/2022-09-01/recommendations/method_resetallfiltersforwebapp_autorest.go deleted file mode 100644 index 5fc69f36f0e..00000000000 --- a/resource-manager/web/2022-09-01/recommendations/method_resetallfiltersforwebapp_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package recommendations - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ResetAllFiltersForWebAppOperationResponse struct { - HttpResponse *http.Response -} - -// ResetAllFiltersForWebApp ... -func (c RecommendationsClient) ResetAllFiltersForWebApp(ctx context.Context, id SiteId) (result ResetAllFiltersForWebAppOperationResponse, err error) { - req, err := c.preparerForResetAllFiltersForWebApp(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "ResetAllFiltersForWebApp", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "ResetAllFiltersForWebApp", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForResetAllFiltersForWebApp(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "recommendations.RecommendationsClient", "ResetAllFiltersForWebApp", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForResetAllFiltersForWebApp prepares the ResetAllFiltersForWebApp request. -func (c RecommendationsClient) preparerForResetAllFiltersForWebApp(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/recommendations/reset", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForResetAllFiltersForWebApp handles the response to the ResetAllFiltersForWebApp request. The method always -// closes the http.Response Body. -func (c RecommendationsClient) responderForResetAllFiltersForWebApp(resp *http.Response) (result ResetAllFiltersForWebAppOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/resourcehealthmetadata/client.go b/resource-manager/web/2022-09-01/resourcehealthmetadata/client.go index 09e7e1f299d..5fe8598fab7 100644 --- a/resource-manager/web/2022-09-01/resourcehealthmetadata/client.go +++ b/resource-manager/web/2022-09-01/resourcehealthmetadata/client.go @@ -1,18 +1,26 @@ package resourcehealthmetadata -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 ResourceHealthMetadataClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewResourceHealthMetadataClientWithBaseURI(endpoint string) ResourceHealthMetadataClient { - return ResourceHealthMetadataClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewResourceHealthMetadataClientWithBaseURI(api environments.Api) (*ResourceHealthMetadataClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "resourcehealthmetadata", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ResourceHealthMetadataClient: %+v", err) } + + return &ResourceHealthMetadataClient{ + Client: client, + }, nil } diff --git a/resource-manager/web/2022-09-01/resourcehealthmetadata/method_getbysite.go b/resource-manager/web/2022-09-01/resourcehealthmetadata/method_getbysite.go new file mode 100644 index 00000000000..9de8b471185 --- /dev/null +++ b/resource-manager/web/2022-09-01/resourcehealthmetadata/method_getbysite.go @@ -0,0 +1,52 @@ +package resourcehealthmetadata + +import ( + "context" + "fmt" + "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 GetBySiteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ResourceHealthMetadata +} + +// GetBySite ... +func (c ResourceHealthMetadataClient) GetBySite(ctx context.Context, id SiteId) (result GetBySiteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/resourceHealthMetadata/default", 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 +} diff --git a/resource-manager/web/2022-09-01/resourcehealthmetadata/method_getbysite_autorest.go b/resource-manager/web/2022-09-01/resourcehealthmetadata/method_getbysite_autorest.go deleted file mode 100644 index aee54f5030c..00000000000 --- a/resource-manager/web/2022-09-01/resourcehealthmetadata/method_getbysite_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package resourcehealthmetadata - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetBySiteOperationResponse struct { - HttpResponse *http.Response - Model *ResourceHealthMetadata -} - -// GetBySite ... -func (c ResourceHealthMetadataClient) GetBySite(ctx context.Context, id SiteId) (result GetBySiteOperationResponse, err error) { - req, err := c.preparerForGetBySite(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "resourcehealthmetadata.ResourceHealthMetadataClient", "GetBySite", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "resourcehealthmetadata.ResourceHealthMetadataClient", "GetBySite", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetBySite(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "resourcehealthmetadata.ResourceHealthMetadataClient", "GetBySite", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetBySite prepares the GetBySite request. -func (c ResourceHealthMetadataClient) preparerForGetBySite(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/resourceHealthMetadata/default", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetBySite handles the response to the GetBySite request. The method always -// closes the http.Response Body. -func (c ResourceHealthMetadataClient) responderForGetBySite(resp *http.Response) (result GetBySiteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/resourcehealthmetadata/method_getbysiteslot.go b/resource-manager/web/2022-09-01/resourcehealthmetadata/method_getbysiteslot.go new file mode 100644 index 00000000000..8e9f0d78f90 --- /dev/null +++ b/resource-manager/web/2022-09-01/resourcehealthmetadata/method_getbysiteslot.go @@ -0,0 +1,52 @@ +package resourcehealthmetadata + +import ( + "context" + "fmt" + "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 GetBySiteSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ResourceHealthMetadata +} + +// GetBySiteSlot ... +func (c ResourceHealthMetadataClient) GetBySiteSlot(ctx context.Context, id SlotId) (result GetBySiteSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/resourceHealthMetadata/default", 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 +} diff --git a/resource-manager/web/2022-09-01/resourcehealthmetadata/method_getbysiteslot_autorest.go b/resource-manager/web/2022-09-01/resourcehealthmetadata/method_getbysiteslot_autorest.go deleted file mode 100644 index 4b931492a0a..00000000000 --- a/resource-manager/web/2022-09-01/resourcehealthmetadata/method_getbysiteslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package resourcehealthmetadata - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetBySiteSlotOperationResponse struct { - HttpResponse *http.Response - Model *ResourceHealthMetadata -} - -// GetBySiteSlot ... -func (c ResourceHealthMetadataClient) GetBySiteSlot(ctx context.Context, id SlotId) (result GetBySiteSlotOperationResponse, err error) { - req, err := c.preparerForGetBySiteSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "resourcehealthmetadata.ResourceHealthMetadataClient", "GetBySiteSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "resourcehealthmetadata.ResourceHealthMetadataClient", "GetBySiteSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetBySiteSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "resourcehealthmetadata.ResourceHealthMetadataClient", "GetBySiteSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetBySiteSlot prepares the GetBySiteSlot request. -func (c ResourceHealthMetadataClient) preparerForGetBySiteSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/resourceHealthMetadata/default", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetBySiteSlot handles the response to the GetBySiteSlot request. The method always -// closes the http.Response Body. -func (c ResourceHealthMetadataClient) responderForGetBySiteSlot(resp *http.Response) (result GetBySiteSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/resourcehealthmetadata/method_list.go b/resource-manager/web/2022-09-01/resourcehealthmetadata/method_list.go new file mode 100644 index 00000000000..d7815ed2590 --- /dev/null +++ b/resource-manager/web/2022-09-01/resourcehealthmetadata/method_list.go @@ -0,0 +1,90 @@ +package resourcehealthmetadata + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ResourceHealthMetadata +} + +type ListCompleteResult struct { + Items []ResourceHealthMetadata +} + +// List ... +func (c ResourceHealthMetadataClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/resourceHealthMetadata", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ResourceHealthMetadata `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ResourceHealthMetadataClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, ResourceHealthMetadataOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceHealthMetadataClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ResourceHealthMetadataOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ResourceHealthMetadata, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/resourcehealthmetadata/method_list_autorest.go b/resource-manager/web/2022-09-01/resourcehealthmetadata/method_list_autorest.go deleted file mode 100644 index a0f1042468b..00000000000 --- a/resource-manager/web/2022-09-01/resourcehealthmetadata/method_list_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package resourcehealthmetadata - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListOperationResponse struct { - HttpResponse *http.Response - Model *[]ResourceHealthMetadata - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []ResourceHealthMetadata -} - -func (r ListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// List ... -func (c ResourceHealthMetadataClient) List(ctx context.Context, id commonids.SubscriptionId) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "resourcehealthmetadata.ResourceHealthMetadataClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "resourcehealthmetadata.ResourceHealthMetadataClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "resourcehealthmetadata.ResourceHealthMetadataClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c ResourceHealthMetadataClient) preparerForList(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Web/resourceHealthMetadata", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c ResourceHealthMetadataClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForList handles the response to the List request. The method always -// closes the http.Response Body. -func (c ResourceHealthMetadataClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []ResourceHealthMetadata `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { - req, err := c.preparerForListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "resourcehealthmetadata.ResourceHealthMetadataClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "resourcehealthmetadata.ResourceHealthMetadataClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "resourcehealthmetadata.ResourceHealthMetadataClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c ResourceHealthMetadataClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, ResourceHealthMetadataOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ResourceHealthMetadataClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ResourceHealthMetadataOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]ResourceHealthMetadata, 0) - - page, err := c.List(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/resourcehealthmetadata/method_listbyresourcegroup.go b/resource-manager/web/2022-09-01/resourcehealthmetadata/method_listbyresourcegroup.go new file mode 100644 index 00000000000..9d19b309d53 --- /dev/null +++ b/resource-manager/web/2022-09-01/resourcehealthmetadata/method_listbyresourcegroup.go @@ -0,0 +1,90 @@ +package resourcehealthmetadata + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ResourceHealthMetadata +} + +type ListByResourceGroupCompleteResult struct { + Items []ResourceHealthMetadata +} + +// ListByResourceGroup ... +func (c ResourceHealthMetadataClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/resourceHealthMetadata", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ResourceHealthMetadata `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c ResourceHealthMetadataClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, ResourceHealthMetadataOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceHealthMetadataClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ResourceHealthMetadataOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]ResourceHealthMetadata, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/resourcehealthmetadata/method_listbyresourcegroup_autorest.go b/resource-manager/web/2022-09-01/resourcehealthmetadata/method_listbyresourcegroup_autorest.go deleted file mode 100644 index 536c332b517..00000000000 --- a/resource-manager/web/2022-09-01/resourcehealthmetadata/method_listbyresourcegroup_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package resourcehealthmetadata - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByResourceGroupOperationResponse struct { - HttpResponse *http.Response - Model *[]ResourceHealthMetadata - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByResourceGroupOperationResponse, error) -} - -type ListByResourceGroupCompleteResult struct { - Items []ResourceHealthMetadata -} - -func (r ListByResourceGroupOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByResourceGroupOperationResponse) LoadMore(ctx context.Context) (resp ListByResourceGroupOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListByResourceGroup ... -func (c ResourceHealthMetadataClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (resp ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroup(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "resourcehealthmetadata.ResourceHealthMetadataClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "resourcehealthmetadata.ResourceHealthMetadataClient", "ListByResourceGroup", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByResourceGroup(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "resourcehealthmetadata.ResourceHealthMetadataClient", "ListByResourceGroup", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByResourceGroup prepares the ListByResourceGroup request. -func (c ResourceHealthMetadataClient) preparerForListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Web/resourceHealthMetadata", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByResourceGroupWithNextLink prepares the ListByResourceGroup request with the given nextLink token. -func (c ResourceHealthMetadataClient) preparerForListByResourceGroupWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByResourceGroup handles the response to the ListByResourceGroup request. The method always -// closes the http.Response Body. -func (c ResourceHealthMetadataClient) responderForListByResourceGroup(resp *http.Response) (result ListByResourceGroupOperationResponse, err error) { - type page struct { - Values []ResourceHealthMetadata `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroupWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "resourcehealthmetadata.ResourceHealthMetadataClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "resourcehealthmetadata.ResourceHealthMetadataClient", "ListByResourceGroup", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByResourceGroup(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "resourcehealthmetadata.ResourceHealthMetadataClient", "ListByResourceGroup", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByResourceGroupComplete retrieves all of the results into a single object -func (c ResourceHealthMetadataClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { - return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, ResourceHealthMetadataOperationPredicate{}) -} - -// ListByResourceGroupCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ResourceHealthMetadataClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ResourceHealthMetadataOperationPredicate) (resp ListByResourceGroupCompleteResult, err error) { - items := make([]ResourceHealthMetadata, 0) - - page, err := c.ListByResourceGroup(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByResourceGroupCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/resourcehealthmetadata/method_listbysite.go b/resource-manager/web/2022-09-01/resourcehealthmetadata/method_listbysite.go new file mode 100644 index 00000000000..2fe75b1ad34 --- /dev/null +++ b/resource-manager/web/2022-09-01/resourcehealthmetadata/method_listbysite.go @@ -0,0 +1,89 @@ +package resourcehealthmetadata + +import ( + "context" + "fmt" + "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 ListBySiteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ResourceHealthMetadata +} + +type ListBySiteCompleteResult struct { + Items []ResourceHealthMetadata +} + +// ListBySite ... +func (c ResourceHealthMetadataClient) ListBySite(ctx context.Context, id SiteId) (result ListBySiteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/resourceHealthMetadata", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ResourceHealthMetadata `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySiteComplete retrieves all the results into a single object +func (c ResourceHealthMetadataClient) ListBySiteComplete(ctx context.Context, id SiteId) (ListBySiteCompleteResult, error) { + return c.ListBySiteCompleteMatchingPredicate(ctx, id, ResourceHealthMetadataOperationPredicate{}) +} + +// ListBySiteCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceHealthMetadataClient) ListBySiteCompleteMatchingPredicate(ctx context.Context, id SiteId, predicate ResourceHealthMetadataOperationPredicate) (result ListBySiteCompleteResult, err error) { + items := make([]ResourceHealthMetadata, 0) + + resp, err := c.ListBySite(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListBySiteCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/resourcehealthmetadata/method_listbysite_autorest.go b/resource-manager/web/2022-09-01/resourcehealthmetadata/method_listbysite_autorest.go deleted file mode 100644 index 594c28dad79..00000000000 --- a/resource-manager/web/2022-09-01/resourcehealthmetadata/method_listbysite_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package resourcehealthmetadata - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListBySiteOperationResponse struct { - HttpResponse *http.Response - Model *[]ResourceHealthMetadata - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListBySiteOperationResponse, error) -} - -type ListBySiteCompleteResult struct { - Items []ResourceHealthMetadata -} - -func (r ListBySiteOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListBySiteOperationResponse) LoadMore(ctx context.Context) (resp ListBySiteOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListBySite ... -func (c ResourceHealthMetadataClient) ListBySite(ctx context.Context, id SiteId) (resp ListBySiteOperationResponse, err error) { - req, err := c.preparerForListBySite(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "resourcehealthmetadata.ResourceHealthMetadataClient", "ListBySite", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "resourcehealthmetadata.ResourceHealthMetadataClient", "ListBySite", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListBySite(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "resourcehealthmetadata.ResourceHealthMetadataClient", "ListBySite", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListBySite prepares the ListBySite request. -func (c ResourceHealthMetadataClient) preparerForListBySite(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/resourceHealthMetadata", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListBySiteWithNextLink prepares the ListBySite request with the given nextLink token. -func (c ResourceHealthMetadataClient) preparerForListBySiteWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListBySite handles the response to the ListBySite request. The method always -// closes the http.Response Body. -func (c ResourceHealthMetadataClient) responderForListBySite(resp *http.Response) (result ListBySiteOperationResponse, err error) { - type page struct { - Values []ResourceHealthMetadata `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListBySiteOperationResponse, err error) { - req, err := c.preparerForListBySiteWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "resourcehealthmetadata.ResourceHealthMetadataClient", "ListBySite", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "resourcehealthmetadata.ResourceHealthMetadataClient", "ListBySite", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListBySite(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "resourcehealthmetadata.ResourceHealthMetadataClient", "ListBySite", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListBySiteComplete retrieves all of the results into a single object -func (c ResourceHealthMetadataClient) ListBySiteComplete(ctx context.Context, id SiteId) (ListBySiteCompleteResult, error) { - return c.ListBySiteCompleteMatchingPredicate(ctx, id, ResourceHealthMetadataOperationPredicate{}) -} - -// ListBySiteCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ResourceHealthMetadataClient) ListBySiteCompleteMatchingPredicate(ctx context.Context, id SiteId, predicate ResourceHealthMetadataOperationPredicate) (resp ListBySiteCompleteResult, err error) { - items := make([]ResourceHealthMetadata, 0) - - page, err := c.ListBySite(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListBySiteCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/resourcehealthmetadata/method_listbysiteslot.go b/resource-manager/web/2022-09-01/resourcehealthmetadata/method_listbysiteslot.go new file mode 100644 index 00000000000..ec90687967e --- /dev/null +++ b/resource-manager/web/2022-09-01/resourcehealthmetadata/method_listbysiteslot.go @@ -0,0 +1,89 @@ +package resourcehealthmetadata + +import ( + "context" + "fmt" + "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 ListBySiteSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ResourceHealthMetadata +} + +type ListBySiteSlotCompleteResult struct { + Items []ResourceHealthMetadata +} + +// ListBySiteSlot ... +func (c ResourceHealthMetadataClient) ListBySiteSlot(ctx context.Context, id SlotId) (result ListBySiteSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/resourceHealthMetadata", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ResourceHealthMetadata `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySiteSlotComplete retrieves all the results into a single object +func (c ResourceHealthMetadataClient) ListBySiteSlotComplete(ctx context.Context, id SlotId) (ListBySiteSlotCompleteResult, error) { + return c.ListBySiteSlotCompleteMatchingPredicate(ctx, id, ResourceHealthMetadataOperationPredicate{}) +} + +// ListBySiteSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceHealthMetadataClient) ListBySiteSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate ResourceHealthMetadataOperationPredicate) (result ListBySiteSlotCompleteResult, err error) { + items := make([]ResourceHealthMetadata, 0) + + resp, err := c.ListBySiteSlot(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListBySiteSlotCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/resourcehealthmetadata/method_listbysiteslot_autorest.go b/resource-manager/web/2022-09-01/resourcehealthmetadata/method_listbysiteslot_autorest.go deleted file mode 100644 index 3db15794dc5..00000000000 --- a/resource-manager/web/2022-09-01/resourcehealthmetadata/method_listbysiteslot_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package resourcehealthmetadata - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListBySiteSlotOperationResponse struct { - HttpResponse *http.Response - Model *[]ResourceHealthMetadata - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListBySiteSlotOperationResponse, error) -} - -type ListBySiteSlotCompleteResult struct { - Items []ResourceHealthMetadata -} - -func (r ListBySiteSlotOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListBySiteSlotOperationResponse) LoadMore(ctx context.Context) (resp ListBySiteSlotOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListBySiteSlot ... -func (c ResourceHealthMetadataClient) ListBySiteSlot(ctx context.Context, id SlotId) (resp ListBySiteSlotOperationResponse, err error) { - req, err := c.preparerForListBySiteSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "resourcehealthmetadata.ResourceHealthMetadataClient", "ListBySiteSlot", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "resourcehealthmetadata.ResourceHealthMetadataClient", "ListBySiteSlot", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListBySiteSlot(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "resourcehealthmetadata.ResourceHealthMetadataClient", "ListBySiteSlot", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListBySiteSlot prepares the ListBySiteSlot request. -func (c ResourceHealthMetadataClient) preparerForListBySiteSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/resourceHealthMetadata", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListBySiteSlotWithNextLink prepares the ListBySiteSlot request with the given nextLink token. -func (c ResourceHealthMetadataClient) preparerForListBySiteSlotWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListBySiteSlot handles the response to the ListBySiteSlot request. The method always -// closes the http.Response Body. -func (c ResourceHealthMetadataClient) responderForListBySiteSlot(resp *http.Response) (result ListBySiteSlotOperationResponse, err error) { - type page struct { - Values []ResourceHealthMetadata `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListBySiteSlotOperationResponse, err error) { - req, err := c.preparerForListBySiteSlotWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "resourcehealthmetadata.ResourceHealthMetadataClient", "ListBySiteSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "resourcehealthmetadata.ResourceHealthMetadataClient", "ListBySiteSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListBySiteSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "resourcehealthmetadata.ResourceHealthMetadataClient", "ListBySiteSlot", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListBySiteSlotComplete retrieves all of the results into a single object -func (c ResourceHealthMetadataClient) ListBySiteSlotComplete(ctx context.Context, id SlotId) (ListBySiteSlotCompleteResult, error) { - return c.ListBySiteSlotCompleteMatchingPredicate(ctx, id, ResourceHealthMetadataOperationPredicate{}) -} - -// ListBySiteSlotCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ResourceHealthMetadataClient) ListBySiteSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate ResourceHealthMetadataOperationPredicate) (resp ListBySiteSlotCompleteResult, err error) { - items := make([]ResourceHealthMetadata, 0) - - page, err := c.ListBySiteSlot(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListBySiteSlotCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/resourceproviders/client.go b/resource-manager/web/2022-09-01/resourceproviders/client.go index 8017103c110..bf4b3ad2627 100644 --- a/resource-manager/web/2022-09-01/resourceproviders/client.go +++ b/resource-manager/web/2022-09-01/resourceproviders/client.go @@ -1,18 +1,26 @@ package resourceproviders -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 ResourceProvidersClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewResourceProvidersClientWithBaseURI(endpoint string) ResourceProvidersClient { - return ResourceProvidersClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewResourceProvidersClientWithBaseURI(api environments.Api) (*ResourceProvidersClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "resourceproviders", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ResourceProvidersClient: %+v", err) } + + return &ResourceProvidersClient{ + Client: client, + }, nil } diff --git a/resource-manager/web/2022-09-01/resourceproviders/constants.go b/resource-manager/web/2022-09-01/resourceproviders/constants.go index 7a8a3dab2fa..54b4de195a5 100644 --- a/resource-manager/web/2022-09-01/resourceproviders/constants.go +++ b/resource-manager/web/2022-09-01/resourceproviders/constants.go @@ -1,6 +1,10 @@ package resourceproviders -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. @@ -27,6 +31,19 @@ func PossibleValuesForAppServicePlanRestrictions() []string { } } +func (s *AppServicePlanRestrictions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAppServicePlanRestrictions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAppServicePlanRestrictions(input string) (*AppServicePlanRestrictions, error) { vals := map[string]AppServicePlanRestrictions{ "basic": AppServicePlanRestrictionsBasic, @@ -71,6 +88,19 @@ func PossibleValuesForCheckNameResourceTypes() []string { } } +func (s *CheckNameResourceTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCheckNameResourceTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseCheckNameResourceTypes(input string) (*CheckNameResourceTypes, error) { vals := map[string]CheckNameResourceTypes{ "hostingenvironment": CheckNameResourceTypesHostingEnvironment, @@ -109,6 +139,19 @@ func PossibleValuesForCustomDnsSuffixProvisioningState() []string { } } +func (s *CustomDnsSuffixProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCustomDnsSuffixProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseCustomDnsSuffixProvisioningState(input string) (*CustomDnsSuffixProvisioningState, error) { vals := map[string]CustomDnsSuffixProvisioningState{ "degraded": CustomDnsSuffixProvisioningStateDegraded, @@ -143,6 +186,19 @@ func PossibleValuesForHostingEnvironmentStatus() []string { } } +func (s *HostingEnvironmentStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHostingEnvironmentStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseHostingEnvironmentStatus(input string) (*HostingEnvironmentStatus, error) { vals := map[string]HostingEnvironmentStatus{ "deleting": HostingEnvironmentStatusDeleting, @@ -173,6 +229,19 @@ func PossibleValuesForInAvailabilityReasonType() []string { } } +func (s *InAvailabilityReasonType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseInAvailabilityReasonType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseInAvailabilityReasonType(input string) (*InAvailabilityReasonType, error) { vals := map[string]InAvailabilityReasonType{ "alreadyexists": InAvailabilityReasonTypeAlreadyExists, @@ -205,6 +274,19 @@ func PossibleValuesForLoadBalancingMode() []string { } } +func (s *LoadBalancingMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLoadBalancingMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseLoadBalancingMode(input string) (*LoadBalancingMode, error) { vals := map[string]LoadBalancingMode{ "none": LoadBalancingModeNone, @@ -241,6 +323,19 @@ func PossibleValuesForProvisioningState() []string { } } +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseProvisioningState(input string) (*ProvisioningState, error) { vals := map[string]ProvisioningState{ "canceled": ProvisioningStateCanceled, @@ -294,6 +389,19 @@ func PossibleValuesForSkuName() []string { } } +func (s *SkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseSkuName(input string) (*SkuName, error) { vals := map[string]SkuName{ "basic": SkuNameBasic, @@ -333,6 +441,19 @@ func PossibleValuesForUpgradeAvailability() []string { } } +func (s *UpgradeAvailability) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUpgradeAvailability(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseUpgradeAvailability(input string) (*UpgradeAvailability, error) { vals := map[string]UpgradeAvailability{ "none": UpgradeAvailabilityNone, @@ -365,6 +486,19 @@ func PossibleValuesForUpgradePreference() []string { } } +func (s *UpgradePreference) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUpgradePreference(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseUpgradePreference(input string) (*UpgradePreference, error) { vals := map[string]UpgradePreference{ "early": UpgradePreferenceEarly, @@ -397,6 +531,19 @@ func PossibleValuesForValidateResourceTypes() []string { } } +func (s *ValidateResourceTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseValidateResourceTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseValidateResourceTypes(input string) (*ValidateResourceTypes, error) { vals := map[string]ValidateResourceTypes{ "microsoft.web/hostingenvironments": ValidateResourceTypesMicrosoftPointWebHostingEnvironments, diff --git a/resource-manager/web/2022-09-01/resourceproviders/method_checknameavailability.go b/resource-manager/web/2022-09-01/resourceproviders/method_checknameavailability.go new file mode 100644 index 00000000000..dbe02e46803 --- /dev/null +++ b/resource-manager/web/2022-09-01/resourceproviders/method_checknameavailability.go @@ -0,0 +1,57 @@ +package resourceproviders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 CheckNameAvailabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ResourceNameAvailability +} + +// CheckNameAvailability ... +func (c ResourceProvidersClient) CheckNameAvailability(ctx context.Context, id commonids.SubscriptionId, input ResourceNameAvailabilityRequest) (result CheckNameAvailabilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/checknameavailability", 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 +} diff --git a/resource-manager/web/2022-09-01/resourceproviders/method_checknameavailability_autorest.go b/resource-manager/web/2022-09-01/resourceproviders/method_checknameavailability_autorest.go deleted file mode 100644 index cec5d8c9cc1..00000000000 --- a/resource-manager/web/2022-09-01/resourceproviders/method_checknameavailability_autorest.go +++ /dev/null @@ -1,71 +0,0 @@ -package resourceproviders - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CheckNameAvailabilityOperationResponse struct { - HttpResponse *http.Response - Model *ResourceNameAvailability -} - -// CheckNameAvailability ... -func (c ResourceProvidersClient) CheckNameAvailability(ctx context.Context, id commonids.SubscriptionId, input ResourceNameAvailabilityRequest) (result CheckNameAvailabilityOperationResponse, err error) { - req, err := c.preparerForCheckNameAvailability(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "CheckNameAvailability", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "CheckNameAvailability", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCheckNameAvailability(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "CheckNameAvailability", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCheckNameAvailability prepares the CheckNameAvailability request. -func (c ResourceProvidersClient) preparerForCheckNameAvailability(ctx context.Context, id commonids.SubscriptionId, input ResourceNameAvailabilityRequest) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Web/checknameavailability", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCheckNameAvailability handles the response to the CheckNameAvailability request. The method always -// closes the http.Response Body. -func (c ResourceProvidersClient) responderForCheckNameAvailability(resp *http.Response) (result CheckNameAvailabilityOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/resourceproviders/method_getpublishinguser.go b/resource-manager/web/2022-09-01/resourceproviders/method_getpublishinguser.go new file mode 100644 index 00000000000..5cfb641f0ce --- /dev/null +++ b/resource-manager/web/2022-09-01/resourceproviders/method_getpublishinguser.go @@ -0,0 +1,51 @@ +package resourceproviders + +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 GetPublishingUserOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *User +} + +// GetPublishingUser ... +func (c ResourceProvidersClient) GetPublishingUser(ctx context.Context) (result GetPublishingUserOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: "/providers/Microsoft.Web/publishingUsers/web", + } + + 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 +} diff --git a/resource-manager/web/2022-09-01/resourceproviders/method_getpublishinguser_autorest.go b/resource-manager/web/2022-09-01/resourceproviders/method_getpublishinguser_autorest.go deleted file mode 100644 index a11b893f611..00000000000 --- a/resource-manager/web/2022-09-01/resourceproviders/method_getpublishinguser_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package resourceproviders - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetPublishingUserOperationResponse struct { - HttpResponse *http.Response - Model *User -} - -// GetPublishingUser ... -func (c ResourceProvidersClient) GetPublishingUser(ctx context.Context) (result GetPublishingUserOperationResponse, err error) { - req, err := c.preparerForGetPublishingUser(ctx) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "GetPublishingUser", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "GetPublishingUser", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetPublishingUser(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "GetPublishingUser", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetPublishingUser prepares the GetPublishingUser request. -func (c ResourceProvidersClient) preparerForGetPublishingUser(ctx context.Context) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath("/providers/Microsoft.Web/publishingUsers/web"), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetPublishingUser handles the response to the GetPublishingUser request. The method always -// closes the http.Response Body. -func (c ResourceProvidersClient) responderForGetPublishingUser(resp *http.Response) (result GetPublishingUserOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/resourceproviders/method_getsourcecontrol.go b/resource-manager/web/2022-09-01/resourceproviders/method_getsourcecontrol.go new file mode 100644 index 00000000000..f298afa0fde --- /dev/null +++ b/resource-manager/web/2022-09-01/resourceproviders/method_getsourcecontrol.go @@ -0,0 +1,51 @@ +package resourceproviders + +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 GetSourceControlOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SourceControl +} + +// GetSourceControl ... +func (c ResourceProvidersClient) GetSourceControl(ctx context.Context, id SourceControlId) (result GetSourceControlOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/resourceproviders/method_getsourcecontrol_autorest.go b/resource-manager/web/2022-09-01/resourceproviders/method_getsourcecontrol_autorest.go deleted file mode 100644 index 678d38bb8df..00000000000 --- a/resource-manager/web/2022-09-01/resourceproviders/method_getsourcecontrol_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package resourceproviders - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetSourceControlOperationResponse struct { - HttpResponse *http.Response - Model *SourceControl -} - -// GetSourceControl ... -func (c ResourceProvidersClient) GetSourceControl(ctx context.Context, id SourceControlId) (result GetSourceControlOperationResponse, err error) { - req, err := c.preparerForGetSourceControl(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "GetSourceControl", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "GetSourceControl", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetSourceControl(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "GetSourceControl", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetSourceControl prepares the GetSourceControl request. -func (c ResourceProvidersClient) preparerForGetSourceControl(ctx context.Context, id SourceControlId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetSourceControl handles the response to the GetSourceControl request. The method always -// closes the http.Response Body. -func (c ResourceProvidersClient) responderForGetSourceControl(resp *http.Response) (result GetSourceControlOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/resourceproviders/method_getsubscriptiondeploymentlocations.go b/resource-manager/web/2022-09-01/resourceproviders/method_getsubscriptiondeploymentlocations.go new file mode 100644 index 00000000000..a550f45169d --- /dev/null +++ b/resource-manager/web/2022-09-01/resourceproviders/method_getsubscriptiondeploymentlocations.go @@ -0,0 +1,53 @@ +package resourceproviders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 GetSubscriptionDeploymentLocationsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DeploymentLocations +} + +// GetSubscriptionDeploymentLocations ... +func (c ResourceProvidersClient) GetSubscriptionDeploymentLocations(ctx context.Context, id commonids.SubscriptionId) (result GetSubscriptionDeploymentLocationsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/deploymentLocations", 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 +} diff --git a/resource-manager/web/2022-09-01/resourceproviders/method_getsubscriptiondeploymentlocations_autorest.go b/resource-manager/web/2022-09-01/resourceproviders/method_getsubscriptiondeploymentlocations_autorest.go deleted file mode 100644 index 900cbf2262c..00000000000 --- a/resource-manager/web/2022-09-01/resourceproviders/method_getsubscriptiondeploymentlocations_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package resourceproviders - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetSubscriptionDeploymentLocationsOperationResponse struct { - HttpResponse *http.Response - Model *DeploymentLocations -} - -// GetSubscriptionDeploymentLocations ... -func (c ResourceProvidersClient) GetSubscriptionDeploymentLocations(ctx context.Context, id commonids.SubscriptionId) (result GetSubscriptionDeploymentLocationsOperationResponse, err error) { - req, err := c.preparerForGetSubscriptionDeploymentLocations(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "GetSubscriptionDeploymentLocations", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "GetSubscriptionDeploymentLocations", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetSubscriptionDeploymentLocations(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "GetSubscriptionDeploymentLocations", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetSubscriptionDeploymentLocations prepares the GetSubscriptionDeploymentLocations request. -func (c ResourceProvidersClient) preparerForGetSubscriptionDeploymentLocations(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Web/deploymentLocations", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetSubscriptionDeploymentLocations handles the response to the GetSubscriptionDeploymentLocations request. The method always -// closes the http.Response Body. -func (c ResourceProvidersClient) responderForGetSubscriptionDeploymentLocations(resp *http.Response) (result GetSubscriptionDeploymentLocationsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/resourceproviders/method_listbillingmeters.go b/resource-manager/web/2022-09-01/resourceproviders/method_listbillingmeters.go new file mode 100644 index 00000000000..a5c1fe8c21b --- /dev/null +++ b/resource-manager/web/2022-09-01/resourceproviders/method_listbillingmeters.go @@ -0,0 +1,122 @@ +package resourceproviders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListBillingMetersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]BillingMeter +} + +type ListBillingMetersCompleteResult struct { + Items []BillingMeter +} + +type ListBillingMetersOperationOptions struct { + BillingLocation *string + OsType *string +} + +func DefaultListBillingMetersOperationOptions() ListBillingMetersOperationOptions { + return ListBillingMetersOperationOptions{} +} + +func (o ListBillingMetersOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListBillingMetersOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListBillingMetersOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.BillingLocation != nil { + out.Append("billingLocation", fmt.Sprintf("%v", *o.BillingLocation)) + } + if o.OsType != nil { + out.Append("osType", fmt.Sprintf("%v", *o.OsType)) + } + return &out +} + +// ListBillingMeters ... +func (c ResourceProvidersClient) ListBillingMeters(ctx context.Context, id commonids.SubscriptionId, options ListBillingMetersOperationOptions) (result ListBillingMetersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/billingMeters", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]BillingMeter `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBillingMetersComplete retrieves all the results into a single object +func (c ResourceProvidersClient) ListBillingMetersComplete(ctx context.Context, id commonids.SubscriptionId, options ListBillingMetersOperationOptions) (ListBillingMetersCompleteResult, error) { + return c.ListBillingMetersCompleteMatchingPredicate(ctx, id, options, BillingMeterOperationPredicate{}) +} + +// ListBillingMetersCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceProvidersClient) ListBillingMetersCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListBillingMetersOperationOptions, predicate BillingMeterOperationPredicate) (result ListBillingMetersCompleteResult, err error) { + items := make([]BillingMeter, 0) + + resp, err := c.ListBillingMeters(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListBillingMetersCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/resourceproviders/method_listbillingmeters_autorest.go b/resource-manager/web/2022-09-01/resourceproviders/method_listbillingmeters_autorest.go deleted file mode 100644 index 8e4673a44a9..00000000000 --- a/resource-manager/web/2022-09-01/resourceproviders/method_listbillingmeters_autorest.go +++ /dev/null @@ -1,221 +0,0 @@ -package resourceproviders - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListBillingMetersOperationResponse struct { - HttpResponse *http.Response - Model *[]BillingMeter - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListBillingMetersOperationResponse, error) -} - -type ListBillingMetersCompleteResult struct { - Items []BillingMeter -} - -func (r ListBillingMetersOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListBillingMetersOperationResponse) LoadMore(ctx context.Context) (resp ListBillingMetersOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListBillingMetersOperationOptions struct { - BillingLocation *string - OsType *string -} - -func DefaultListBillingMetersOperationOptions() ListBillingMetersOperationOptions { - return ListBillingMetersOperationOptions{} -} - -func (o ListBillingMetersOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListBillingMetersOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.BillingLocation != nil { - out["billingLocation"] = *o.BillingLocation - } - - if o.OsType != nil { - out["osType"] = *o.OsType - } - - return out -} - -// ListBillingMeters ... -func (c ResourceProvidersClient) ListBillingMeters(ctx context.Context, id commonids.SubscriptionId, options ListBillingMetersOperationOptions) (resp ListBillingMetersOperationResponse, err error) { - req, err := c.preparerForListBillingMeters(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "ListBillingMeters", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "ListBillingMeters", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListBillingMeters(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "ListBillingMeters", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListBillingMeters prepares the ListBillingMeters request. -func (c ResourceProvidersClient) preparerForListBillingMeters(ctx context.Context, id commonids.SubscriptionId, options ListBillingMetersOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Web/billingMeters", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListBillingMetersWithNextLink prepares the ListBillingMeters request with the given nextLink token. -func (c ResourceProvidersClient) preparerForListBillingMetersWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListBillingMeters handles the response to the ListBillingMeters request. The method always -// closes the http.Response Body. -func (c ResourceProvidersClient) responderForListBillingMeters(resp *http.Response) (result ListBillingMetersOperationResponse, err error) { - type page struct { - Values []BillingMeter `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListBillingMetersOperationResponse, err error) { - req, err := c.preparerForListBillingMetersWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "ListBillingMeters", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "ListBillingMeters", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListBillingMeters(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "ListBillingMeters", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListBillingMetersComplete retrieves all of the results into a single object -func (c ResourceProvidersClient) ListBillingMetersComplete(ctx context.Context, id commonids.SubscriptionId, options ListBillingMetersOperationOptions) (ListBillingMetersCompleteResult, error) { - return c.ListBillingMetersCompleteMatchingPredicate(ctx, id, options, BillingMeterOperationPredicate{}) -} - -// ListBillingMetersCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ResourceProvidersClient) ListBillingMetersCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListBillingMetersOperationOptions, predicate BillingMeterOperationPredicate) (resp ListBillingMetersCompleteResult, err error) { - items := make([]BillingMeter, 0) - - page, err := c.ListBillingMeters(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListBillingMetersCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/resourceproviders/method_listcustomhostnamesites.go b/resource-manager/web/2022-09-01/resourceproviders/method_listcustomhostnamesites.go new file mode 100644 index 00000000000..4fce76c0c0d --- /dev/null +++ b/resource-manager/web/2022-09-01/resourceproviders/method_listcustomhostnamesites.go @@ -0,0 +1,118 @@ +package resourceproviders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListCustomHostNameSitesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CustomHostnameSites +} + +type ListCustomHostNameSitesCompleteResult struct { + Items []CustomHostnameSites +} + +type ListCustomHostNameSitesOperationOptions struct { + Hostname *string +} + +func DefaultListCustomHostNameSitesOperationOptions() ListCustomHostNameSitesOperationOptions { + return ListCustomHostNameSitesOperationOptions{} +} + +func (o ListCustomHostNameSitesOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListCustomHostNameSitesOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListCustomHostNameSitesOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Hostname != nil { + out.Append("hostname", fmt.Sprintf("%v", *o.Hostname)) + } + return &out +} + +// ListCustomHostNameSites ... +func (c ResourceProvidersClient) ListCustomHostNameSites(ctx context.Context, id commonids.SubscriptionId, options ListCustomHostNameSitesOperationOptions) (result ListCustomHostNameSitesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/customhostnameSites", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]CustomHostnameSites `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListCustomHostNameSitesComplete retrieves all the results into a single object +func (c ResourceProvidersClient) ListCustomHostNameSitesComplete(ctx context.Context, id commonids.SubscriptionId, options ListCustomHostNameSitesOperationOptions) (ListCustomHostNameSitesCompleteResult, error) { + return c.ListCustomHostNameSitesCompleteMatchingPredicate(ctx, id, options, CustomHostnameSitesOperationPredicate{}) +} + +// ListCustomHostNameSitesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceProvidersClient) ListCustomHostNameSitesCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListCustomHostNameSitesOperationOptions, predicate CustomHostnameSitesOperationPredicate) (result ListCustomHostNameSitesCompleteResult, err error) { + items := make([]CustomHostnameSites, 0) + + resp, err := c.ListCustomHostNameSites(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCustomHostNameSitesCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/resourceproviders/method_listcustomhostnamesites_autorest.go b/resource-manager/web/2022-09-01/resourceproviders/method_listcustomhostnamesites_autorest.go deleted file mode 100644 index ce7a302a02e..00000000000 --- a/resource-manager/web/2022-09-01/resourceproviders/method_listcustomhostnamesites_autorest.go +++ /dev/null @@ -1,216 +0,0 @@ -package resourceproviders - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListCustomHostNameSitesOperationResponse struct { - HttpResponse *http.Response - Model *[]CustomHostnameSites - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListCustomHostNameSitesOperationResponse, error) -} - -type ListCustomHostNameSitesCompleteResult struct { - Items []CustomHostnameSites -} - -func (r ListCustomHostNameSitesOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListCustomHostNameSitesOperationResponse) LoadMore(ctx context.Context) (resp ListCustomHostNameSitesOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListCustomHostNameSitesOperationOptions struct { - Hostname *string -} - -func DefaultListCustomHostNameSitesOperationOptions() ListCustomHostNameSitesOperationOptions { - return ListCustomHostNameSitesOperationOptions{} -} - -func (o ListCustomHostNameSitesOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListCustomHostNameSitesOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Hostname != nil { - out["hostname"] = *o.Hostname - } - - return out -} - -// ListCustomHostNameSites ... -func (c ResourceProvidersClient) ListCustomHostNameSites(ctx context.Context, id commonids.SubscriptionId, options ListCustomHostNameSitesOperationOptions) (resp ListCustomHostNameSitesOperationResponse, err error) { - req, err := c.preparerForListCustomHostNameSites(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "ListCustomHostNameSites", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "ListCustomHostNameSites", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListCustomHostNameSites(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "ListCustomHostNameSites", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListCustomHostNameSites prepares the ListCustomHostNameSites request. -func (c ResourceProvidersClient) preparerForListCustomHostNameSites(ctx context.Context, id commonids.SubscriptionId, options ListCustomHostNameSitesOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Web/customhostnameSites", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListCustomHostNameSitesWithNextLink prepares the ListCustomHostNameSites request with the given nextLink token. -func (c ResourceProvidersClient) preparerForListCustomHostNameSitesWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListCustomHostNameSites handles the response to the ListCustomHostNameSites request. The method always -// closes the http.Response Body. -func (c ResourceProvidersClient) responderForListCustomHostNameSites(resp *http.Response) (result ListCustomHostNameSitesOperationResponse, err error) { - type page struct { - Values []CustomHostnameSites `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListCustomHostNameSitesOperationResponse, err error) { - req, err := c.preparerForListCustomHostNameSitesWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "ListCustomHostNameSites", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "ListCustomHostNameSites", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListCustomHostNameSites(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "ListCustomHostNameSites", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListCustomHostNameSitesComplete retrieves all of the results into a single object -func (c ResourceProvidersClient) ListCustomHostNameSitesComplete(ctx context.Context, id commonids.SubscriptionId, options ListCustomHostNameSitesOperationOptions) (ListCustomHostNameSitesCompleteResult, error) { - return c.ListCustomHostNameSitesCompleteMatchingPredicate(ctx, id, options, CustomHostnameSitesOperationPredicate{}) -} - -// ListCustomHostNameSitesCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ResourceProvidersClient) ListCustomHostNameSitesCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListCustomHostNameSitesOperationOptions, predicate CustomHostnameSitesOperationPredicate) (resp ListCustomHostNameSitesCompleteResult, err error) { - items := make([]CustomHostnameSites, 0) - - page, err := c.ListCustomHostNameSites(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCustomHostNameSitesCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/resourceproviders/method_listgeoregions.go b/resource-manager/web/2022-09-01/resourceproviders/method_listgeoregions.go new file mode 100644 index 00000000000..1e3e9832208 --- /dev/null +++ b/resource-manager/web/2022-09-01/resourceproviders/method_listgeoregions.go @@ -0,0 +1,130 @@ +package resourceproviders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListGeoRegionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]GeoRegion +} + +type ListGeoRegionsCompleteResult struct { + Items []GeoRegion +} + +type ListGeoRegionsOperationOptions struct { + LinuxDynamicWorkersEnabled *bool + LinuxWorkersEnabled *bool + Sku *SkuName + XenonWorkersEnabled *bool +} + +func DefaultListGeoRegionsOperationOptions() ListGeoRegionsOperationOptions { + return ListGeoRegionsOperationOptions{} +} + +func (o ListGeoRegionsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListGeoRegionsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListGeoRegionsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.LinuxDynamicWorkersEnabled != nil { + out.Append("linuxDynamicWorkersEnabled", fmt.Sprintf("%v", *o.LinuxDynamicWorkersEnabled)) + } + if o.LinuxWorkersEnabled != nil { + out.Append("linuxWorkersEnabled", fmt.Sprintf("%v", *o.LinuxWorkersEnabled)) + } + if o.Sku != nil { + out.Append("sku", fmt.Sprintf("%v", *o.Sku)) + } + if o.XenonWorkersEnabled != nil { + out.Append("xenonWorkersEnabled", fmt.Sprintf("%v", *o.XenonWorkersEnabled)) + } + return &out +} + +// ListGeoRegions ... +func (c ResourceProvidersClient) ListGeoRegions(ctx context.Context, id commonids.SubscriptionId, options ListGeoRegionsOperationOptions) (result ListGeoRegionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/geoRegions", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]GeoRegion `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListGeoRegionsComplete retrieves all the results into a single object +func (c ResourceProvidersClient) ListGeoRegionsComplete(ctx context.Context, id commonids.SubscriptionId, options ListGeoRegionsOperationOptions) (ListGeoRegionsCompleteResult, error) { + return c.ListGeoRegionsCompleteMatchingPredicate(ctx, id, options, GeoRegionOperationPredicate{}) +} + +// ListGeoRegionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceProvidersClient) ListGeoRegionsCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListGeoRegionsOperationOptions, predicate GeoRegionOperationPredicate) (result ListGeoRegionsCompleteResult, err error) { + items := make([]GeoRegion, 0) + + resp, err := c.ListGeoRegions(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListGeoRegionsCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/resourceproviders/method_listgeoregions_autorest.go b/resource-manager/web/2022-09-01/resourceproviders/method_listgeoregions_autorest.go deleted file mode 100644 index fb2549d870a..00000000000 --- a/resource-manager/web/2022-09-01/resourceproviders/method_listgeoregions_autorest.go +++ /dev/null @@ -1,231 +0,0 @@ -package resourceproviders - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListGeoRegionsOperationResponse struct { - HttpResponse *http.Response - Model *[]GeoRegion - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListGeoRegionsOperationResponse, error) -} - -type ListGeoRegionsCompleteResult struct { - Items []GeoRegion -} - -func (r ListGeoRegionsOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListGeoRegionsOperationResponse) LoadMore(ctx context.Context) (resp ListGeoRegionsOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListGeoRegionsOperationOptions struct { - LinuxDynamicWorkersEnabled *bool - LinuxWorkersEnabled *bool - Sku *SkuName - XenonWorkersEnabled *bool -} - -func DefaultListGeoRegionsOperationOptions() ListGeoRegionsOperationOptions { - return ListGeoRegionsOperationOptions{} -} - -func (o ListGeoRegionsOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListGeoRegionsOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.LinuxDynamicWorkersEnabled != nil { - out["linuxDynamicWorkersEnabled"] = *o.LinuxDynamicWorkersEnabled - } - - if o.LinuxWorkersEnabled != nil { - out["linuxWorkersEnabled"] = *o.LinuxWorkersEnabled - } - - if o.Sku != nil { - out["sku"] = *o.Sku - } - - if o.XenonWorkersEnabled != nil { - out["xenonWorkersEnabled"] = *o.XenonWorkersEnabled - } - - return out -} - -// ListGeoRegions ... -func (c ResourceProvidersClient) ListGeoRegions(ctx context.Context, id commonids.SubscriptionId, options ListGeoRegionsOperationOptions) (resp ListGeoRegionsOperationResponse, err error) { - req, err := c.preparerForListGeoRegions(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "ListGeoRegions", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "ListGeoRegions", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListGeoRegions(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "ListGeoRegions", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListGeoRegions prepares the ListGeoRegions request. -func (c ResourceProvidersClient) preparerForListGeoRegions(ctx context.Context, id commonids.SubscriptionId, options ListGeoRegionsOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Web/geoRegions", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListGeoRegionsWithNextLink prepares the ListGeoRegions request with the given nextLink token. -func (c ResourceProvidersClient) preparerForListGeoRegionsWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListGeoRegions handles the response to the ListGeoRegions request. The method always -// closes the http.Response Body. -func (c ResourceProvidersClient) responderForListGeoRegions(resp *http.Response) (result ListGeoRegionsOperationResponse, err error) { - type page struct { - Values []GeoRegion `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListGeoRegionsOperationResponse, err error) { - req, err := c.preparerForListGeoRegionsWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "ListGeoRegions", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "ListGeoRegions", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListGeoRegions(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "ListGeoRegions", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListGeoRegionsComplete retrieves all of the results into a single object -func (c ResourceProvidersClient) ListGeoRegionsComplete(ctx context.Context, id commonids.SubscriptionId, options ListGeoRegionsOperationOptions) (ListGeoRegionsCompleteResult, error) { - return c.ListGeoRegionsCompleteMatchingPredicate(ctx, id, options, GeoRegionOperationPredicate{}) -} - -// ListGeoRegionsCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ResourceProvidersClient) ListGeoRegionsCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListGeoRegionsOperationOptions, predicate GeoRegionOperationPredicate) (resp ListGeoRegionsCompleteResult, err error) { - items := make([]GeoRegion, 0) - - page, err := c.ListGeoRegions(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListGeoRegionsCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/resourceproviders/method_listpremieraddonoffers.go b/resource-manager/web/2022-09-01/resourceproviders/method_listpremieraddonoffers.go new file mode 100644 index 00000000000..4ff395dbc4c --- /dev/null +++ b/resource-manager/web/2022-09-01/resourceproviders/method_listpremieraddonoffers.go @@ -0,0 +1,90 @@ +package resourceproviders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListPremierAddOnOffersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PremierAddOnOffer +} + +type ListPremierAddOnOffersCompleteResult struct { + Items []PremierAddOnOffer +} + +// ListPremierAddOnOffers ... +func (c ResourceProvidersClient) ListPremierAddOnOffers(ctx context.Context, id commonids.SubscriptionId) (result ListPremierAddOnOffersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/premieraddonoffers", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PremierAddOnOffer `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListPremierAddOnOffersComplete retrieves all the results into a single object +func (c ResourceProvidersClient) ListPremierAddOnOffersComplete(ctx context.Context, id commonids.SubscriptionId) (ListPremierAddOnOffersCompleteResult, error) { + return c.ListPremierAddOnOffersCompleteMatchingPredicate(ctx, id, PremierAddOnOfferOperationPredicate{}) +} + +// ListPremierAddOnOffersCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceProvidersClient) ListPremierAddOnOffersCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate PremierAddOnOfferOperationPredicate) (result ListPremierAddOnOffersCompleteResult, err error) { + items := make([]PremierAddOnOffer, 0) + + resp, err := c.ListPremierAddOnOffers(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListPremierAddOnOffersCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/resourceproviders/method_listpremieraddonoffers_autorest.go b/resource-manager/web/2022-09-01/resourceproviders/method_listpremieraddonoffers_autorest.go deleted file mode 100644 index 5a5cfe5eabb..00000000000 --- a/resource-manager/web/2022-09-01/resourceproviders/method_listpremieraddonoffers_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package resourceproviders - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListPremierAddOnOffersOperationResponse struct { - HttpResponse *http.Response - Model *[]PremierAddOnOffer - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListPremierAddOnOffersOperationResponse, error) -} - -type ListPremierAddOnOffersCompleteResult struct { - Items []PremierAddOnOffer -} - -func (r ListPremierAddOnOffersOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListPremierAddOnOffersOperationResponse) LoadMore(ctx context.Context) (resp ListPremierAddOnOffersOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListPremierAddOnOffers ... -func (c ResourceProvidersClient) ListPremierAddOnOffers(ctx context.Context, id commonids.SubscriptionId) (resp ListPremierAddOnOffersOperationResponse, err error) { - req, err := c.preparerForListPremierAddOnOffers(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "ListPremierAddOnOffers", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "ListPremierAddOnOffers", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListPremierAddOnOffers(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "ListPremierAddOnOffers", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListPremierAddOnOffers prepares the ListPremierAddOnOffers request. -func (c ResourceProvidersClient) preparerForListPremierAddOnOffers(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Web/premieraddonoffers", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListPremierAddOnOffersWithNextLink prepares the ListPremierAddOnOffers request with the given nextLink token. -func (c ResourceProvidersClient) preparerForListPremierAddOnOffersWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListPremierAddOnOffers handles the response to the ListPremierAddOnOffers request. The method always -// closes the http.Response Body. -func (c ResourceProvidersClient) responderForListPremierAddOnOffers(resp *http.Response) (result ListPremierAddOnOffersOperationResponse, err error) { - type page struct { - Values []PremierAddOnOffer `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListPremierAddOnOffersOperationResponse, err error) { - req, err := c.preparerForListPremierAddOnOffersWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "ListPremierAddOnOffers", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "ListPremierAddOnOffers", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListPremierAddOnOffers(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "ListPremierAddOnOffers", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListPremierAddOnOffersComplete retrieves all of the results into a single object -func (c ResourceProvidersClient) ListPremierAddOnOffersComplete(ctx context.Context, id commonids.SubscriptionId) (ListPremierAddOnOffersCompleteResult, error) { - return c.ListPremierAddOnOffersCompleteMatchingPredicate(ctx, id, PremierAddOnOfferOperationPredicate{}) -} - -// ListPremierAddOnOffersCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ResourceProvidersClient) ListPremierAddOnOffersCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate PremierAddOnOfferOperationPredicate) (resp ListPremierAddOnOffersCompleteResult, err error) { - items := make([]PremierAddOnOffer, 0) - - page, err := c.ListPremierAddOnOffers(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListPremierAddOnOffersCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/resourceproviders/method_listsiteidentifiersassignedtohostname.go b/resource-manager/web/2022-09-01/resourceproviders/method_listsiteidentifiersassignedtohostname.go new file mode 100644 index 00000000000..f20e141d45c --- /dev/null +++ b/resource-manager/web/2022-09-01/resourceproviders/method_listsiteidentifiersassignedtohostname.go @@ -0,0 +1,90 @@ +package resourceproviders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListSiteIdentifiersAssignedToHostNameOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Identifier +} + +type ListSiteIdentifiersAssignedToHostNameCompleteResult struct { + Items []Identifier +} + +// ListSiteIdentifiersAssignedToHostName ... +func (c ResourceProvidersClient) ListSiteIdentifiersAssignedToHostName(ctx context.Context, id commonids.SubscriptionId, input NameIdentifier) (result ListSiteIdentifiersAssignedToHostNameOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/listSitesAssignedToHostName", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Identifier `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteIdentifiersAssignedToHostNameComplete retrieves all the results into a single object +func (c ResourceProvidersClient) ListSiteIdentifiersAssignedToHostNameComplete(ctx context.Context, id commonids.SubscriptionId, input NameIdentifier) (ListSiteIdentifiersAssignedToHostNameCompleteResult, error) { + return c.ListSiteIdentifiersAssignedToHostNameCompleteMatchingPredicate(ctx, id, input, IdentifierOperationPredicate{}) +} + +// ListSiteIdentifiersAssignedToHostNameCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceProvidersClient) ListSiteIdentifiersAssignedToHostNameCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, input NameIdentifier, predicate IdentifierOperationPredicate) (result ListSiteIdentifiersAssignedToHostNameCompleteResult, err error) { + items := make([]Identifier, 0) + + resp, err := c.ListSiteIdentifiersAssignedToHostName(ctx, id, input) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListSiteIdentifiersAssignedToHostNameCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/resourceproviders/method_listsiteidentifiersassignedtohostname_autorest.go b/resource-manager/web/2022-09-01/resourceproviders/method_listsiteidentifiersassignedtohostname_autorest.go deleted file mode 100644 index b1597bf60ca..00000000000 --- a/resource-manager/web/2022-09-01/resourceproviders/method_listsiteidentifiersassignedtohostname_autorest.go +++ /dev/null @@ -1,188 +0,0 @@ -package resourceproviders - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListSiteIdentifiersAssignedToHostNameOperationResponse struct { - HttpResponse *http.Response - Model *[]Identifier - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListSiteIdentifiersAssignedToHostNameOperationResponse, error) -} - -type ListSiteIdentifiersAssignedToHostNameCompleteResult struct { - Items []Identifier -} - -func (r ListSiteIdentifiersAssignedToHostNameOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListSiteIdentifiersAssignedToHostNameOperationResponse) LoadMore(ctx context.Context) (resp ListSiteIdentifiersAssignedToHostNameOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListSiteIdentifiersAssignedToHostName ... -func (c ResourceProvidersClient) ListSiteIdentifiersAssignedToHostName(ctx context.Context, id commonids.SubscriptionId, input NameIdentifier) (resp ListSiteIdentifiersAssignedToHostNameOperationResponse, err error) { - req, err := c.preparerForListSiteIdentifiersAssignedToHostName(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "ListSiteIdentifiersAssignedToHostName", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "ListSiteIdentifiersAssignedToHostName", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListSiteIdentifiersAssignedToHostName(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "ListSiteIdentifiersAssignedToHostName", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListSiteIdentifiersAssignedToHostName prepares the ListSiteIdentifiersAssignedToHostName request. -func (c ResourceProvidersClient) preparerForListSiteIdentifiersAssignedToHostName(ctx context.Context, id commonids.SubscriptionId, input NameIdentifier) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Web/listSitesAssignedToHostName", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListSiteIdentifiersAssignedToHostNameWithNextLink prepares the ListSiteIdentifiersAssignedToHostName request with the given nextLink token. -func (c ResourceProvidersClient) preparerForListSiteIdentifiersAssignedToHostNameWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListSiteIdentifiersAssignedToHostName handles the response to the ListSiteIdentifiersAssignedToHostName request. The method always -// closes the http.Response Body. -func (c ResourceProvidersClient) responderForListSiteIdentifiersAssignedToHostName(resp *http.Response) (result ListSiteIdentifiersAssignedToHostNameOperationResponse, err error) { - type page struct { - Values []Identifier `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListSiteIdentifiersAssignedToHostNameOperationResponse, err error) { - req, err := c.preparerForListSiteIdentifiersAssignedToHostNameWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "ListSiteIdentifiersAssignedToHostName", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "ListSiteIdentifiersAssignedToHostName", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListSiteIdentifiersAssignedToHostName(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "ListSiteIdentifiersAssignedToHostName", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListSiteIdentifiersAssignedToHostNameComplete retrieves all of the results into a single object -func (c ResourceProvidersClient) ListSiteIdentifiersAssignedToHostNameComplete(ctx context.Context, id commonids.SubscriptionId, input NameIdentifier) (ListSiteIdentifiersAssignedToHostNameCompleteResult, error) { - return c.ListSiteIdentifiersAssignedToHostNameCompleteMatchingPredicate(ctx, id, input, IdentifierOperationPredicate{}) -} - -// ListSiteIdentifiersAssignedToHostNameCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ResourceProvidersClient) ListSiteIdentifiersAssignedToHostNameCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, input NameIdentifier, predicate IdentifierOperationPredicate) (resp ListSiteIdentifiersAssignedToHostNameCompleteResult, err error) { - items := make([]Identifier, 0) - - page, err := c.ListSiteIdentifiersAssignedToHostName(ctx, id, input) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListSiteIdentifiersAssignedToHostNameCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/resourceproviders/method_listskus.go b/resource-manager/web/2022-09-01/resourceproviders/method_listskus.go new file mode 100644 index 00000000000..0cee557191b --- /dev/null +++ b/resource-manager/web/2022-09-01/resourceproviders/method_listskus.go @@ -0,0 +1,53 @@ +package resourceproviders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListSkusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SkuInfos +} + +// ListSkus ... +func (c ResourceProvidersClient) ListSkus(ctx context.Context, id commonids.SubscriptionId) (result ListSkusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/skus", 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 +} diff --git a/resource-manager/web/2022-09-01/resourceproviders/method_listskus_autorest.go b/resource-manager/web/2022-09-01/resourceproviders/method_listskus_autorest.go deleted file mode 100644 index b0a6311bb82..00000000000 --- a/resource-manager/web/2022-09-01/resourceproviders/method_listskus_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package resourceproviders - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListSkusOperationResponse struct { - HttpResponse *http.Response - Model *SkuInfos -} - -// ListSkus ... -func (c ResourceProvidersClient) ListSkus(ctx context.Context, id commonids.SubscriptionId) (result ListSkusOperationResponse, err error) { - req, err := c.preparerForListSkus(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "ListSkus", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "ListSkus", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListSkus(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "ListSkus", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListSkus prepares the ListSkus request. -func (c ResourceProvidersClient) preparerForListSkus(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Web/skus", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListSkus handles the response to the ListSkus request. The method always -// closes the http.Response Body. -func (c ResourceProvidersClient) responderForListSkus(resp *http.Response) (result ListSkusOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/resourceproviders/method_listsourcecontrols.go b/resource-manager/web/2022-09-01/resourceproviders/method_listsourcecontrols.go new file mode 100644 index 00000000000..8a082f651c7 --- /dev/null +++ b/resource-manager/web/2022-09-01/resourceproviders/method_listsourcecontrols.go @@ -0,0 +1,89 @@ +package resourceproviders + +import ( + "context" + "fmt" + "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 ListSourceControlsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SourceControl +} + +type ListSourceControlsCompleteResult struct { + Items []SourceControl +} + +// ListSourceControls ... +func (c ResourceProvidersClient) ListSourceControls(ctx context.Context) (result ListSourceControlsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: "/providers/Microsoft.Web/sourceControls", + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]SourceControl `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSourceControlsComplete retrieves all the results into a single object +func (c ResourceProvidersClient) ListSourceControlsComplete(ctx context.Context) (ListSourceControlsCompleteResult, error) { + return c.ListSourceControlsCompleteMatchingPredicate(ctx, SourceControlOperationPredicate{}) +} + +// ListSourceControlsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceProvidersClient) ListSourceControlsCompleteMatchingPredicate(ctx context.Context, predicate SourceControlOperationPredicate) (result ListSourceControlsCompleteResult, err error) { + items := make([]SourceControl, 0) + + resp, err := c.ListSourceControls(ctx) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListSourceControlsCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/resourceproviders/method_listsourcecontrols_autorest.go b/resource-manager/web/2022-09-01/resourceproviders/method_listsourcecontrols_autorest.go deleted file mode 100644 index 99c1c49d5ae..00000000000 --- a/resource-manager/web/2022-09-01/resourceproviders/method_listsourcecontrols_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package resourceproviders - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListSourceControlsOperationResponse struct { - HttpResponse *http.Response - Model *[]SourceControl - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListSourceControlsOperationResponse, error) -} - -type ListSourceControlsCompleteResult struct { - Items []SourceControl -} - -func (r ListSourceControlsOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListSourceControlsOperationResponse) LoadMore(ctx context.Context) (resp ListSourceControlsOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListSourceControls ... -func (c ResourceProvidersClient) ListSourceControls(ctx context.Context) (resp ListSourceControlsOperationResponse, err error) { - req, err := c.preparerForListSourceControls(ctx) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "ListSourceControls", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "ListSourceControls", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListSourceControls(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "ListSourceControls", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListSourceControls prepares the ListSourceControls request. -func (c ResourceProvidersClient) preparerForListSourceControls(ctx context.Context) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath("/providers/Microsoft.Web/sourceControls"), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListSourceControlsWithNextLink prepares the ListSourceControls request with the given nextLink token. -func (c ResourceProvidersClient) preparerForListSourceControlsWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListSourceControls handles the response to the ListSourceControls request. The method always -// closes the http.Response Body. -func (c ResourceProvidersClient) responderForListSourceControls(resp *http.Response) (result ListSourceControlsOperationResponse, err error) { - type page struct { - Values []SourceControl `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListSourceControlsOperationResponse, err error) { - req, err := c.preparerForListSourceControlsWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "ListSourceControls", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "ListSourceControls", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListSourceControls(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "ListSourceControls", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListSourceControlsComplete retrieves all of the results into a single object -func (c ResourceProvidersClient) ListSourceControlsComplete(ctx context.Context) (ListSourceControlsCompleteResult, error) { - return c.ListSourceControlsCompleteMatchingPredicate(ctx, SourceControlOperationPredicate{}) -} - -// ListSourceControlsCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c ResourceProvidersClient) ListSourceControlsCompleteMatchingPredicate(ctx context.Context, predicate SourceControlOperationPredicate) (resp ListSourceControlsCompleteResult, err error) { - items := make([]SourceControl, 0) - - page, err := c.ListSourceControls(ctx) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListSourceControlsCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/resourceproviders/method_move.go b/resource-manager/web/2022-09-01/resourceproviders/method_move.go new file mode 100644 index 00000000000..ff0f12304ee --- /dev/null +++ b/resource-manager/web/2022-09-01/resourceproviders/method_move.go @@ -0,0 +1,52 @@ +package resourceproviders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 MoveOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Move ... +func (c ResourceProvidersClient) Move(ctx context.Context, id commonids.ResourceGroupId, input CsmMoveResourceEnvelope) (result MoveOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/moveResources", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/resourceproviders/method_move_autorest.go b/resource-manager/web/2022-09-01/resourceproviders/method_move_autorest.go deleted file mode 100644 index e6982908c8c..00000000000 --- a/resource-manager/web/2022-09-01/resourceproviders/method_move_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package resourceproviders - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type MoveOperationResponse struct { - HttpResponse *http.Response -} - -// Move ... -func (c ResourceProvidersClient) Move(ctx context.Context, id commonids.ResourceGroupId, input CsmMoveResourceEnvelope) (result MoveOperationResponse, err error) { - req, err := c.preparerForMove(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "Move", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "Move", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForMove(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "Move", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForMove prepares the Move request. -func (c ResourceProvidersClient) preparerForMove(ctx context.Context, id commonids.ResourceGroupId, input CsmMoveResourceEnvelope) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/moveResources", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForMove handles the response to the Move request. The method always -// closes the http.Response Body. -func (c ResourceProvidersClient) responderForMove(resp *http.Response) (result MoveOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/resourceproviders/method_updatepublishinguser.go b/resource-manager/web/2022-09-01/resourceproviders/method_updatepublishinguser.go new file mode 100644 index 00000000000..339aabf038c --- /dev/null +++ b/resource-manager/web/2022-09-01/resourceproviders/method_updatepublishinguser.go @@ -0,0 +1,55 @@ +package resourceproviders + +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 UpdatePublishingUserOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *User +} + +// UpdatePublishingUser ... +func (c ResourceProvidersClient) UpdatePublishingUser(ctx context.Context, input User) (result UpdatePublishingUserOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: "/providers/Microsoft.Web/publishingUsers/web", + } + + 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 +} diff --git a/resource-manager/web/2022-09-01/resourceproviders/method_updatepublishinguser_autorest.go b/resource-manager/web/2022-09-01/resourceproviders/method_updatepublishinguser_autorest.go deleted file mode 100644 index 512f77c3fb4..00000000000 --- a/resource-manager/web/2022-09-01/resourceproviders/method_updatepublishinguser_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package resourceproviders - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdatePublishingUserOperationResponse struct { - HttpResponse *http.Response - Model *User -} - -// UpdatePublishingUser ... -func (c ResourceProvidersClient) UpdatePublishingUser(ctx context.Context, input User) (result UpdatePublishingUserOperationResponse, err error) { - req, err := c.preparerForUpdatePublishingUser(ctx, input) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "UpdatePublishingUser", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "UpdatePublishingUser", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdatePublishingUser(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "UpdatePublishingUser", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdatePublishingUser prepares the UpdatePublishingUser request. -func (c ResourceProvidersClient) preparerForUpdatePublishingUser(ctx context.Context, input User) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath("/providers/Microsoft.Web/publishingUsers/web"), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdatePublishingUser handles the response to the UpdatePublishingUser request. The method always -// closes the http.Response Body. -func (c ResourceProvidersClient) responderForUpdatePublishingUser(resp *http.Response) (result UpdatePublishingUserOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/resourceproviders/method_updatesourcecontrol.go b/resource-manager/web/2022-09-01/resourceproviders/method_updatesourcecontrol.go new file mode 100644 index 00000000000..a08993156ca --- /dev/null +++ b/resource-manager/web/2022-09-01/resourceproviders/method_updatesourcecontrol.go @@ -0,0 +1,55 @@ +package resourceproviders + +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 UpdateSourceControlOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SourceControl +} + +// UpdateSourceControl ... +func (c ResourceProvidersClient) UpdateSourceControl(ctx context.Context, id SourceControlId, input SourceControl) (result UpdateSourceControlOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 +} diff --git a/resource-manager/web/2022-09-01/resourceproviders/method_updatesourcecontrol_autorest.go b/resource-manager/web/2022-09-01/resourceproviders/method_updatesourcecontrol_autorest.go deleted file mode 100644 index 1ef29bfe547..00000000000 --- a/resource-manager/web/2022-09-01/resourceproviders/method_updatesourcecontrol_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package resourceproviders - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateSourceControlOperationResponse struct { - HttpResponse *http.Response - Model *SourceControl -} - -// UpdateSourceControl ... -func (c ResourceProvidersClient) UpdateSourceControl(ctx context.Context, id SourceControlId, input SourceControl) (result UpdateSourceControlOperationResponse, err error) { - req, err := c.preparerForUpdateSourceControl(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "UpdateSourceControl", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "UpdateSourceControl", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateSourceControl(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "UpdateSourceControl", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateSourceControl prepares the UpdateSourceControl request. -func (c ResourceProvidersClient) preparerForUpdateSourceControl(ctx context.Context, id SourceControlId, input SourceControl) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateSourceControl handles the response to the UpdateSourceControl request. The method always -// closes the http.Response Body. -func (c ResourceProvidersClient) responderForUpdateSourceControl(resp *http.Response) (result UpdateSourceControlOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/resourceproviders/method_validate.go b/resource-manager/web/2022-09-01/resourceproviders/method_validate.go new file mode 100644 index 00000000000..22587232832 --- /dev/null +++ b/resource-manager/web/2022-09-01/resourceproviders/method_validate.go @@ -0,0 +1,57 @@ +package resourceproviders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ValidateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ValidateResponse +} + +// Validate ... +func (c ResourceProvidersClient) Validate(ctx context.Context, id commonids.ResourceGroupId, input ValidateRequest) (result ValidateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/validate", 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 +} diff --git a/resource-manager/web/2022-09-01/resourceproviders/method_validate_autorest.go b/resource-manager/web/2022-09-01/resourceproviders/method_validate_autorest.go deleted file mode 100644 index cafb5eed4f7..00000000000 --- a/resource-manager/web/2022-09-01/resourceproviders/method_validate_autorest.go +++ /dev/null @@ -1,71 +0,0 @@ -package resourceproviders - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ValidateOperationResponse struct { - HttpResponse *http.Response - Model *ValidateResponse -} - -// Validate ... -func (c ResourceProvidersClient) Validate(ctx context.Context, id commonids.ResourceGroupId, input ValidateRequest) (result ValidateOperationResponse, err error) { - req, err := c.preparerForValidate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "Validate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "Validate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForValidate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "Validate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForValidate prepares the Validate request. -func (c ResourceProvidersClient) preparerForValidate(ctx context.Context, id commonids.ResourceGroupId, input ValidateRequest) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Web/validate", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForValidate handles the response to the Validate request. The method always -// closes the http.Response Body. -func (c ResourceProvidersClient) responderForValidate(resp *http.Response) (result ValidateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/resourceproviders/method_validatemove.go b/resource-manager/web/2022-09-01/resourceproviders/method_validatemove.go new file mode 100644 index 00000000000..f1f01d75957 --- /dev/null +++ b/resource-manager/web/2022-09-01/resourceproviders/method_validatemove.go @@ -0,0 +1,52 @@ +package resourceproviders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ValidateMoveOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ValidateMove ... +func (c ResourceProvidersClient) ValidateMove(ctx context.Context, id commonids.ResourceGroupId, input CsmMoveResourceEnvelope) (result ValidateMoveOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/validateMoveResources", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/resourceproviders/method_validatemove_autorest.go b/resource-manager/web/2022-09-01/resourceproviders/method_validatemove_autorest.go deleted file mode 100644 index 187a60e8ff1..00000000000 --- a/resource-manager/web/2022-09-01/resourceproviders/method_validatemove_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package resourceproviders - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ValidateMoveOperationResponse struct { - HttpResponse *http.Response -} - -// ValidateMove ... -func (c ResourceProvidersClient) ValidateMove(ctx context.Context, id commonids.ResourceGroupId, input CsmMoveResourceEnvelope) (result ValidateMoveOperationResponse, err error) { - req, err := c.preparerForValidateMove(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "ValidateMove", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "ValidateMove", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForValidateMove(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "ValidateMove", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForValidateMove prepares the ValidateMove request. -func (c ResourceProvidersClient) preparerForValidateMove(ctx context.Context, id commonids.ResourceGroupId, input CsmMoveResourceEnvelope) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/validateMoveResources", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForValidateMove handles the response to the ValidateMove request. The method always -// closes the http.Response Body. -func (c ResourceProvidersClient) responderForValidateMove(resp *http.Response) (result ValidateMoveOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/resourceproviders/method_verifyhostingenvironmentvnet.go b/resource-manager/web/2022-09-01/resourceproviders/method_verifyhostingenvironmentvnet.go new file mode 100644 index 00000000000..a4f71bdc48f --- /dev/null +++ b/resource-manager/web/2022-09-01/resourceproviders/method_verifyhostingenvironmentvnet.go @@ -0,0 +1,57 @@ +package resourceproviders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 VerifyHostingEnvironmentVnetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetValidationFailureDetails +} + +// VerifyHostingEnvironmentVnet ... +func (c ResourceProvidersClient) VerifyHostingEnvironmentVnet(ctx context.Context, id commonids.SubscriptionId, input VnetParameters) (result VerifyHostingEnvironmentVnetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/verifyHostingEnvironmentVnet", 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 +} diff --git a/resource-manager/web/2022-09-01/resourceproviders/method_verifyhostingenvironmentvnet_autorest.go b/resource-manager/web/2022-09-01/resourceproviders/method_verifyhostingenvironmentvnet_autorest.go deleted file mode 100644 index acaeb648e61..00000000000 --- a/resource-manager/web/2022-09-01/resourceproviders/method_verifyhostingenvironmentvnet_autorest.go +++ /dev/null @@ -1,71 +0,0 @@ -package resourceproviders - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type VerifyHostingEnvironmentVnetOperationResponse struct { - HttpResponse *http.Response - Model *VnetValidationFailureDetails -} - -// VerifyHostingEnvironmentVnet ... -func (c ResourceProvidersClient) VerifyHostingEnvironmentVnet(ctx context.Context, id commonids.SubscriptionId, input VnetParameters) (result VerifyHostingEnvironmentVnetOperationResponse, err error) { - req, err := c.preparerForVerifyHostingEnvironmentVnet(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "VerifyHostingEnvironmentVnet", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "VerifyHostingEnvironmentVnet", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForVerifyHostingEnvironmentVnet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "resourceproviders.ResourceProvidersClient", "VerifyHostingEnvironmentVnet", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForVerifyHostingEnvironmentVnet prepares the VerifyHostingEnvironmentVnet request. -func (c ResourceProvidersClient) preparerForVerifyHostingEnvironmentVnet(ctx context.Context, id commonids.SubscriptionId, input VnetParameters) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Web/verifyHostingEnvironmentVnet", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForVerifyHostingEnvironmentVnet handles the response to the VerifyHostingEnvironmentVnet request. The method always -// closes the http.Response Body. -func (c ResourceProvidersClient) responderForVerifyHostingEnvironmentVnet(resp *http.Response) (result VerifyHostingEnvironmentVnetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/client.go b/resource-manager/web/2022-09-01/staticsites/client.go index 6a8e522194f..41a9a3d6d83 100644 --- a/resource-manager/web/2022-09-01/staticsites/client.go +++ b/resource-manager/web/2022-09-01/staticsites/client.go @@ -1,18 +1,26 @@ package staticsites -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 StaticSitesClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewStaticSitesClientWithBaseURI(endpoint string) StaticSitesClient { - return StaticSitesClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewStaticSitesClientWithBaseURI(api environments.Api) (*StaticSitesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "staticsites", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating StaticSitesClient: %+v", err) } + + return &StaticSitesClient{ + Client: client, + }, nil } diff --git a/resource-manager/web/2022-09-01/staticsites/constants.go b/resource-manager/web/2022-09-01/staticsites/constants.go index 3d31ea629d6..dfdde973015 100644 --- a/resource-manager/web/2022-09-01/staticsites/constants.go +++ b/resource-manager/web/2022-09-01/staticsites/constants.go @@ -1,6 +1,10 @@ package staticsites -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. @@ -29,6 +33,19 @@ func PossibleValuesForBuildStatus() []string { } } +func (s *BuildStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBuildStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseBuildStatus(input string) (*BuildStatus, error) { vals := map[string]BuildStatus{ "deleting": BuildStatusDeleting, @@ -72,6 +89,19 @@ func PossibleValuesForCustomDomainStatus() []string { } } +func (s *CustomDomainStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCustomDomainStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseCustomDomainStatus(input string) (*CustomDomainStatus, error) { vals := map[string]CustomDomainStatus{ "adding": CustomDomainStatusAdding, @@ -109,6 +139,19 @@ func PossibleValuesForEnterpriseGradeCdnStatus() []string { } } +func (s *EnterpriseGradeCdnStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEnterpriseGradeCdnStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseEnterpriseGradeCdnStatus(input string) (*EnterpriseGradeCdnStatus, error) { vals := map[string]EnterpriseGradeCdnStatus{ "disabled": EnterpriseGradeCdnStatusDisabled, @@ -139,6 +182,19 @@ func PossibleValuesForStagingEnvironmentPolicy() []string { } } +func (s *StagingEnvironmentPolicy) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStagingEnvironmentPolicy(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseStagingEnvironmentPolicy(input string) (*StagingEnvironmentPolicy, error) { vals := map[string]StagingEnvironmentPolicy{ "disabled": StagingEnvironmentPolicyDisabled, @@ -167,6 +223,19 @@ func PossibleValuesForTriggerTypes() []string { } } +func (s *TriggerTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTriggerTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseTriggerTypes(input string) (*TriggerTypes, error) { vals := map[string]TriggerTypes{ "httptrigger": TriggerTypesHTTPTrigger, diff --git a/resource-manager/web/2022-09-01/staticsites/method_approveorrejectprivateendpointconnection.go b/resource-manager/web/2022-09-01/staticsites/method_approveorrejectprivateendpointconnection.go new file mode 100644 index 00000000000..3d2c848cda3 --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_approveorrejectprivateendpointconnection.go @@ -0,0 +1,74 @@ +package staticsites + +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 ApproveOrRejectPrivateEndpointConnectionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ApproveOrRejectPrivateEndpointConnection ... +func (c StaticSitesClient) ApproveOrRejectPrivateEndpointConnection(ctx context.Context, id StaticSitePrivateEndpointConnectionId, input PrivateLinkConnectionApprovalRequestResource) (result ApproveOrRejectPrivateEndpointConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// ApproveOrRejectPrivateEndpointConnectionThenPoll performs ApproveOrRejectPrivateEndpointConnection then polls until it's completed +func (c StaticSitesClient) ApproveOrRejectPrivateEndpointConnectionThenPoll(ctx context.Context, id StaticSitePrivateEndpointConnectionId, input PrivateLinkConnectionApprovalRequestResource) error { + result, err := c.ApproveOrRejectPrivateEndpointConnection(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ApproveOrRejectPrivateEndpointConnection: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ApproveOrRejectPrivateEndpointConnection: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_approveorrejectprivateendpointconnection_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_approveorrejectprivateendpointconnection_autorest.go deleted file mode 100644 index cb4b0a7d388..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_approveorrejectprivateendpointconnection_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package staticsites - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ApproveOrRejectPrivateEndpointConnectionOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// ApproveOrRejectPrivateEndpointConnection ... -func (c StaticSitesClient) ApproveOrRejectPrivateEndpointConnection(ctx context.Context, id StaticSitePrivateEndpointConnectionId, input PrivateLinkConnectionApprovalRequestResource) (result ApproveOrRejectPrivateEndpointConnectionOperationResponse, err error) { - req, err := c.preparerForApproveOrRejectPrivateEndpointConnection(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ApproveOrRejectPrivateEndpointConnection", nil, "Failure preparing request") - return - } - - result, err = c.senderForApproveOrRejectPrivateEndpointConnection(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ApproveOrRejectPrivateEndpointConnection", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// ApproveOrRejectPrivateEndpointConnectionThenPoll performs ApproveOrRejectPrivateEndpointConnection then polls until it's completed -func (c StaticSitesClient) ApproveOrRejectPrivateEndpointConnectionThenPoll(ctx context.Context, id StaticSitePrivateEndpointConnectionId, input PrivateLinkConnectionApprovalRequestResource) error { - result, err := c.ApproveOrRejectPrivateEndpointConnection(ctx, id, input) - if err != nil { - return fmt.Errorf("performing ApproveOrRejectPrivateEndpointConnection: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after ApproveOrRejectPrivateEndpointConnection: %+v", err) - } - - return nil -} - -// preparerForApproveOrRejectPrivateEndpointConnection prepares the ApproveOrRejectPrivateEndpointConnection request. -func (c StaticSitesClient) preparerForApproveOrRejectPrivateEndpointConnection(ctx context.Context, id StaticSitePrivateEndpointConnectionId, input PrivateLinkConnectionApprovalRequestResource) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForApproveOrRejectPrivateEndpointConnection sends the ApproveOrRejectPrivateEndpointConnection request. The method will close the -// http.Response Body if it receives an error. -func (c StaticSitesClient) senderForApproveOrRejectPrivateEndpointConnection(ctx context.Context, req *http.Request) (future ApproveOrRejectPrivateEndpointConnectionOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_createorupdatebasicauth.go b/resource-manager/web/2022-09-01/staticsites/method_createorupdatebasicauth.go new file mode 100644 index 00000000000..9ecf4725bda --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_createorupdatebasicauth.go @@ -0,0 +1,56 @@ +package staticsites + +import ( + "context" + "fmt" + "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 CreateOrUpdateBasicAuthOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteBasicAuthPropertiesARMResource +} + +// CreateOrUpdateBasicAuth ... +func (c StaticSitesClient) CreateOrUpdateBasicAuth(ctx context.Context, id StaticSiteId, input StaticSiteBasicAuthPropertiesARMResource) (result CreateOrUpdateBasicAuthOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/basicAuth/default", 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 +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_createorupdatebasicauth_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_createorupdatebasicauth_autorest.go deleted file mode 100644 index 716a6c67196..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_createorupdatebasicauth_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package staticsites - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateBasicAuthOperationResponse struct { - HttpResponse *http.Response - Model *StaticSiteBasicAuthPropertiesARMResource -} - -// CreateOrUpdateBasicAuth ... -func (c StaticSitesClient) CreateOrUpdateBasicAuth(ctx context.Context, id StaticSiteId, input StaticSiteBasicAuthPropertiesARMResource) (result CreateOrUpdateBasicAuthOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdateBasicAuth(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "CreateOrUpdateBasicAuth", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "CreateOrUpdateBasicAuth", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdateBasicAuth(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "CreateOrUpdateBasicAuth", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdateBasicAuth prepares the CreateOrUpdateBasicAuth request. -func (c StaticSitesClient) preparerForCreateOrUpdateBasicAuth(ctx context.Context, id StaticSiteId, input StaticSiteBasicAuthPropertiesARMResource) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/basicAuth/default", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateOrUpdateBasicAuth handles the response to the CreateOrUpdateBasicAuth request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForCreateOrUpdateBasicAuth(resp *http.Response) (result CreateOrUpdateBasicAuthOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_createorupdatebuilddatabaseconnection.go b/resource-manager/web/2022-09-01/staticsites/method_createorupdatebuilddatabaseconnection.go new file mode 100644 index 00000000000..a0a2c0ac26f --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_createorupdatebuilddatabaseconnection.go @@ -0,0 +1,55 @@ +package staticsites + +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 CreateOrUpdateBuildDatabaseConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DatabaseConnection +} + +// CreateOrUpdateBuildDatabaseConnection ... +func (c StaticSitesClient) CreateOrUpdateBuildDatabaseConnection(ctx context.Context, id BuildDatabaseConnectionId, input DatabaseConnection) (result CreateOrUpdateBuildDatabaseConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_createorupdatebuilddatabaseconnection_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_createorupdatebuilddatabaseconnection_autorest.go deleted file mode 100644 index cf0ee17bdf8..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_createorupdatebuilddatabaseconnection_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package staticsites - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateBuildDatabaseConnectionOperationResponse struct { - HttpResponse *http.Response - Model *DatabaseConnection -} - -// CreateOrUpdateBuildDatabaseConnection ... -func (c StaticSitesClient) CreateOrUpdateBuildDatabaseConnection(ctx context.Context, id BuildDatabaseConnectionId, input DatabaseConnection) (result CreateOrUpdateBuildDatabaseConnectionOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdateBuildDatabaseConnection(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "CreateOrUpdateBuildDatabaseConnection", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "CreateOrUpdateBuildDatabaseConnection", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdateBuildDatabaseConnection(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "CreateOrUpdateBuildDatabaseConnection", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdateBuildDatabaseConnection prepares the CreateOrUpdateBuildDatabaseConnection request. -func (c StaticSitesClient) preparerForCreateOrUpdateBuildDatabaseConnection(ctx context.Context, id BuildDatabaseConnectionId, input DatabaseConnection) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateOrUpdateBuildDatabaseConnection handles the response to the CreateOrUpdateBuildDatabaseConnection request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForCreateOrUpdateBuildDatabaseConnection(resp *http.Response) (result CreateOrUpdateBuildDatabaseConnectionOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_createorupdatedatabaseconnection.go b/resource-manager/web/2022-09-01/staticsites/method_createorupdatedatabaseconnection.go new file mode 100644 index 00000000000..863e651451f --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_createorupdatedatabaseconnection.go @@ -0,0 +1,55 @@ +package staticsites + +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 CreateOrUpdateDatabaseConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DatabaseConnection +} + +// CreateOrUpdateDatabaseConnection ... +func (c StaticSitesClient) CreateOrUpdateDatabaseConnection(ctx context.Context, id DatabaseConnectionId, input DatabaseConnection) (result CreateOrUpdateDatabaseConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_createorupdatedatabaseconnection_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_createorupdatedatabaseconnection_autorest.go deleted file mode 100644 index dcab76aa7f8..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_createorupdatedatabaseconnection_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package staticsites - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateDatabaseConnectionOperationResponse struct { - HttpResponse *http.Response - Model *DatabaseConnection -} - -// CreateOrUpdateDatabaseConnection ... -func (c StaticSitesClient) CreateOrUpdateDatabaseConnection(ctx context.Context, id DatabaseConnectionId, input DatabaseConnection) (result CreateOrUpdateDatabaseConnectionOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdateDatabaseConnection(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "CreateOrUpdateDatabaseConnection", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "CreateOrUpdateDatabaseConnection", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdateDatabaseConnection(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "CreateOrUpdateDatabaseConnection", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdateDatabaseConnection prepares the CreateOrUpdateDatabaseConnection request. -func (c StaticSitesClient) preparerForCreateOrUpdateDatabaseConnection(ctx context.Context, id DatabaseConnectionId, input DatabaseConnection) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateOrUpdateDatabaseConnection handles the response to the CreateOrUpdateDatabaseConnection request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForCreateOrUpdateDatabaseConnection(resp *http.Response) (result CreateOrUpdateDatabaseConnectionOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_createorupdatestaticsite.go b/resource-manager/web/2022-09-01/staticsites/method_createorupdatestaticsite.go new file mode 100644 index 00000000000..bd8630cc4e6 --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_createorupdatestaticsite.go @@ -0,0 +1,74 @@ +package staticsites + +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 CreateOrUpdateStaticSiteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// CreateOrUpdateStaticSite ... +func (c StaticSitesClient) CreateOrUpdateStaticSite(ctx context.Context, id StaticSiteId, input StaticSiteARMResource) (result CreateOrUpdateStaticSiteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// CreateOrUpdateStaticSiteThenPoll performs CreateOrUpdateStaticSite then polls until it's completed +func (c StaticSitesClient) CreateOrUpdateStaticSiteThenPoll(ctx context.Context, id StaticSiteId, input StaticSiteARMResource) error { + result, err := c.CreateOrUpdateStaticSite(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdateStaticSite: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdateStaticSite: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_createorupdatestaticsite_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_createorupdatestaticsite_autorest.go deleted file mode 100644 index be58430ec6b..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_createorupdatestaticsite_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package staticsites - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateStaticSiteOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateOrUpdateStaticSite ... -func (c StaticSitesClient) CreateOrUpdateStaticSite(ctx context.Context, id StaticSiteId, input StaticSiteARMResource) (result CreateOrUpdateStaticSiteOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdateStaticSite(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "CreateOrUpdateStaticSite", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdateStaticSite(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "CreateOrUpdateStaticSite", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateStaticSiteThenPoll performs CreateOrUpdateStaticSite then polls until it's completed -func (c StaticSitesClient) CreateOrUpdateStaticSiteThenPoll(ctx context.Context, id StaticSiteId, input StaticSiteARMResource) error { - result, err := c.CreateOrUpdateStaticSite(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateOrUpdateStaticSite: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateOrUpdateStaticSite: %+v", err) - } - - return nil -} - -// preparerForCreateOrUpdateStaticSite prepares the CreateOrUpdateStaticSite request. -func (c StaticSitesClient) preparerForCreateOrUpdateStaticSite(ctx context.Context, id StaticSiteId, input StaticSiteARMResource) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateOrUpdateStaticSite sends the CreateOrUpdateStaticSite request. The method will close the -// http.Response Body if it receives an error. -func (c StaticSitesClient) senderForCreateOrUpdateStaticSite(ctx context.Context, req *http.Request) (future CreateOrUpdateStaticSiteOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_createorupdatestaticsiteappsettings.go b/resource-manager/web/2022-09-01/staticsites/method_createorupdatestaticsiteappsettings.go new file mode 100644 index 00000000000..d26181f7adc --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_createorupdatestaticsiteappsettings.go @@ -0,0 +1,56 @@ +package staticsites + +import ( + "context" + "fmt" + "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 CreateOrUpdateStaticSiteAppSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// CreateOrUpdateStaticSiteAppSettings ... +func (c StaticSitesClient) CreateOrUpdateStaticSiteAppSettings(ctx context.Context, id StaticSiteId, input StringDictionary) (result CreateOrUpdateStaticSiteAppSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/appSettings", 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 +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_createorupdatestaticsiteappsettings_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_createorupdatestaticsiteappsettings_autorest.go deleted file mode 100644 index 05d943bc316..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_createorupdatestaticsiteappsettings_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package staticsites - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateStaticSiteAppSettingsOperationResponse struct { - HttpResponse *http.Response - Model *StringDictionary -} - -// CreateOrUpdateStaticSiteAppSettings ... -func (c StaticSitesClient) CreateOrUpdateStaticSiteAppSettings(ctx context.Context, id StaticSiteId, input StringDictionary) (result CreateOrUpdateStaticSiteAppSettingsOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdateStaticSiteAppSettings(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "CreateOrUpdateStaticSiteAppSettings", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "CreateOrUpdateStaticSiteAppSettings", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdateStaticSiteAppSettings(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "CreateOrUpdateStaticSiteAppSettings", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdateStaticSiteAppSettings prepares the CreateOrUpdateStaticSiteAppSettings request. -func (c StaticSitesClient) preparerForCreateOrUpdateStaticSiteAppSettings(ctx context.Context, id StaticSiteId, input StringDictionary) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/appSettings", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateOrUpdateStaticSiteAppSettings handles the response to the CreateOrUpdateStaticSiteAppSettings request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForCreateOrUpdateStaticSiteAppSettings(resp *http.Response) (result CreateOrUpdateStaticSiteAppSettingsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_createorupdatestaticsitebuildappsettings.go b/resource-manager/web/2022-09-01/staticsites/method_createorupdatestaticsitebuildappsettings.go new file mode 100644 index 00000000000..6ebeaae54a5 --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_createorupdatestaticsitebuildappsettings.go @@ -0,0 +1,56 @@ +package staticsites + +import ( + "context" + "fmt" + "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 CreateOrUpdateStaticSiteBuildAppSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// CreateOrUpdateStaticSiteBuildAppSettings ... +func (c StaticSitesClient) CreateOrUpdateStaticSiteBuildAppSettings(ctx context.Context, id BuildId, input StringDictionary) (result CreateOrUpdateStaticSiteBuildAppSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/appSettings", 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 +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_createorupdatestaticsitebuildappsettings_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_createorupdatestaticsitebuildappsettings_autorest.go deleted file mode 100644 index 64ecccdc3d7..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_createorupdatestaticsitebuildappsettings_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package staticsites - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateStaticSiteBuildAppSettingsOperationResponse struct { - HttpResponse *http.Response - Model *StringDictionary -} - -// CreateOrUpdateStaticSiteBuildAppSettings ... -func (c StaticSitesClient) CreateOrUpdateStaticSiteBuildAppSettings(ctx context.Context, id BuildId, input StringDictionary) (result CreateOrUpdateStaticSiteBuildAppSettingsOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdateStaticSiteBuildAppSettings(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "CreateOrUpdateStaticSiteBuildAppSettings", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "CreateOrUpdateStaticSiteBuildAppSettings", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdateStaticSiteBuildAppSettings(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "CreateOrUpdateStaticSiteBuildAppSettings", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdateStaticSiteBuildAppSettings prepares the CreateOrUpdateStaticSiteBuildAppSettings request. -func (c StaticSitesClient) preparerForCreateOrUpdateStaticSiteBuildAppSettings(ctx context.Context, id BuildId, input StringDictionary) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/appSettings", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateOrUpdateStaticSiteBuildAppSettings handles the response to the CreateOrUpdateStaticSiteBuildAppSettings request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForCreateOrUpdateStaticSiteBuildAppSettings(resp *http.Response) (result CreateOrUpdateStaticSiteBuildAppSettingsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_createorupdatestaticsitebuildfunctionappsettings.go b/resource-manager/web/2022-09-01/staticsites/method_createorupdatestaticsitebuildfunctionappsettings.go new file mode 100644 index 00000000000..c96d00cff42 --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_createorupdatestaticsitebuildfunctionappsettings.go @@ -0,0 +1,56 @@ +package staticsites + +import ( + "context" + "fmt" + "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 CreateOrUpdateStaticSiteBuildFunctionAppSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// CreateOrUpdateStaticSiteBuildFunctionAppSettings ... +func (c StaticSitesClient) CreateOrUpdateStaticSiteBuildFunctionAppSettings(ctx context.Context, id BuildId, input StringDictionary) (result CreateOrUpdateStaticSiteBuildFunctionAppSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/functionAppSettings", 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 +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_createorupdatestaticsitebuildfunctionappsettings_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_createorupdatestaticsitebuildfunctionappsettings_autorest.go deleted file mode 100644 index 83b8738ea28..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_createorupdatestaticsitebuildfunctionappsettings_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package staticsites - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateStaticSiteBuildFunctionAppSettingsOperationResponse struct { - HttpResponse *http.Response - Model *StringDictionary -} - -// CreateOrUpdateStaticSiteBuildFunctionAppSettings ... -func (c StaticSitesClient) CreateOrUpdateStaticSiteBuildFunctionAppSettings(ctx context.Context, id BuildId, input StringDictionary) (result CreateOrUpdateStaticSiteBuildFunctionAppSettingsOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdateStaticSiteBuildFunctionAppSettings(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "CreateOrUpdateStaticSiteBuildFunctionAppSettings", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "CreateOrUpdateStaticSiteBuildFunctionAppSettings", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdateStaticSiteBuildFunctionAppSettings(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "CreateOrUpdateStaticSiteBuildFunctionAppSettings", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdateStaticSiteBuildFunctionAppSettings prepares the CreateOrUpdateStaticSiteBuildFunctionAppSettings request. -func (c StaticSitesClient) preparerForCreateOrUpdateStaticSiteBuildFunctionAppSettings(ctx context.Context, id BuildId, input StringDictionary) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/functionAppSettings", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateOrUpdateStaticSiteBuildFunctionAppSettings handles the response to the CreateOrUpdateStaticSiteBuildFunctionAppSettings request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForCreateOrUpdateStaticSiteBuildFunctionAppSettings(resp *http.Response) (result CreateOrUpdateStaticSiteBuildFunctionAppSettingsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_createorupdatestaticsitecustomdomain.go b/resource-manager/web/2022-09-01/staticsites/method_createorupdatestaticsitecustomdomain.go new file mode 100644 index 00000000000..a03c037a165 --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_createorupdatestaticsitecustomdomain.go @@ -0,0 +1,74 @@ +package staticsites + +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 CreateOrUpdateStaticSiteCustomDomainOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// CreateOrUpdateStaticSiteCustomDomain ... +func (c StaticSitesClient) CreateOrUpdateStaticSiteCustomDomain(ctx context.Context, id CustomDomainId, input StaticSiteCustomDomainRequestPropertiesARMResource) (result CreateOrUpdateStaticSiteCustomDomainOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// CreateOrUpdateStaticSiteCustomDomainThenPoll performs CreateOrUpdateStaticSiteCustomDomain then polls until it's completed +func (c StaticSitesClient) CreateOrUpdateStaticSiteCustomDomainThenPoll(ctx context.Context, id CustomDomainId, input StaticSiteCustomDomainRequestPropertiesARMResource) error { + result, err := c.CreateOrUpdateStaticSiteCustomDomain(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdateStaticSiteCustomDomain: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdateStaticSiteCustomDomain: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_createorupdatestaticsitecustomdomain_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_createorupdatestaticsitecustomdomain_autorest.go deleted file mode 100644 index 6ea06d9632c..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_createorupdatestaticsitecustomdomain_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package staticsites - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateStaticSiteCustomDomainOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateOrUpdateStaticSiteCustomDomain ... -func (c StaticSitesClient) CreateOrUpdateStaticSiteCustomDomain(ctx context.Context, id CustomDomainId, input StaticSiteCustomDomainRequestPropertiesARMResource) (result CreateOrUpdateStaticSiteCustomDomainOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdateStaticSiteCustomDomain(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "CreateOrUpdateStaticSiteCustomDomain", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdateStaticSiteCustomDomain(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "CreateOrUpdateStaticSiteCustomDomain", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateStaticSiteCustomDomainThenPoll performs CreateOrUpdateStaticSiteCustomDomain then polls until it's completed -func (c StaticSitesClient) CreateOrUpdateStaticSiteCustomDomainThenPoll(ctx context.Context, id CustomDomainId, input StaticSiteCustomDomainRequestPropertiesARMResource) error { - result, err := c.CreateOrUpdateStaticSiteCustomDomain(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateOrUpdateStaticSiteCustomDomain: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateOrUpdateStaticSiteCustomDomain: %+v", err) - } - - return nil -} - -// preparerForCreateOrUpdateStaticSiteCustomDomain prepares the CreateOrUpdateStaticSiteCustomDomain request. -func (c StaticSitesClient) preparerForCreateOrUpdateStaticSiteCustomDomain(ctx context.Context, id CustomDomainId, input StaticSiteCustomDomainRequestPropertiesARMResource) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateOrUpdateStaticSiteCustomDomain sends the CreateOrUpdateStaticSiteCustomDomain request. The method will close the -// http.Response Body if it receives an error. -func (c StaticSitesClient) senderForCreateOrUpdateStaticSiteCustomDomain(ctx context.Context, req *http.Request) (future CreateOrUpdateStaticSiteCustomDomainOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_createorupdatestaticsitefunctionappsettings.go b/resource-manager/web/2022-09-01/staticsites/method_createorupdatestaticsitefunctionappsettings.go new file mode 100644 index 00000000000..dafc39eeeaa --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_createorupdatestaticsitefunctionappsettings.go @@ -0,0 +1,56 @@ +package staticsites + +import ( + "context" + "fmt" + "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 CreateOrUpdateStaticSiteFunctionAppSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// CreateOrUpdateStaticSiteFunctionAppSettings ... +func (c StaticSitesClient) CreateOrUpdateStaticSiteFunctionAppSettings(ctx context.Context, id StaticSiteId, input StringDictionary) (result CreateOrUpdateStaticSiteFunctionAppSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/functionAppSettings", 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 +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_createorupdatestaticsitefunctionappsettings_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_createorupdatestaticsitefunctionappsettings_autorest.go deleted file mode 100644 index 24351e6a679..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_createorupdatestaticsitefunctionappsettings_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package staticsites - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateStaticSiteFunctionAppSettingsOperationResponse struct { - HttpResponse *http.Response - Model *StringDictionary -} - -// CreateOrUpdateStaticSiteFunctionAppSettings ... -func (c StaticSitesClient) CreateOrUpdateStaticSiteFunctionAppSettings(ctx context.Context, id StaticSiteId, input StringDictionary) (result CreateOrUpdateStaticSiteFunctionAppSettingsOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdateStaticSiteFunctionAppSettings(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "CreateOrUpdateStaticSiteFunctionAppSettings", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "CreateOrUpdateStaticSiteFunctionAppSettings", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdateStaticSiteFunctionAppSettings(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "CreateOrUpdateStaticSiteFunctionAppSettings", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdateStaticSiteFunctionAppSettings prepares the CreateOrUpdateStaticSiteFunctionAppSettings request. -func (c StaticSitesClient) preparerForCreateOrUpdateStaticSiteFunctionAppSettings(ctx context.Context, id StaticSiteId, input StringDictionary) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/functionAppSettings", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateOrUpdateStaticSiteFunctionAppSettings handles the response to the CreateOrUpdateStaticSiteFunctionAppSettings request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForCreateOrUpdateStaticSiteFunctionAppSettings(resp *http.Response) (result CreateOrUpdateStaticSiteFunctionAppSettingsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_createuserrolesinvitationlink.go b/resource-manager/web/2022-09-01/staticsites/method_createuserrolesinvitationlink.go new file mode 100644 index 00000000000..92d3cc889ef --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_createuserrolesinvitationlink.go @@ -0,0 +1,56 @@ +package staticsites + +import ( + "context" + "fmt" + "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 CreateUserRolesInvitationLinkOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteUserInvitationResponseResource +} + +// CreateUserRolesInvitationLink ... +func (c StaticSitesClient) CreateUserRolesInvitationLink(ctx context.Context, id StaticSiteId, input StaticSiteUserInvitationRequestResource) (result CreateUserRolesInvitationLinkOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/createUserInvitation", 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 +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_createuserrolesinvitationlink_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_createuserrolesinvitationlink_autorest.go deleted file mode 100644 index 684bb1d78fd..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_createuserrolesinvitationlink_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package staticsites - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateUserRolesInvitationLinkOperationResponse struct { - HttpResponse *http.Response - Model *StaticSiteUserInvitationResponseResource -} - -// CreateUserRolesInvitationLink ... -func (c StaticSitesClient) CreateUserRolesInvitationLink(ctx context.Context, id StaticSiteId, input StaticSiteUserInvitationRequestResource) (result CreateUserRolesInvitationLinkOperationResponse, err error) { - req, err := c.preparerForCreateUserRolesInvitationLink(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "CreateUserRolesInvitationLink", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "CreateUserRolesInvitationLink", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateUserRolesInvitationLink(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "CreateUserRolesInvitationLink", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateUserRolesInvitationLink prepares the CreateUserRolesInvitationLink request. -func (c StaticSitesClient) preparerForCreateUserRolesInvitationLink(ctx context.Context, id StaticSiteId, input StaticSiteUserInvitationRequestResource) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/createUserInvitation", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateUserRolesInvitationLink handles the response to the CreateUserRolesInvitationLink request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForCreateUserRolesInvitationLink(resp *http.Response) (result CreateUserRolesInvitationLinkOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_createzipdeploymentforstaticsite.go b/resource-manager/web/2022-09-01/staticsites/method_createzipdeploymentforstaticsite.go new file mode 100644 index 00000000000..8678d9a2b3c --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_createzipdeploymentforstaticsite.go @@ -0,0 +1,74 @@ +package staticsites + +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 CreateZipDeploymentForStaticSiteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// CreateZipDeploymentForStaticSite ... +func (c StaticSitesClient) CreateZipDeploymentForStaticSite(ctx context.Context, id StaticSiteId, input StaticSiteZipDeploymentARMResource) (result CreateZipDeploymentForStaticSiteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/zipdeploy", 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 +} + +// CreateZipDeploymentForStaticSiteThenPoll performs CreateZipDeploymentForStaticSite then polls until it's completed +func (c StaticSitesClient) CreateZipDeploymentForStaticSiteThenPoll(ctx context.Context, id StaticSiteId, input StaticSiteZipDeploymentARMResource) error { + result, err := c.CreateZipDeploymentForStaticSite(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateZipDeploymentForStaticSite: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateZipDeploymentForStaticSite: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_createzipdeploymentforstaticsite_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_createzipdeploymentforstaticsite_autorest.go deleted file mode 100644 index 36a204d1f32..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_createzipdeploymentforstaticsite_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package staticsites - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateZipDeploymentForStaticSiteOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateZipDeploymentForStaticSite ... -func (c StaticSitesClient) CreateZipDeploymentForStaticSite(ctx context.Context, id StaticSiteId, input StaticSiteZipDeploymentARMResource) (result CreateZipDeploymentForStaticSiteOperationResponse, err error) { - req, err := c.preparerForCreateZipDeploymentForStaticSite(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "CreateZipDeploymentForStaticSite", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateZipDeploymentForStaticSite(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "CreateZipDeploymentForStaticSite", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateZipDeploymentForStaticSiteThenPoll performs CreateZipDeploymentForStaticSite then polls until it's completed -func (c StaticSitesClient) CreateZipDeploymentForStaticSiteThenPoll(ctx context.Context, id StaticSiteId, input StaticSiteZipDeploymentARMResource) error { - result, err := c.CreateZipDeploymentForStaticSite(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateZipDeploymentForStaticSite: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateZipDeploymentForStaticSite: %+v", err) - } - - return nil -} - -// preparerForCreateZipDeploymentForStaticSite prepares the CreateZipDeploymentForStaticSite request. -func (c StaticSitesClient) preparerForCreateZipDeploymentForStaticSite(ctx context.Context, id StaticSiteId, input StaticSiteZipDeploymentARMResource) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/zipdeploy", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateZipDeploymentForStaticSite sends the CreateZipDeploymentForStaticSite request. The method will close the -// http.Response Body if it receives an error. -func (c StaticSitesClient) senderForCreateZipDeploymentForStaticSite(ctx context.Context, req *http.Request) (future CreateZipDeploymentForStaticSiteOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_createzipdeploymentforstaticsitebuild.go b/resource-manager/web/2022-09-01/staticsites/method_createzipdeploymentforstaticsitebuild.go new file mode 100644 index 00000000000..c72e444e86b --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_createzipdeploymentforstaticsitebuild.go @@ -0,0 +1,74 @@ +package staticsites + +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 CreateZipDeploymentForStaticSiteBuildOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// CreateZipDeploymentForStaticSiteBuild ... +func (c StaticSitesClient) CreateZipDeploymentForStaticSiteBuild(ctx context.Context, id BuildId, input StaticSiteZipDeploymentARMResource) (result CreateZipDeploymentForStaticSiteBuildOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/zipdeploy", 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 +} + +// CreateZipDeploymentForStaticSiteBuildThenPoll performs CreateZipDeploymentForStaticSiteBuild then polls until it's completed +func (c StaticSitesClient) CreateZipDeploymentForStaticSiteBuildThenPoll(ctx context.Context, id BuildId, input StaticSiteZipDeploymentARMResource) error { + result, err := c.CreateZipDeploymentForStaticSiteBuild(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateZipDeploymentForStaticSiteBuild: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateZipDeploymentForStaticSiteBuild: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_createzipdeploymentforstaticsitebuild_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_createzipdeploymentforstaticsitebuild_autorest.go deleted file mode 100644 index bf1511cbc95..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_createzipdeploymentforstaticsitebuild_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package staticsites - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateZipDeploymentForStaticSiteBuildOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateZipDeploymentForStaticSiteBuild ... -func (c StaticSitesClient) CreateZipDeploymentForStaticSiteBuild(ctx context.Context, id BuildId, input StaticSiteZipDeploymentARMResource) (result CreateZipDeploymentForStaticSiteBuildOperationResponse, err error) { - req, err := c.preparerForCreateZipDeploymentForStaticSiteBuild(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "CreateZipDeploymentForStaticSiteBuild", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateZipDeploymentForStaticSiteBuild(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "CreateZipDeploymentForStaticSiteBuild", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateZipDeploymentForStaticSiteBuildThenPoll performs CreateZipDeploymentForStaticSiteBuild then polls until it's completed -func (c StaticSitesClient) CreateZipDeploymentForStaticSiteBuildThenPoll(ctx context.Context, id BuildId, input StaticSiteZipDeploymentARMResource) error { - result, err := c.CreateZipDeploymentForStaticSiteBuild(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateZipDeploymentForStaticSiteBuild: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateZipDeploymentForStaticSiteBuild: %+v", err) - } - - return nil -} - -// preparerForCreateZipDeploymentForStaticSiteBuild prepares the CreateZipDeploymentForStaticSiteBuild request. -func (c StaticSitesClient) preparerForCreateZipDeploymentForStaticSiteBuild(ctx context.Context, id BuildId, input StaticSiteZipDeploymentARMResource) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/zipdeploy", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateZipDeploymentForStaticSiteBuild sends the CreateZipDeploymentForStaticSiteBuild request. The method will close the -// http.Response Body if it receives an error. -func (c StaticSitesClient) senderForCreateZipDeploymentForStaticSiteBuild(ctx context.Context, req *http.Request) (future CreateZipDeploymentForStaticSiteBuildOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_deletebuilddatabaseconnection.go b/resource-manager/web/2022-09-01/staticsites/method_deletebuilddatabaseconnection.go new file mode 100644 index 00000000000..62fc3a1bb43 --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_deletebuilddatabaseconnection.go @@ -0,0 +1,47 @@ +package staticsites + +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 DeleteBuildDatabaseConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteBuildDatabaseConnection ... +func (c StaticSitesClient) DeleteBuildDatabaseConnection(ctx context.Context, id BuildDatabaseConnectionId) (result DeleteBuildDatabaseConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_deletebuilddatabaseconnection_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_deletebuilddatabaseconnection_autorest.go deleted file mode 100644 index d69f34225e4..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_deletebuilddatabaseconnection_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package staticsites - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteBuildDatabaseConnectionOperationResponse struct { - HttpResponse *http.Response -} - -// DeleteBuildDatabaseConnection ... -func (c StaticSitesClient) DeleteBuildDatabaseConnection(ctx context.Context, id BuildDatabaseConnectionId) (result DeleteBuildDatabaseConnectionOperationResponse, err error) { - req, err := c.preparerForDeleteBuildDatabaseConnection(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "DeleteBuildDatabaseConnection", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "DeleteBuildDatabaseConnection", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeleteBuildDatabaseConnection(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "DeleteBuildDatabaseConnection", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeleteBuildDatabaseConnection prepares the DeleteBuildDatabaseConnection request. -func (c StaticSitesClient) preparerForDeleteBuildDatabaseConnection(ctx context.Context, id BuildDatabaseConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeleteBuildDatabaseConnection handles the response to the DeleteBuildDatabaseConnection request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForDeleteBuildDatabaseConnection(resp *http.Response) (result DeleteBuildDatabaseConnectionOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_deletedatabaseconnection.go b/resource-manager/web/2022-09-01/staticsites/method_deletedatabaseconnection.go new file mode 100644 index 00000000000..fed1ac013b3 --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_deletedatabaseconnection.go @@ -0,0 +1,47 @@ +package staticsites + +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 DeleteDatabaseConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteDatabaseConnection ... +func (c StaticSitesClient) DeleteDatabaseConnection(ctx context.Context, id DatabaseConnectionId) (result DeleteDatabaseConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_deletedatabaseconnection_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_deletedatabaseconnection_autorest.go deleted file mode 100644 index c18759ac916..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_deletedatabaseconnection_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package staticsites - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteDatabaseConnectionOperationResponse struct { - HttpResponse *http.Response -} - -// DeleteDatabaseConnection ... -func (c StaticSitesClient) DeleteDatabaseConnection(ctx context.Context, id DatabaseConnectionId) (result DeleteDatabaseConnectionOperationResponse, err error) { - req, err := c.preparerForDeleteDatabaseConnection(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "DeleteDatabaseConnection", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "DeleteDatabaseConnection", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeleteDatabaseConnection(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "DeleteDatabaseConnection", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeleteDatabaseConnection prepares the DeleteDatabaseConnection request. -func (c StaticSitesClient) preparerForDeleteDatabaseConnection(ctx context.Context, id DatabaseConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeleteDatabaseConnection handles the response to the DeleteDatabaseConnection request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForDeleteDatabaseConnection(resp *http.Response) (result DeleteDatabaseConnectionOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_deleteprivateendpointconnection.go b/resource-manager/web/2022-09-01/staticsites/method_deleteprivateendpointconnection.go new file mode 100644 index 00000000000..13868f95109 --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_deleteprivateendpointconnection.go @@ -0,0 +1,71 @@ +package staticsites + +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 DeletePrivateEndpointConnectionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// DeletePrivateEndpointConnection ... +func (c StaticSitesClient) DeletePrivateEndpointConnection(ctx context.Context, id StaticSitePrivateEndpointConnectionId) (result DeletePrivateEndpointConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 +} + +// DeletePrivateEndpointConnectionThenPoll performs DeletePrivateEndpointConnection then polls until it's completed +func (c StaticSitesClient) DeletePrivateEndpointConnectionThenPoll(ctx context.Context, id StaticSitePrivateEndpointConnectionId) error { + result, err := c.DeletePrivateEndpointConnection(ctx, id) + if err != nil { + return fmt.Errorf("performing DeletePrivateEndpointConnection: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DeletePrivateEndpointConnection: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_deleteprivateendpointconnection_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_deleteprivateendpointconnection_autorest.go deleted file mode 100644 index 3a650d2a8ba..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_deleteprivateendpointconnection_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package staticsites - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeletePrivateEndpointConnectionOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// DeletePrivateEndpointConnection ... -func (c StaticSitesClient) DeletePrivateEndpointConnection(ctx context.Context, id StaticSitePrivateEndpointConnectionId) (result DeletePrivateEndpointConnectionOperationResponse, err error) { - req, err := c.preparerForDeletePrivateEndpointConnection(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "DeletePrivateEndpointConnection", nil, "Failure preparing request") - return - } - - result, err = c.senderForDeletePrivateEndpointConnection(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "DeletePrivateEndpointConnection", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeletePrivateEndpointConnectionThenPoll performs DeletePrivateEndpointConnection then polls until it's completed -func (c StaticSitesClient) DeletePrivateEndpointConnectionThenPoll(ctx context.Context, id StaticSitePrivateEndpointConnectionId) error { - result, err := c.DeletePrivateEndpointConnection(ctx, id) - if err != nil { - return fmt.Errorf("performing DeletePrivateEndpointConnection: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after DeletePrivateEndpointConnection: %+v", err) - } - - return nil -} - -// preparerForDeletePrivateEndpointConnection prepares the DeletePrivateEndpointConnection request. -func (c StaticSitesClient) preparerForDeletePrivateEndpointConnection(ctx context.Context, id StaticSitePrivateEndpointConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDeletePrivateEndpointConnection sends the DeletePrivateEndpointConnection request. The method will close the -// http.Response Body if it receives an error. -func (c StaticSitesClient) senderForDeletePrivateEndpointConnection(ctx context.Context, req *http.Request) (future DeletePrivateEndpointConnectionOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_deletestaticsite.go b/resource-manager/web/2022-09-01/staticsites/method_deletestaticsite.go new file mode 100644 index 00000000000..3b445e902e2 --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_deletestaticsite.go @@ -0,0 +1,70 @@ +package staticsites + +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 DeleteStaticSiteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteStaticSite ... +func (c StaticSitesClient) DeleteStaticSite(ctx context.Context, id StaticSiteId) (result DeleteStaticSiteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// DeleteStaticSiteThenPoll performs DeleteStaticSite then polls until it's completed +func (c StaticSitesClient) DeleteStaticSiteThenPoll(ctx context.Context, id StaticSiteId) error { + result, err := c.DeleteStaticSite(ctx, id) + if err != nil { + return fmt.Errorf("performing DeleteStaticSite: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DeleteStaticSite: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_deletestaticsite_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_deletestaticsite_autorest.go deleted file mode 100644 index 22c9bff9302..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_deletestaticsite_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package staticsites - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteStaticSiteOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// DeleteStaticSite ... -func (c StaticSitesClient) DeleteStaticSite(ctx context.Context, id StaticSiteId) (result DeleteStaticSiteOperationResponse, err error) { - req, err := c.preparerForDeleteStaticSite(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "DeleteStaticSite", nil, "Failure preparing request") - return - } - - result, err = c.senderForDeleteStaticSite(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "DeleteStaticSite", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteStaticSiteThenPoll performs DeleteStaticSite then polls until it's completed -func (c StaticSitesClient) DeleteStaticSiteThenPoll(ctx context.Context, id StaticSiteId) error { - result, err := c.DeleteStaticSite(ctx, id) - if err != nil { - return fmt.Errorf("performing DeleteStaticSite: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after DeleteStaticSite: %+v", err) - } - - return nil -} - -// preparerForDeleteStaticSite prepares the DeleteStaticSite request. -func (c StaticSitesClient) preparerForDeleteStaticSite(ctx context.Context, id StaticSiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDeleteStaticSite sends the DeleteStaticSite request. The method will close the -// http.Response Body if it receives an error. -func (c StaticSitesClient) senderForDeleteStaticSite(ctx context.Context, req *http.Request) (future DeleteStaticSiteOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_deletestaticsitebuild.go b/resource-manager/web/2022-09-01/staticsites/method_deletestaticsitebuild.go new file mode 100644 index 00000000000..4e530140061 --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_deletestaticsitebuild.go @@ -0,0 +1,71 @@ +package staticsites + +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 DeleteStaticSiteBuildOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteStaticSiteBuild ... +func (c StaticSitesClient) DeleteStaticSiteBuild(ctx context.Context, id BuildId) (result DeleteStaticSiteBuildOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 +} + +// DeleteStaticSiteBuildThenPoll performs DeleteStaticSiteBuild then polls until it's completed +func (c StaticSitesClient) DeleteStaticSiteBuildThenPoll(ctx context.Context, id BuildId) error { + result, err := c.DeleteStaticSiteBuild(ctx, id) + if err != nil { + return fmt.Errorf("performing DeleteStaticSiteBuild: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DeleteStaticSiteBuild: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_deletestaticsitebuild_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_deletestaticsitebuild_autorest.go deleted file mode 100644 index 60e9e365f58..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_deletestaticsitebuild_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package staticsites - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteStaticSiteBuildOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// DeleteStaticSiteBuild ... -func (c StaticSitesClient) DeleteStaticSiteBuild(ctx context.Context, id BuildId) (result DeleteStaticSiteBuildOperationResponse, err error) { - req, err := c.preparerForDeleteStaticSiteBuild(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "DeleteStaticSiteBuild", nil, "Failure preparing request") - return - } - - result, err = c.senderForDeleteStaticSiteBuild(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "DeleteStaticSiteBuild", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteStaticSiteBuildThenPoll performs DeleteStaticSiteBuild then polls until it's completed -func (c StaticSitesClient) DeleteStaticSiteBuildThenPoll(ctx context.Context, id BuildId) error { - result, err := c.DeleteStaticSiteBuild(ctx, id) - if err != nil { - return fmt.Errorf("performing DeleteStaticSiteBuild: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after DeleteStaticSiteBuild: %+v", err) - } - - return nil -} - -// preparerForDeleteStaticSiteBuild prepares the DeleteStaticSiteBuild request. -func (c StaticSitesClient) preparerForDeleteStaticSiteBuild(ctx context.Context, id BuildId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDeleteStaticSiteBuild sends the DeleteStaticSiteBuild request. The method will close the -// http.Response Body if it receives an error. -func (c StaticSitesClient) senderForDeleteStaticSiteBuild(ctx context.Context, req *http.Request) (future DeleteStaticSiteBuildOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_deletestaticsitecustomdomain.go b/resource-manager/web/2022-09-01/staticsites/method_deletestaticsitecustomdomain.go new file mode 100644 index 00000000000..4b6678463a7 --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_deletestaticsitecustomdomain.go @@ -0,0 +1,70 @@ +package staticsites + +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 DeleteStaticSiteCustomDomainOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteStaticSiteCustomDomain ... +func (c StaticSitesClient) DeleteStaticSiteCustomDomain(ctx context.Context, id CustomDomainId) (result DeleteStaticSiteCustomDomainOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// DeleteStaticSiteCustomDomainThenPoll performs DeleteStaticSiteCustomDomain then polls until it's completed +func (c StaticSitesClient) DeleteStaticSiteCustomDomainThenPoll(ctx context.Context, id CustomDomainId) error { + result, err := c.DeleteStaticSiteCustomDomain(ctx, id) + if err != nil { + return fmt.Errorf("performing DeleteStaticSiteCustomDomain: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DeleteStaticSiteCustomDomain: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_deletestaticsitecustomdomain_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_deletestaticsitecustomdomain_autorest.go deleted file mode 100644 index cb943958190..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_deletestaticsitecustomdomain_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package staticsites - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteStaticSiteCustomDomainOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// DeleteStaticSiteCustomDomain ... -func (c StaticSitesClient) DeleteStaticSiteCustomDomain(ctx context.Context, id CustomDomainId) (result DeleteStaticSiteCustomDomainOperationResponse, err error) { - req, err := c.preparerForDeleteStaticSiteCustomDomain(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "DeleteStaticSiteCustomDomain", nil, "Failure preparing request") - return - } - - result, err = c.senderForDeleteStaticSiteCustomDomain(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "DeleteStaticSiteCustomDomain", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeleteStaticSiteCustomDomainThenPoll performs DeleteStaticSiteCustomDomain then polls until it's completed -func (c StaticSitesClient) DeleteStaticSiteCustomDomainThenPoll(ctx context.Context, id CustomDomainId) error { - result, err := c.DeleteStaticSiteCustomDomain(ctx, id) - if err != nil { - return fmt.Errorf("performing DeleteStaticSiteCustomDomain: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after DeleteStaticSiteCustomDomain: %+v", err) - } - - return nil -} - -// preparerForDeleteStaticSiteCustomDomain prepares the DeleteStaticSiteCustomDomain request. -func (c StaticSitesClient) preparerForDeleteStaticSiteCustomDomain(ctx context.Context, id CustomDomainId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDeleteStaticSiteCustomDomain sends the DeleteStaticSiteCustomDomain request. The method will close the -// http.Response Body if it receives an error. -func (c StaticSitesClient) senderForDeleteStaticSiteCustomDomain(ctx context.Context, req *http.Request) (future DeleteStaticSiteCustomDomainOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_deletestaticsiteuser.go b/resource-manager/web/2022-09-01/staticsites/method_deletestaticsiteuser.go new file mode 100644 index 00000000000..39185d56c81 --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_deletestaticsiteuser.go @@ -0,0 +1,46 @@ +package staticsites + +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 DeleteStaticSiteUserOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteStaticSiteUser ... +func (c StaticSitesClient) DeleteStaticSiteUser(ctx context.Context, id UserId) (result DeleteStaticSiteUserOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_deletestaticsiteuser_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_deletestaticsiteuser_autorest.go deleted file mode 100644 index 48bd231b5da..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_deletestaticsiteuser_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package staticsites - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteStaticSiteUserOperationResponse struct { - HttpResponse *http.Response -} - -// DeleteStaticSiteUser ... -func (c StaticSitesClient) DeleteStaticSiteUser(ctx context.Context, id UserId) (result DeleteStaticSiteUserOperationResponse, err error) { - req, err := c.preparerForDeleteStaticSiteUser(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "DeleteStaticSiteUser", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "DeleteStaticSiteUser", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeleteStaticSiteUser(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "DeleteStaticSiteUser", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeleteStaticSiteUser prepares the DeleteStaticSiteUser request. -func (c StaticSitesClient) preparerForDeleteStaticSiteUser(ctx context.Context, id UserId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeleteStaticSiteUser handles the response to the DeleteStaticSiteUser request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForDeleteStaticSiteUser(resp *http.Response) (result DeleteStaticSiteUserOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_detachstaticsite.go b/resource-manager/web/2022-09-01/staticsites/method_detachstaticsite.go new file mode 100644 index 00000000000..0cdcbd90ee2 --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_detachstaticsite.go @@ -0,0 +1,70 @@ +package staticsites + +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 DetachStaticSiteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// DetachStaticSite ... +func (c StaticSitesClient) DetachStaticSite(ctx context.Context, id StaticSiteId) (result DetachStaticSiteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/detach", 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 +} + +// DetachStaticSiteThenPoll performs DetachStaticSite then polls until it's completed +func (c StaticSitesClient) DetachStaticSiteThenPoll(ctx context.Context, id StaticSiteId) error { + result, err := c.DetachStaticSite(ctx, id) + if err != nil { + return fmt.Errorf("performing DetachStaticSite: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DetachStaticSite: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_detachstaticsite_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_detachstaticsite_autorest.go deleted file mode 100644 index 6a73e959850..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_detachstaticsite_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package staticsites - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DetachStaticSiteOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// DetachStaticSite ... -func (c StaticSitesClient) DetachStaticSite(ctx context.Context, id StaticSiteId) (result DetachStaticSiteOperationResponse, err error) { - req, err := c.preparerForDetachStaticSite(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "DetachStaticSite", nil, "Failure preparing request") - return - } - - result, err = c.senderForDetachStaticSite(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "DetachStaticSite", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DetachStaticSiteThenPoll performs DetachStaticSite then polls until it's completed -func (c StaticSitesClient) DetachStaticSiteThenPoll(ctx context.Context, id StaticSiteId) error { - result, err := c.DetachStaticSite(ctx, id) - if err != nil { - return fmt.Errorf("performing DetachStaticSite: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after DetachStaticSite: %+v", err) - } - - return nil -} - -// preparerForDetachStaticSite prepares the DetachStaticSite request. -func (c StaticSitesClient) preparerForDetachStaticSite(ctx context.Context, id StaticSiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/detach", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDetachStaticSite sends the DetachStaticSite request. The method will close the -// http.Response Body if it receives an error. -func (c StaticSitesClient) senderForDetachStaticSite(ctx context.Context, req *http.Request) (future DetachStaticSiteOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_detachuserprovidedfunctionappfromstaticsite.go b/resource-manager/web/2022-09-01/staticsites/method_detachuserprovidedfunctionappfromstaticsite.go new file mode 100644 index 00000000000..f84480b1bf0 --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_detachuserprovidedfunctionappfromstaticsite.go @@ -0,0 +1,47 @@ +package staticsites + +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 DetachUserProvidedFunctionAppFromStaticSiteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DetachUserProvidedFunctionAppFromStaticSite ... +func (c StaticSitesClient) DetachUserProvidedFunctionAppFromStaticSite(ctx context.Context, id UserProvidedFunctionAppId) (result DetachUserProvidedFunctionAppFromStaticSiteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_detachuserprovidedfunctionappfromstaticsite_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_detachuserprovidedfunctionappfromstaticsite_autorest.go deleted file mode 100644 index 65fc98a2fee..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_detachuserprovidedfunctionappfromstaticsite_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package staticsites - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DetachUserProvidedFunctionAppFromStaticSiteOperationResponse struct { - HttpResponse *http.Response -} - -// DetachUserProvidedFunctionAppFromStaticSite ... -func (c StaticSitesClient) DetachUserProvidedFunctionAppFromStaticSite(ctx context.Context, id UserProvidedFunctionAppId) (result DetachUserProvidedFunctionAppFromStaticSiteOperationResponse, err error) { - req, err := c.preparerForDetachUserProvidedFunctionAppFromStaticSite(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "DetachUserProvidedFunctionAppFromStaticSite", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "DetachUserProvidedFunctionAppFromStaticSite", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDetachUserProvidedFunctionAppFromStaticSite(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "DetachUserProvidedFunctionAppFromStaticSite", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDetachUserProvidedFunctionAppFromStaticSite prepares the DetachUserProvidedFunctionAppFromStaticSite request. -func (c StaticSitesClient) preparerForDetachUserProvidedFunctionAppFromStaticSite(ctx context.Context, id UserProvidedFunctionAppId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDetachUserProvidedFunctionAppFromStaticSite handles the response to the DetachUserProvidedFunctionAppFromStaticSite request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForDetachUserProvidedFunctionAppFromStaticSite(resp *http.Response) (result DetachUserProvidedFunctionAppFromStaticSiteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_detachuserprovidedfunctionappfromstaticsitebuild.go b/resource-manager/web/2022-09-01/staticsites/method_detachuserprovidedfunctionappfromstaticsitebuild.go new file mode 100644 index 00000000000..ca0040c5bb7 --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_detachuserprovidedfunctionappfromstaticsitebuild.go @@ -0,0 +1,47 @@ +package staticsites + +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 DetachUserProvidedFunctionAppFromStaticSiteBuildOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DetachUserProvidedFunctionAppFromStaticSiteBuild ... +func (c StaticSitesClient) DetachUserProvidedFunctionAppFromStaticSiteBuild(ctx context.Context, id BuildUserProvidedFunctionAppId) (result DetachUserProvidedFunctionAppFromStaticSiteBuildOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_detachuserprovidedfunctionappfromstaticsitebuild_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_detachuserprovidedfunctionappfromstaticsitebuild_autorest.go deleted file mode 100644 index b08e63652e3..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_detachuserprovidedfunctionappfromstaticsitebuild_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package staticsites - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DetachUserProvidedFunctionAppFromStaticSiteBuildOperationResponse struct { - HttpResponse *http.Response -} - -// DetachUserProvidedFunctionAppFromStaticSiteBuild ... -func (c StaticSitesClient) DetachUserProvidedFunctionAppFromStaticSiteBuild(ctx context.Context, id BuildUserProvidedFunctionAppId) (result DetachUserProvidedFunctionAppFromStaticSiteBuildOperationResponse, err error) { - req, err := c.preparerForDetachUserProvidedFunctionAppFromStaticSiteBuild(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "DetachUserProvidedFunctionAppFromStaticSiteBuild", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "DetachUserProvidedFunctionAppFromStaticSiteBuild", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDetachUserProvidedFunctionAppFromStaticSiteBuild(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "DetachUserProvidedFunctionAppFromStaticSiteBuild", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDetachUserProvidedFunctionAppFromStaticSiteBuild prepares the DetachUserProvidedFunctionAppFromStaticSiteBuild request. -func (c StaticSitesClient) preparerForDetachUserProvidedFunctionAppFromStaticSiteBuild(ctx context.Context, id BuildUserProvidedFunctionAppId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDetachUserProvidedFunctionAppFromStaticSiteBuild handles the response to the DetachUserProvidedFunctionAppFromStaticSiteBuild request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForDetachUserProvidedFunctionAppFromStaticSiteBuild(resp *http.Response) (result DetachUserProvidedFunctionAppFromStaticSiteBuildOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_getbasicauth.go b/resource-manager/web/2022-09-01/staticsites/method_getbasicauth.go new file mode 100644 index 00000000000..65e711aea58 --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_getbasicauth.go @@ -0,0 +1,52 @@ +package staticsites + +import ( + "context" + "fmt" + "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 GetBasicAuthOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteBasicAuthPropertiesARMResource +} + +// GetBasicAuth ... +func (c StaticSitesClient) GetBasicAuth(ctx context.Context, id StaticSiteId) (result GetBasicAuthOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/basicAuth/default", 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 +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_getbasicauth_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_getbasicauth_autorest.go deleted file mode 100644 index 0e27b21336a..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_getbasicauth_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package staticsites - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetBasicAuthOperationResponse struct { - HttpResponse *http.Response - Model *StaticSiteBasicAuthPropertiesARMResource -} - -// GetBasicAuth ... -func (c StaticSitesClient) GetBasicAuth(ctx context.Context, id StaticSiteId) (result GetBasicAuthOperationResponse, err error) { - req, err := c.preparerForGetBasicAuth(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetBasicAuth", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetBasicAuth", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetBasicAuth(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetBasicAuth", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetBasicAuth prepares the GetBasicAuth request. -func (c StaticSitesClient) preparerForGetBasicAuth(ctx context.Context, id StaticSiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/basicAuth/default", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetBasicAuth handles the response to the GetBasicAuth request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForGetBasicAuth(resp *http.Response) (result GetBasicAuthOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_getbuilddatabaseconnection.go b/resource-manager/web/2022-09-01/staticsites/method_getbuilddatabaseconnection.go new file mode 100644 index 00000000000..3a99286c5ca --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_getbuilddatabaseconnection.go @@ -0,0 +1,51 @@ +package staticsites + +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 GetBuildDatabaseConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DatabaseConnection +} + +// GetBuildDatabaseConnection ... +func (c StaticSitesClient) GetBuildDatabaseConnection(ctx context.Context, id BuildDatabaseConnectionId) (result GetBuildDatabaseConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_getbuilddatabaseconnection_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_getbuilddatabaseconnection_autorest.go deleted file mode 100644 index a7298b5c926..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_getbuilddatabaseconnection_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package staticsites - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetBuildDatabaseConnectionOperationResponse struct { - HttpResponse *http.Response - Model *DatabaseConnection -} - -// GetBuildDatabaseConnection ... -func (c StaticSitesClient) GetBuildDatabaseConnection(ctx context.Context, id BuildDatabaseConnectionId) (result GetBuildDatabaseConnectionOperationResponse, err error) { - req, err := c.preparerForGetBuildDatabaseConnection(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetBuildDatabaseConnection", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetBuildDatabaseConnection", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetBuildDatabaseConnection(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetBuildDatabaseConnection", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetBuildDatabaseConnection prepares the GetBuildDatabaseConnection request. -func (c StaticSitesClient) preparerForGetBuildDatabaseConnection(ctx context.Context, id BuildDatabaseConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetBuildDatabaseConnection handles the response to the GetBuildDatabaseConnection request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForGetBuildDatabaseConnection(resp *http.Response) (result GetBuildDatabaseConnectionOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_getbuilddatabaseconnections.go b/resource-manager/web/2022-09-01/staticsites/method_getbuilddatabaseconnections.go new file mode 100644 index 00000000000..668ae2c7308 --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_getbuilddatabaseconnections.go @@ -0,0 +1,89 @@ +package staticsites + +import ( + "context" + "fmt" + "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 GetBuildDatabaseConnectionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DatabaseConnection +} + +type GetBuildDatabaseConnectionsCompleteResult struct { + Items []DatabaseConnection +} + +// GetBuildDatabaseConnections ... +func (c StaticSitesClient) GetBuildDatabaseConnections(ctx context.Context, id BuildId) (result GetBuildDatabaseConnectionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/databaseConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]DatabaseConnection `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetBuildDatabaseConnectionsComplete retrieves all the results into a single object +func (c StaticSitesClient) GetBuildDatabaseConnectionsComplete(ctx context.Context, id BuildId) (GetBuildDatabaseConnectionsCompleteResult, error) { + return c.GetBuildDatabaseConnectionsCompleteMatchingPredicate(ctx, id, DatabaseConnectionOperationPredicate{}) +} + +// GetBuildDatabaseConnectionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) GetBuildDatabaseConnectionsCompleteMatchingPredicate(ctx context.Context, id BuildId, predicate DatabaseConnectionOperationPredicate) (result GetBuildDatabaseConnectionsCompleteResult, err error) { + items := make([]DatabaseConnection, 0) + + resp, err := c.GetBuildDatabaseConnections(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetBuildDatabaseConnectionsCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_getbuilddatabaseconnections_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_getbuilddatabaseconnections_autorest.go deleted file mode 100644 index 8cfdccde03a..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_getbuilddatabaseconnections_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package staticsites - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetBuildDatabaseConnectionsOperationResponse struct { - HttpResponse *http.Response - Model *[]DatabaseConnection - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (GetBuildDatabaseConnectionsOperationResponse, error) -} - -type GetBuildDatabaseConnectionsCompleteResult struct { - Items []DatabaseConnection -} - -func (r GetBuildDatabaseConnectionsOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r GetBuildDatabaseConnectionsOperationResponse) LoadMore(ctx context.Context) (resp GetBuildDatabaseConnectionsOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// GetBuildDatabaseConnections ... -func (c StaticSitesClient) GetBuildDatabaseConnections(ctx context.Context, id BuildId) (resp GetBuildDatabaseConnectionsOperationResponse, err error) { - req, err := c.preparerForGetBuildDatabaseConnections(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetBuildDatabaseConnections", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetBuildDatabaseConnections", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForGetBuildDatabaseConnections(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetBuildDatabaseConnections", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForGetBuildDatabaseConnections prepares the GetBuildDatabaseConnections request. -func (c StaticSitesClient) preparerForGetBuildDatabaseConnections(ctx context.Context, id BuildId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/databaseConnections", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForGetBuildDatabaseConnectionsWithNextLink prepares the GetBuildDatabaseConnections request with the given nextLink token. -func (c StaticSitesClient) preparerForGetBuildDatabaseConnectionsWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetBuildDatabaseConnections handles the response to the GetBuildDatabaseConnections request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForGetBuildDatabaseConnections(resp *http.Response) (result GetBuildDatabaseConnectionsOperationResponse, err error) { - type page struct { - Values []DatabaseConnection `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result GetBuildDatabaseConnectionsOperationResponse, err error) { - req, err := c.preparerForGetBuildDatabaseConnectionsWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetBuildDatabaseConnections", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetBuildDatabaseConnections", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetBuildDatabaseConnections(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetBuildDatabaseConnections", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// GetBuildDatabaseConnectionsComplete retrieves all of the results into a single object -func (c StaticSitesClient) GetBuildDatabaseConnectionsComplete(ctx context.Context, id BuildId) (GetBuildDatabaseConnectionsCompleteResult, error) { - return c.GetBuildDatabaseConnectionsCompleteMatchingPredicate(ctx, id, DatabaseConnectionOperationPredicate{}) -} - -// GetBuildDatabaseConnectionsCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c StaticSitesClient) GetBuildDatabaseConnectionsCompleteMatchingPredicate(ctx context.Context, id BuildId, predicate DatabaseConnectionOperationPredicate) (resp GetBuildDatabaseConnectionsCompleteResult, err error) { - items := make([]DatabaseConnection, 0) - - page, err := c.GetBuildDatabaseConnections(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := GetBuildDatabaseConnectionsCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_getbuilddatabaseconnectionswithdetails.go b/resource-manager/web/2022-09-01/staticsites/method_getbuilddatabaseconnectionswithdetails.go new file mode 100644 index 00000000000..7a4cbe6182f --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_getbuilddatabaseconnectionswithdetails.go @@ -0,0 +1,89 @@ +package staticsites + +import ( + "context" + "fmt" + "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 GetBuildDatabaseConnectionsWithDetailsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DatabaseConnection +} + +type GetBuildDatabaseConnectionsWithDetailsCompleteResult struct { + Items []DatabaseConnection +} + +// GetBuildDatabaseConnectionsWithDetails ... +func (c StaticSitesClient) GetBuildDatabaseConnectionsWithDetails(ctx context.Context, id BuildId) (result GetBuildDatabaseConnectionsWithDetailsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/showDatabaseConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]DatabaseConnection `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetBuildDatabaseConnectionsWithDetailsComplete retrieves all the results into a single object +func (c StaticSitesClient) GetBuildDatabaseConnectionsWithDetailsComplete(ctx context.Context, id BuildId) (GetBuildDatabaseConnectionsWithDetailsCompleteResult, error) { + return c.GetBuildDatabaseConnectionsWithDetailsCompleteMatchingPredicate(ctx, id, DatabaseConnectionOperationPredicate{}) +} + +// GetBuildDatabaseConnectionsWithDetailsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) GetBuildDatabaseConnectionsWithDetailsCompleteMatchingPredicate(ctx context.Context, id BuildId, predicate DatabaseConnectionOperationPredicate) (result GetBuildDatabaseConnectionsWithDetailsCompleteResult, err error) { + items := make([]DatabaseConnection, 0) + + resp, err := c.GetBuildDatabaseConnectionsWithDetails(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetBuildDatabaseConnectionsWithDetailsCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_getbuilddatabaseconnectionswithdetails_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_getbuilddatabaseconnectionswithdetails_autorest.go deleted file mode 100644 index f408b25048e..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_getbuilddatabaseconnectionswithdetails_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package staticsites - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetBuildDatabaseConnectionsWithDetailsOperationResponse struct { - HttpResponse *http.Response - Model *[]DatabaseConnection - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (GetBuildDatabaseConnectionsWithDetailsOperationResponse, error) -} - -type GetBuildDatabaseConnectionsWithDetailsCompleteResult struct { - Items []DatabaseConnection -} - -func (r GetBuildDatabaseConnectionsWithDetailsOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r GetBuildDatabaseConnectionsWithDetailsOperationResponse) LoadMore(ctx context.Context) (resp GetBuildDatabaseConnectionsWithDetailsOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// GetBuildDatabaseConnectionsWithDetails ... -func (c StaticSitesClient) GetBuildDatabaseConnectionsWithDetails(ctx context.Context, id BuildId) (resp GetBuildDatabaseConnectionsWithDetailsOperationResponse, err error) { - req, err := c.preparerForGetBuildDatabaseConnectionsWithDetails(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetBuildDatabaseConnectionsWithDetails", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetBuildDatabaseConnectionsWithDetails", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForGetBuildDatabaseConnectionsWithDetails(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetBuildDatabaseConnectionsWithDetails", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForGetBuildDatabaseConnectionsWithDetails prepares the GetBuildDatabaseConnectionsWithDetails request. -func (c StaticSitesClient) preparerForGetBuildDatabaseConnectionsWithDetails(ctx context.Context, id BuildId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/showDatabaseConnections", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForGetBuildDatabaseConnectionsWithDetailsWithNextLink prepares the GetBuildDatabaseConnectionsWithDetails request with the given nextLink token. -func (c StaticSitesClient) preparerForGetBuildDatabaseConnectionsWithDetailsWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetBuildDatabaseConnectionsWithDetails handles the response to the GetBuildDatabaseConnectionsWithDetails request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForGetBuildDatabaseConnectionsWithDetails(resp *http.Response) (result GetBuildDatabaseConnectionsWithDetailsOperationResponse, err error) { - type page struct { - Values []DatabaseConnection `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result GetBuildDatabaseConnectionsWithDetailsOperationResponse, err error) { - req, err := c.preparerForGetBuildDatabaseConnectionsWithDetailsWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetBuildDatabaseConnectionsWithDetails", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetBuildDatabaseConnectionsWithDetails", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetBuildDatabaseConnectionsWithDetails(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetBuildDatabaseConnectionsWithDetails", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// GetBuildDatabaseConnectionsWithDetailsComplete retrieves all of the results into a single object -func (c StaticSitesClient) GetBuildDatabaseConnectionsWithDetailsComplete(ctx context.Context, id BuildId) (GetBuildDatabaseConnectionsWithDetailsCompleteResult, error) { - return c.GetBuildDatabaseConnectionsWithDetailsCompleteMatchingPredicate(ctx, id, DatabaseConnectionOperationPredicate{}) -} - -// GetBuildDatabaseConnectionsWithDetailsCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c StaticSitesClient) GetBuildDatabaseConnectionsWithDetailsCompleteMatchingPredicate(ctx context.Context, id BuildId, predicate DatabaseConnectionOperationPredicate) (resp GetBuildDatabaseConnectionsWithDetailsCompleteResult, err error) { - items := make([]DatabaseConnection, 0) - - page, err := c.GetBuildDatabaseConnectionsWithDetails(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := GetBuildDatabaseConnectionsWithDetailsCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_getbuilddatabaseconnectionwithdetails.go b/resource-manager/web/2022-09-01/staticsites/method_getbuilddatabaseconnectionwithdetails.go new file mode 100644 index 00000000000..e58e67fd2be --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_getbuilddatabaseconnectionwithdetails.go @@ -0,0 +1,52 @@ +package staticsites + +import ( + "context" + "fmt" + "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 GetBuildDatabaseConnectionWithDetailsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DatabaseConnection +} + +// GetBuildDatabaseConnectionWithDetails ... +func (c StaticSitesClient) GetBuildDatabaseConnectionWithDetails(ctx context.Context, id BuildDatabaseConnectionId) (result GetBuildDatabaseConnectionWithDetailsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/show", 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 +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_getbuilddatabaseconnectionwithdetails_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_getbuilddatabaseconnectionwithdetails_autorest.go deleted file mode 100644 index 4e7ab94845d..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_getbuilddatabaseconnectionwithdetails_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package staticsites - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetBuildDatabaseConnectionWithDetailsOperationResponse struct { - HttpResponse *http.Response - Model *DatabaseConnection -} - -// GetBuildDatabaseConnectionWithDetails ... -func (c StaticSitesClient) GetBuildDatabaseConnectionWithDetails(ctx context.Context, id BuildDatabaseConnectionId) (result GetBuildDatabaseConnectionWithDetailsOperationResponse, err error) { - req, err := c.preparerForGetBuildDatabaseConnectionWithDetails(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetBuildDatabaseConnectionWithDetails", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetBuildDatabaseConnectionWithDetails", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetBuildDatabaseConnectionWithDetails(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetBuildDatabaseConnectionWithDetails", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetBuildDatabaseConnectionWithDetails prepares the GetBuildDatabaseConnectionWithDetails request. -func (c StaticSitesClient) preparerForGetBuildDatabaseConnectionWithDetails(ctx context.Context, id BuildDatabaseConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/show", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetBuildDatabaseConnectionWithDetails handles the response to the GetBuildDatabaseConnectionWithDetails request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForGetBuildDatabaseConnectionWithDetails(resp *http.Response) (result GetBuildDatabaseConnectionWithDetailsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_getdatabaseconnection.go b/resource-manager/web/2022-09-01/staticsites/method_getdatabaseconnection.go new file mode 100644 index 00000000000..ff13048b296 --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_getdatabaseconnection.go @@ -0,0 +1,51 @@ +package staticsites + +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 GetDatabaseConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DatabaseConnection +} + +// GetDatabaseConnection ... +func (c StaticSitesClient) GetDatabaseConnection(ctx context.Context, id DatabaseConnectionId) (result GetDatabaseConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_getdatabaseconnection_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_getdatabaseconnection_autorest.go deleted file mode 100644 index 8f36aae9d02..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_getdatabaseconnection_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package staticsites - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetDatabaseConnectionOperationResponse struct { - HttpResponse *http.Response - Model *DatabaseConnection -} - -// GetDatabaseConnection ... -func (c StaticSitesClient) GetDatabaseConnection(ctx context.Context, id DatabaseConnectionId) (result GetDatabaseConnectionOperationResponse, err error) { - req, err := c.preparerForGetDatabaseConnection(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetDatabaseConnection", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetDatabaseConnection", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetDatabaseConnection(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetDatabaseConnection", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetDatabaseConnection prepares the GetDatabaseConnection request. -func (c StaticSitesClient) preparerForGetDatabaseConnection(ctx context.Context, id DatabaseConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetDatabaseConnection handles the response to the GetDatabaseConnection request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForGetDatabaseConnection(resp *http.Response) (result GetDatabaseConnectionOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_getdatabaseconnections.go b/resource-manager/web/2022-09-01/staticsites/method_getdatabaseconnections.go new file mode 100644 index 00000000000..2ec2901de94 --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_getdatabaseconnections.go @@ -0,0 +1,89 @@ +package staticsites + +import ( + "context" + "fmt" + "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 GetDatabaseConnectionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DatabaseConnection +} + +type GetDatabaseConnectionsCompleteResult struct { + Items []DatabaseConnection +} + +// GetDatabaseConnections ... +func (c StaticSitesClient) GetDatabaseConnections(ctx context.Context, id StaticSiteId) (result GetDatabaseConnectionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/databaseConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]DatabaseConnection `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetDatabaseConnectionsComplete retrieves all the results into a single object +func (c StaticSitesClient) GetDatabaseConnectionsComplete(ctx context.Context, id StaticSiteId) (GetDatabaseConnectionsCompleteResult, error) { + return c.GetDatabaseConnectionsCompleteMatchingPredicate(ctx, id, DatabaseConnectionOperationPredicate{}) +} + +// GetDatabaseConnectionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) GetDatabaseConnectionsCompleteMatchingPredicate(ctx context.Context, id StaticSiteId, predicate DatabaseConnectionOperationPredicate) (result GetDatabaseConnectionsCompleteResult, err error) { + items := make([]DatabaseConnection, 0) + + resp, err := c.GetDatabaseConnections(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetDatabaseConnectionsCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_getdatabaseconnections_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_getdatabaseconnections_autorest.go deleted file mode 100644 index 313c2adbb1b..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_getdatabaseconnections_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package staticsites - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetDatabaseConnectionsOperationResponse struct { - HttpResponse *http.Response - Model *[]DatabaseConnection - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (GetDatabaseConnectionsOperationResponse, error) -} - -type GetDatabaseConnectionsCompleteResult struct { - Items []DatabaseConnection -} - -func (r GetDatabaseConnectionsOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r GetDatabaseConnectionsOperationResponse) LoadMore(ctx context.Context) (resp GetDatabaseConnectionsOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// GetDatabaseConnections ... -func (c StaticSitesClient) GetDatabaseConnections(ctx context.Context, id StaticSiteId) (resp GetDatabaseConnectionsOperationResponse, err error) { - req, err := c.preparerForGetDatabaseConnections(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetDatabaseConnections", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetDatabaseConnections", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForGetDatabaseConnections(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetDatabaseConnections", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForGetDatabaseConnections prepares the GetDatabaseConnections request. -func (c StaticSitesClient) preparerForGetDatabaseConnections(ctx context.Context, id StaticSiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/databaseConnections", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForGetDatabaseConnectionsWithNextLink prepares the GetDatabaseConnections request with the given nextLink token. -func (c StaticSitesClient) preparerForGetDatabaseConnectionsWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetDatabaseConnections handles the response to the GetDatabaseConnections request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForGetDatabaseConnections(resp *http.Response) (result GetDatabaseConnectionsOperationResponse, err error) { - type page struct { - Values []DatabaseConnection `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result GetDatabaseConnectionsOperationResponse, err error) { - req, err := c.preparerForGetDatabaseConnectionsWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetDatabaseConnections", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetDatabaseConnections", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetDatabaseConnections(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetDatabaseConnections", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// GetDatabaseConnectionsComplete retrieves all of the results into a single object -func (c StaticSitesClient) GetDatabaseConnectionsComplete(ctx context.Context, id StaticSiteId) (GetDatabaseConnectionsCompleteResult, error) { - return c.GetDatabaseConnectionsCompleteMatchingPredicate(ctx, id, DatabaseConnectionOperationPredicate{}) -} - -// GetDatabaseConnectionsCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c StaticSitesClient) GetDatabaseConnectionsCompleteMatchingPredicate(ctx context.Context, id StaticSiteId, predicate DatabaseConnectionOperationPredicate) (resp GetDatabaseConnectionsCompleteResult, err error) { - items := make([]DatabaseConnection, 0) - - page, err := c.GetDatabaseConnections(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := GetDatabaseConnectionsCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_getdatabaseconnectionswithdetails.go b/resource-manager/web/2022-09-01/staticsites/method_getdatabaseconnectionswithdetails.go new file mode 100644 index 00000000000..700b21825d1 --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_getdatabaseconnectionswithdetails.go @@ -0,0 +1,89 @@ +package staticsites + +import ( + "context" + "fmt" + "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 GetDatabaseConnectionsWithDetailsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DatabaseConnection +} + +type GetDatabaseConnectionsWithDetailsCompleteResult struct { + Items []DatabaseConnection +} + +// GetDatabaseConnectionsWithDetails ... +func (c StaticSitesClient) GetDatabaseConnectionsWithDetails(ctx context.Context, id StaticSiteId) (result GetDatabaseConnectionsWithDetailsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/showDatabaseConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]DatabaseConnection `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetDatabaseConnectionsWithDetailsComplete retrieves all the results into a single object +func (c StaticSitesClient) GetDatabaseConnectionsWithDetailsComplete(ctx context.Context, id StaticSiteId) (GetDatabaseConnectionsWithDetailsCompleteResult, error) { + return c.GetDatabaseConnectionsWithDetailsCompleteMatchingPredicate(ctx, id, DatabaseConnectionOperationPredicate{}) +} + +// GetDatabaseConnectionsWithDetailsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) GetDatabaseConnectionsWithDetailsCompleteMatchingPredicate(ctx context.Context, id StaticSiteId, predicate DatabaseConnectionOperationPredicate) (result GetDatabaseConnectionsWithDetailsCompleteResult, err error) { + items := make([]DatabaseConnection, 0) + + resp, err := c.GetDatabaseConnectionsWithDetails(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetDatabaseConnectionsWithDetailsCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_getdatabaseconnectionswithdetails_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_getdatabaseconnectionswithdetails_autorest.go deleted file mode 100644 index 42d5f888820..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_getdatabaseconnectionswithdetails_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package staticsites - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetDatabaseConnectionsWithDetailsOperationResponse struct { - HttpResponse *http.Response - Model *[]DatabaseConnection - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (GetDatabaseConnectionsWithDetailsOperationResponse, error) -} - -type GetDatabaseConnectionsWithDetailsCompleteResult struct { - Items []DatabaseConnection -} - -func (r GetDatabaseConnectionsWithDetailsOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r GetDatabaseConnectionsWithDetailsOperationResponse) LoadMore(ctx context.Context) (resp GetDatabaseConnectionsWithDetailsOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// GetDatabaseConnectionsWithDetails ... -func (c StaticSitesClient) GetDatabaseConnectionsWithDetails(ctx context.Context, id StaticSiteId) (resp GetDatabaseConnectionsWithDetailsOperationResponse, err error) { - req, err := c.preparerForGetDatabaseConnectionsWithDetails(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetDatabaseConnectionsWithDetails", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetDatabaseConnectionsWithDetails", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForGetDatabaseConnectionsWithDetails(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetDatabaseConnectionsWithDetails", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForGetDatabaseConnectionsWithDetails prepares the GetDatabaseConnectionsWithDetails request. -func (c StaticSitesClient) preparerForGetDatabaseConnectionsWithDetails(ctx context.Context, id StaticSiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/showDatabaseConnections", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForGetDatabaseConnectionsWithDetailsWithNextLink prepares the GetDatabaseConnectionsWithDetails request with the given nextLink token. -func (c StaticSitesClient) preparerForGetDatabaseConnectionsWithDetailsWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetDatabaseConnectionsWithDetails handles the response to the GetDatabaseConnectionsWithDetails request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForGetDatabaseConnectionsWithDetails(resp *http.Response) (result GetDatabaseConnectionsWithDetailsOperationResponse, err error) { - type page struct { - Values []DatabaseConnection `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result GetDatabaseConnectionsWithDetailsOperationResponse, err error) { - req, err := c.preparerForGetDatabaseConnectionsWithDetailsWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetDatabaseConnectionsWithDetails", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetDatabaseConnectionsWithDetails", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetDatabaseConnectionsWithDetails(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetDatabaseConnectionsWithDetails", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// GetDatabaseConnectionsWithDetailsComplete retrieves all of the results into a single object -func (c StaticSitesClient) GetDatabaseConnectionsWithDetailsComplete(ctx context.Context, id StaticSiteId) (GetDatabaseConnectionsWithDetailsCompleteResult, error) { - return c.GetDatabaseConnectionsWithDetailsCompleteMatchingPredicate(ctx, id, DatabaseConnectionOperationPredicate{}) -} - -// GetDatabaseConnectionsWithDetailsCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c StaticSitesClient) GetDatabaseConnectionsWithDetailsCompleteMatchingPredicate(ctx context.Context, id StaticSiteId, predicate DatabaseConnectionOperationPredicate) (resp GetDatabaseConnectionsWithDetailsCompleteResult, err error) { - items := make([]DatabaseConnection, 0) - - page, err := c.GetDatabaseConnectionsWithDetails(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := GetDatabaseConnectionsWithDetailsCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_getdatabaseconnectionwithdetails.go b/resource-manager/web/2022-09-01/staticsites/method_getdatabaseconnectionwithdetails.go new file mode 100644 index 00000000000..f122d826f2b --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_getdatabaseconnectionwithdetails.go @@ -0,0 +1,52 @@ +package staticsites + +import ( + "context" + "fmt" + "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 GetDatabaseConnectionWithDetailsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DatabaseConnection +} + +// GetDatabaseConnectionWithDetails ... +func (c StaticSitesClient) GetDatabaseConnectionWithDetails(ctx context.Context, id DatabaseConnectionId) (result GetDatabaseConnectionWithDetailsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/show", 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 +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_getdatabaseconnectionwithdetails_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_getdatabaseconnectionwithdetails_autorest.go deleted file mode 100644 index 8764c497a80..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_getdatabaseconnectionwithdetails_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package staticsites - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetDatabaseConnectionWithDetailsOperationResponse struct { - HttpResponse *http.Response - Model *DatabaseConnection -} - -// GetDatabaseConnectionWithDetails ... -func (c StaticSitesClient) GetDatabaseConnectionWithDetails(ctx context.Context, id DatabaseConnectionId) (result GetDatabaseConnectionWithDetailsOperationResponse, err error) { - req, err := c.preparerForGetDatabaseConnectionWithDetails(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetDatabaseConnectionWithDetails", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetDatabaseConnectionWithDetails", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetDatabaseConnectionWithDetails(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetDatabaseConnectionWithDetails", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetDatabaseConnectionWithDetails prepares the GetDatabaseConnectionWithDetails request. -func (c StaticSitesClient) preparerForGetDatabaseConnectionWithDetails(ctx context.Context, id DatabaseConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/show", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetDatabaseConnectionWithDetails handles the response to the GetDatabaseConnectionWithDetails request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForGetDatabaseConnectionWithDetails(resp *http.Response) (result GetDatabaseConnectionWithDetailsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_getlinkedbackend.go b/resource-manager/web/2022-09-01/staticsites/method_getlinkedbackend.go new file mode 100644 index 00000000000..1c186290872 --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_getlinkedbackend.go @@ -0,0 +1,51 @@ +package staticsites + +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 GetLinkedBackendOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteLinkedBackendARMResource +} + +// GetLinkedBackend ... +func (c StaticSitesClient) GetLinkedBackend(ctx context.Context, id LinkedBackendId) (result GetLinkedBackendOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_getlinkedbackend_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_getlinkedbackend_autorest.go deleted file mode 100644 index b84d8087bf7..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_getlinkedbackend_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package staticsites - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetLinkedBackendOperationResponse struct { - HttpResponse *http.Response - Model *StaticSiteLinkedBackendARMResource -} - -// GetLinkedBackend ... -func (c StaticSitesClient) GetLinkedBackend(ctx context.Context, id LinkedBackendId) (result GetLinkedBackendOperationResponse, err error) { - req, err := c.preparerForGetLinkedBackend(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetLinkedBackend", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetLinkedBackend", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetLinkedBackend(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetLinkedBackend", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetLinkedBackend prepares the GetLinkedBackend request. -func (c StaticSitesClient) preparerForGetLinkedBackend(ctx context.Context, id LinkedBackendId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetLinkedBackend handles the response to the GetLinkedBackend request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForGetLinkedBackend(resp *http.Response) (result GetLinkedBackendOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_getlinkedbackendforbuild.go b/resource-manager/web/2022-09-01/staticsites/method_getlinkedbackendforbuild.go new file mode 100644 index 00000000000..4052ed2d676 --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_getlinkedbackendforbuild.go @@ -0,0 +1,51 @@ +package staticsites + +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 GetLinkedBackendForBuildOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteLinkedBackendARMResource +} + +// GetLinkedBackendForBuild ... +func (c StaticSitesClient) GetLinkedBackendForBuild(ctx context.Context, id BuildLinkedBackendId) (result GetLinkedBackendForBuildOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_getlinkedbackendforbuild_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_getlinkedbackendforbuild_autorest.go deleted file mode 100644 index 80ecb69c0dc..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_getlinkedbackendforbuild_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package staticsites - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetLinkedBackendForBuildOperationResponse struct { - HttpResponse *http.Response - Model *StaticSiteLinkedBackendARMResource -} - -// GetLinkedBackendForBuild ... -func (c StaticSitesClient) GetLinkedBackendForBuild(ctx context.Context, id BuildLinkedBackendId) (result GetLinkedBackendForBuildOperationResponse, err error) { - req, err := c.preparerForGetLinkedBackendForBuild(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetLinkedBackendForBuild", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetLinkedBackendForBuild", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetLinkedBackendForBuild(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetLinkedBackendForBuild", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetLinkedBackendForBuild prepares the GetLinkedBackendForBuild request. -func (c StaticSitesClient) preparerForGetLinkedBackendForBuild(ctx context.Context, id BuildLinkedBackendId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetLinkedBackendForBuild handles the response to the GetLinkedBackendForBuild request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForGetLinkedBackendForBuild(resp *http.Response) (result GetLinkedBackendForBuildOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_getlinkedbackends.go b/resource-manager/web/2022-09-01/staticsites/method_getlinkedbackends.go new file mode 100644 index 00000000000..b5072109348 --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_getlinkedbackends.go @@ -0,0 +1,89 @@ +package staticsites + +import ( + "context" + "fmt" + "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 GetLinkedBackendsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StaticSiteLinkedBackendARMResource +} + +type GetLinkedBackendsCompleteResult struct { + Items []StaticSiteLinkedBackendARMResource +} + +// GetLinkedBackends ... +func (c StaticSitesClient) GetLinkedBackends(ctx context.Context, id StaticSiteId) (result GetLinkedBackendsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/linkedBackends", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]StaticSiteLinkedBackendARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetLinkedBackendsComplete retrieves all the results into a single object +func (c StaticSitesClient) GetLinkedBackendsComplete(ctx context.Context, id StaticSiteId) (GetLinkedBackendsCompleteResult, error) { + return c.GetLinkedBackendsCompleteMatchingPredicate(ctx, id, StaticSiteLinkedBackendARMResourceOperationPredicate{}) +} + +// GetLinkedBackendsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) GetLinkedBackendsCompleteMatchingPredicate(ctx context.Context, id StaticSiteId, predicate StaticSiteLinkedBackendARMResourceOperationPredicate) (result GetLinkedBackendsCompleteResult, err error) { + items := make([]StaticSiteLinkedBackendARMResource, 0) + + resp, err := c.GetLinkedBackends(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetLinkedBackendsCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_getlinkedbackends_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_getlinkedbackends_autorest.go deleted file mode 100644 index b5de7e17d60..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_getlinkedbackends_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package staticsites - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetLinkedBackendsOperationResponse struct { - HttpResponse *http.Response - Model *[]StaticSiteLinkedBackendARMResource - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (GetLinkedBackendsOperationResponse, error) -} - -type GetLinkedBackendsCompleteResult struct { - Items []StaticSiteLinkedBackendARMResource -} - -func (r GetLinkedBackendsOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r GetLinkedBackendsOperationResponse) LoadMore(ctx context.Context) (resp GetLinkedBackendsOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// GetLinkedBackends ... -func (c StaticSitesClient) GetLinkedBackends(ctx context.Context, id StaticSiteId) (resp GetLinkedBackendsOperationResponse, err error) { - req, err := c.preparerForGetLinkedBackends(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetLinkedBackends", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetLinkedBackends", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForGetLinkedBackends(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetLinkedBackends", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForGetLinkedBackends prepares the GetLinkedBackends request. -func (c StaticSitesClient) preparerForGetLinkedBackends(ctx context.Context, id StaticSiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/linkedBackends", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForGetLinkedBackendsWithNextLink prepares the GetLinkedBackends request with the given nextLink token. -func (c StaticSitesClient) preparerForGetLinkedBackendsWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetLinkedBackends handles the response to the GetLinkedBackends request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForGetLinkedBackends(resp *http.Response) (result GetLinkedBackendsOperationResponse, err error) { - type page struct { - Values []StaticSiteLinkedBackendARMResource `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result GetLinkedBackendsOperationResponse, err error) { - req, err := c.preparerForGetLinkedBackendsWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetLinkedBackends", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetLinkedBackends", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetLinkedBackends(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetLinkedBackends", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// GetLinkedBackendsComplete retrieves all of the results into a single object -func (c StaticSitesClient) GetLinkedBackendsComplete(ctx context.Context, id StaticSiteId) (GetLinkedBackendsCompleteResult, error) { - return c.GetLinkedBackendsCompleteMatchingPredicate(ctx, id, StaticSiteLinkedBackendARMResourceOperationPredicate{}) -} - -// GetLinkedBackendsCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c StaticSitesClient) GetLinkedBackendsCompleteMatchingPredicate(ctx context.Context, id StaticSiteId, predicate StaticSiteLinkedBackendARMResourceOperationPredicate) (resp GetLinkedBackendsCompleteResult, err error) { - items := make([]StaticSiteLinkedBackendARMResource, 0) - - page, err := c.GetLinkedBackends(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := GetLinkedBackendsCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_getlinkedbackendsforbuild.go b/resource-manager/web/2022-09-01/staticsites/method_getlinkedbackendsforbuild.go new file mode 100644 index 00000000000..be100c81c24 --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_getlinkedbackendsforbuild.go @@ -0,0 +1,89 @@ +package staticsites + +import ( + "context" + "fmt" + "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 GetLinkedBackendsForBuildOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StaticSiteLinkedBackendARMResource +} + +type GetLinkedBackendsForBuildCompleteResult struct { + Items []StaticSiteLinkedBackendARMResource +} + +// GetLinkedBackendsForBuild ... +func (c StaticSitesClient) GetLinkedBackendsForBuild(ctx context.Context, id BuildId) (result GetLinkedBackendsForBuildOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/linkedBackends", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]StaticSiteLinkedBackendARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetLinkedBackendsForBuildComplete retrieves all the results into a single object +func (c StaticSitesClient) GetLinkedBackendsForBuildComplete(ctx context.Context, id BuildId) (GetLinkedBackendsForBuildCompleteResult, error) { + return c.GetLinkedBackendsForBuildCompleteMatchingPredicate(ctx, id, StaticSiteLinkedBackendARMResourceOperationPredicate{}) +} + +// GetLinkedBackendsForBuildCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) GetLinkedBackendsForBuildCompleteMatchingPredicate(ctx context.Context, id BuildId, predicate StaticSiteLinkedBackendARMResourceOperationPredicate) (result GetLinkedBackendsForBuildCompleteResult, err error) { + items := make([]StaticSiteLinkedBackendARMResource, 0) + + resp, err := c.GetLinkedBackendsForBuild(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetLinkedBackendsForBuildCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_getlinkedbackendsforbuild_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_getlinkedbackendsforbuild_autorest.go deleted file mode 100644 index 7f3438e3505..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_getlinkedbackendsforbuild_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package staticsites - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetLinkedBackendsForBuildOperationResponse struct { - HttpResponse *http.Response - Model *[]StaticSiteLinkedBackendARMResource - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (GetLinkedBackendsForBuildOperationResponse, error) -} - -type GetLinkedBackendsForBuildCompleteResult struct { - Items []StaticSiteLinkedBackendARMResource -} - -func (r GetLinkedBackendsForBuildOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r GetLinkedBackendsForBuildOperationResponse) LoadMore(ctx context.Context) (resp GetLinkedBackendsForBuildOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// GetLinkedBackendsForBuild ... -func (c StaticSitesClient) GetLinkedBackendsForBuild(ctx context.Context, id BuildId) (resp GetLinkedBackendsForBuildOperationResponse, err error) { - req, err := c.preparerForGetLinkedBackendsForBuild(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetLinkedBackendsForBuild", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetLinkedBackendsForBuild", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForGetLinkedBackendsForBuild(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetLinkedBackendsForBuild", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForGetLinkedBackendsForBuild prepares the GetLinkedBackendsForBuild request. -func (c StaticSitesClient) preparerForGetLinkedBackendsForBuild(ctx context.Context, id BuildId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/linkedBackends", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForGetLinkedBackendsForBuildWithNextLink prepares the GetLinkedBackendsForBuild request with the given nextLink token. -func (c StaticSitesClient) preparerForGetLinkedBackendsForBuildWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetLinkedBackendsForBuild handles the response to the GetLinkedBackendsForBuild request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForGetLinkedBackendsForBuild(resp *http.Response) (result GetLinkedBackendsForBuildOperationResponse, err error) { - type page struct { - Values []StaticSiteLinkedBackendARMResource `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result GetLinkedBackendsForBuildOperationResponse, err error) { - req, err := c.preparerForGetLinkedBackendsForBuildWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetLinkedBackendsForBuild", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetLinkedBackendsForBuild", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetLinkedBackendsForBuild(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetLinkedBackendsForBuild", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// GetLinkedBackendsForBuildComplete retrieves all of the results into a single object -func (c StaticSitesClient) GetLinkedBackendsForBuildComplete(ctx context.Context, id BuildId) (GetLinkedBackendsForBuildCompleteResult, error) { - return c.GetLinkedBackendsForBuildCompleteMatchingPredicate(ctx, id, StaticSiteLinkedBackendARMResourceOperationPredicate{}) -} - -// GetLinkedBackendsForBuildCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c StaticSitesClient) GetLinkedBackendsForBuildCompleteMatchingPredicate(ctx context.Context, id BuildId, predicate StaticSiteLinkedBackendARMResourceOperationPredicate) (resp GetLinkedBackendsForBuildCompleteResult, err error) { - items := make([]StaticSiteLinkedBackendARMResource, 0) - - page, err := c.GetLinkedBackendsForBuild(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := GetLinkedBackendsForBuildCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_getprivateendpointconnection.go b/resource-manager/web/2022-09-01/staticsites/method_getprivateendpointconnection.go new file mode 100644 index 00000000000..9358fa54ef1 --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_getprivateendpointconnection.go @@ -0,0 +1,51 @@ +package staticsites + +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 GetPrivateEndpointConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RemotePrivateEndpointConnectionARMResource +} + +// GetPrivateEndpointConnection ... +func (c StaticSitesClient) GetPrivateEndpointConnection(ctx context.Context, id StaticSitePrivateEndpointConnectionId) (result GetPrivateEndpointConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_getprivateendpointconnection_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_getprivateendpointconnection_autorest.go deleted file mode 100644 index 91c43fca518..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_getprivateendpointconnection_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package staticsites - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetPrivateEndpointConnectionOperationResponse struct { - HttpResponse *http.Response - Model *RemotePrivateEndpointConnectionARMResource -} - -// GetPrivateEndpointConnection ... -func (c StaticSitesClient) GetPrivateEndpointConnection(ctx context.Context, id StaticSitePrivateEndpointConnectionId) (result GetPrivateEndpointConnectionOperationResponse, err error) { - req, err := c.preparerForGetPrivateEndpointConnection(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetPrivateEndpointConnection", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetPrivateEndpointConnection", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetPrivateEndpointConnection(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetPrivateEndpointConnection", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetPrivateEndpointConnection prepares the GetPrivateEndpointConnection request. -func (c StaticSitesClient) preparerForGetPrivateEndpointConnection(ctx context.Context, id StaticSitePrivateEndpointConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetPrivateEndpointConnection handles the response to the GetPrivateEndpointConnection request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForGetPrivateEndpointConnection(resp *http.Response) (result GetPrivateEndpointConnectionOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_getprivateendpointconnectionlist.go b/resource-manager/web/2022-09-01/staticsites/method_getprivateendpointconnectionlist.go new file mode 100644 index 00000000000..b463ae51acc --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_getprivateendpointconnectionlist.go @@ -0,0 +1,89 @@ +package staticsites + +import ( + "context" + "fmt" + "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 GetPrivateEndpointConnectionListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RemotePrivateEndpointConnectionARMResource +} + +type GetPrivateEndpointConnectionListCompleteResult struct { + Items []RemotePrivateEndpointConnectionARMResource +} + +// GetPrivateEndpointConnectionList ... +func (c StaticSitesClient) GetPrivateEndpointConnectionList(ctx context.Context, id StaticSiteId) (result GetPrivateEndpointConnectionListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateEndpointConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]RemotePrivateEndpointConnectionARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetPrivateEndpointConnectionListComplete retrieves all the results into a single object +func (c StaticSitesClient) GetPrivateEndpointConnectionListComplete(ctx context.Context, id StaticSiteId) (GetPrivateEndpointConnectionListCompleteResult, error) { + return c.GetPrivateEndpointConnectionListCompleteMatchingPredicate(ctx, id, RemotePrivateEndpointConnectionARMResourceOperationPredicate{}) +} + +// GetPrivateEndpointConnectionListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) GetPrivateEndpointConnectionListCompleteMatchingPredicate(ctx context.Context, id StaticSiteId, predicate RemotePrivateEndpointConnectionARMResourceOperationPredicate) (result GetPrivateEndpointConnectionListCompleteResult, err error) { + items := make([]RemotePrivateEndpointConnectionARMResource, 0) + + resp, err := c.GetPrivateEndpointConnectionList(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetPrivateEndpointConnectionListCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_getprivateendpointconnectionlist_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_getprivateendpointconnectionlist_autorest.go deleted file mode 100644 index a8253f88388..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_getprivateendpointconnectionlist_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package staticsites - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetPrivateEndpointConnectionListOperationResponse struct { - HttpResponse *http.Response - Model *[]RemotePrivateEndpointConnectionARMResource - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (GetPrivateEndpointConnectionListOperationResponse, error) -} - -type GetPrivateEndpointConnectionListCompleteResult struct { - Items []RemotePrivateEndpointConnectionARMResource -} - -func (r GetPrivateEndpointConnectionListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r GetPrivateEndpointConnectionListOperationResponse) LoadMore(ctx context.Context) (resp GetPrivateEndpointConnectionListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// GetPrivateEndpointConnectionList ... -func (c StaticSitesClient) GetPrivateEndpointConnectionList(ctx context.Context, id StaticSiteId) (resp GetPrivateEndpointConnectionListOperationResponse, err error) { - req, err := c.preparerForGetPrivateEndpointConnectionList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetPrivateEndpointConnectionList", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetPrivateEndpointConnectionList", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForGetPrivateEndpointConnectionList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetPrivateEndpointConnectionList", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForGetPrivateEndpointConnectionList prepares the GetPrivateEndpointConnectionList request. -func (c StaticSitesClient) preparerForGetPrivateEndpointConnectionList(ctx context.Context, id StaticSiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/privateEndpointConnections", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForGetPrivateEndpointConnectionListWithNextLink prepares the GetPrivateEndpointConnectionList request with the given nextLink token. -func (c StaticSitesClient) preparerForGetPrivateEndpointConnectionListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetPrivateEndpointConnectionList handles the response to the GetPrivateEndpointConnectionList request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForGetPrivateEndpointConnectionList(resp *http.Response) (result GetPrivateEndpointConnectionListOperationResponse, err error) { - type page struct { - Values []RemotePrivateEndpointConnectionARMResource `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result GetPrivateEndpointConnectionListOperationResponse, err error) { - req, err := c.preparerForGetPrivateEndpointConnectionListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetPrivateEndpointConnectionList", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetPrivateEndpointConnectionList", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetPrivateEndpointConnectionList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetPrivateEndpointConnectionList", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// GetPrivateEndpointConnectionListComplete retrieves all of the results into a single object -func (c StaticSitesClient) GetPrivateEndpointConnectionListComplete(ctx context.Context, id StaticSiteId) (GetPrivateEndpointConnectionListCompleteResult, error) { - return c.GetPrivateEndpointConnectionListCompleteMatchingPredicate(ctx, id, RemotePrivateEndpointConnectionARMResourceOperationPredicate{}) -} - -// GetPrivateEndpointConnectionListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c StaticSitesClient) GetPrivateEndpointConnectionListCompleteMatchingPredicate(ctx context.Context, id StaticSiteId, predicate RemotePrivateEndpointConnectionARMResourceOperationPredicate) (resp GetPrivateEndpointConnectionListCompleteResult, err error) { - items := make([]RemotePrivateEndpointConnectionARMResource, 0) - - page, err := c.GetPrivateEndpointConnectionList(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := GetPrivateEndpointConnectionListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_getprivatelinkresources.go b/resource-manager/web/2022-09-01/staticsites/method_getprivatelinkresources.go new file mode 100644 index 00000000000..8914466deb6 --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_getprivatelinkresources.go @@ -0,0 +1,52 @@ +package staticsites + +import ( + "context" + "fmt" + "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 GetPrivateLinkResourcesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateLinkResourcesWrapper +} + +// GetPrivateLinkResources ... +func (c StaticSitesClient) GetPrivateLinkResources(ctx context.Context, id StaticSiteId) (result GetPrivateLinkResourcesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateLinkResources", 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 +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_getprivatelinkresources_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_getprivatelinkresources_autorest.go deleted file mode 100644 index ee89329f2d4..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_getprivatelinkresources_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package staticsites - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetPrivateLinkResourcesOperationResponse struct { - HttpResponse *http.Response - Model *PrivateLinkResourcesWrapper -} - -// GetPrivateLinkResources ... -func (c StaticSitesClient) GetPrivateLinkResources(ctx context.Context, id StaticSiteId) (result GetPrivateLinkResourcesOperationResponse, err error) { - req, err := c.preparerForGetPrivateLinkResources(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetPrivateLinkResources", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetPrivateLinkResources", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetPrivateLinkResources(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetPrivateLinkResources", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetPrivateLinkResources prepares the GetPrivateLinkResources request. -func (c StaticSitesClient) preparerForGetPrivateLinkResources(ctx context.Context, id StaticSiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/privateLinkResources", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetPrivateLinkResources handles the response to the GetPrivateLinkResources request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForGetPrivateLinkResources(resp *http.Response) (result GetPrivateLinkResourcesOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_getstaticsite.go b/resource-manager/web/2022-09-01/staticsites/method_getstaticsite.go new file mode 100644 index 00000000000..89574b0514f --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_getstaticsite.go @@ -0,0 +1,51 @@ +package staticsites + +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 GetStaticSiteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteARMResource +} + +// GetStaticSite ... +func (c StaticSitesClient) GetStaticSite(ctx context.Context, id StaticSiteId) (result GetStaticSiteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_getstaticsite_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_getstaticsite_autorest.go deleted file mode 100644 index b340dadb408..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_getstaticsite_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package staticsites - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetStaticSiteOperationResponse struct { - HttpResponse *http.Response - Model *StaticSiteARMResource -} - -// GetStaticSite ... -func (c StaticSitesClient) GetStaticSite(ctx context.Context, id StaticSiteId) (result GetStaticSiteOperationResponse, err error) { - req, err := c.preparerForGetStaticSite(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetStaticSite", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetStaticSite", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetStaticSite(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetStaticSite", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetStaticSite prepares the GetStaticSite request. -func (c StaticSitesClient) preparerForGetStaticSite(ctx context.Context, id StaticSiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetStaticSite handles the response to the GetStaticSite request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForGetStaticSite(resp *http.Response) (result GetStaticSiteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_getstaticsitebuild.go b/resource-manager/web/2022-09-01/staticsites/method_getstaticsitebuild.go new file mode 100644 index 00000000000..9f182caf234 --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_getstaticsitebuild.go @@ -0,0 +1,51 @@ +package staticsites + +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 GetStaticSiteBuildOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteBuildARMResource +} + +// GetStaticSiteBuild ... +func (c StaticSitesClient) GetStaticSiteBuild(ctx context.Context, id BuildId) (result GetStaticSiteBuildOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_getstaticsitebuild_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_getstaticsitebuild_autorest.go deleted file mode 100644 index 83b639646ca..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_getstaticsitebuild_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package staticsites - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetStaticSiteBuildOperationResponse struct { - HttpResponse *http.Response - Model *StaticSiteBuildARMResource -} - -// GetStaticSiteBuild ... -func (c StaticSitesClient) GetStaticSiteBuild(ctx context.Context, id BuildId) (result GetStaticSiteBuildOperationResponse, err error) { - req, err := c.preparerForGetStaticSiteBuild(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetStaticSiteBuild", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetStaticSiteBuild", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetStaticSiteBuild(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetStaticSiteBuild", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetStaticSiteBuild prepares the GetStaticSiteBuild request. -func (c StaticSitesClient) preparerForGetStaticSiteBuild(ctx context.Context, id BuildId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetStaticSiteBuild handles the response to the GetStaticSiteBuild request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForGetStaticSiteBuild(resp *http.Response) (result GetStaticSiteBuildOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_getstaticsitebuilds.go b/resource-manager/web/2022-09-01/staticsites/method_getstaticsitebuilds.go new file mode 100644 index 00000000000..e6247503447 --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_getstaticsitebuilds.go @@ -0,0 +1,89 @@ +package staticsites + +import ( + "context" + "fmt" + "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 GetStaticSiteBuildsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StaticSiteBuildARMResource +} + +type GetStaticSiteBuildsCompleteResult struct { + Items []StaticSiteBuildARMResource +} + +// GetStaticSiteBuilds ... +func (c StaticSitesClient) GetStaticSiteBuilds(ctx context.Context, id StaticSiteId) (result GetStaticSiteBuildsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/builds", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]StaticSiteBuildARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetStaticSiteBuildsComplete retrieves all the results into a single object +func (c StaticSitesClient) GetStaticSiteBuildsComplete(ctx context.Context, id StaticSiteId) (GetStaticSiteBuildsCompleteResult, error) { + return c.GetStaticSiteBuildsCompleteMatchingPredicate(ctx, id, StaticSiteBuildARMResourceOperationPredicate{}) +} + +// GetStaticSiteBuildsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) GetStaticSiteBuildsCompleteMatchingPredicate(ctx context.Context, id StaticSiteId, predicate StaticSiteBuildARMResourceOperationPredicate) (result GetStaticSiteBuildsCompleteResult, err error) { + items := make([]StaticSiteBuildARMResource, 0) + + resp, err := c.GetStaticSiteBuilds(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetStaticSiteBuildsCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_getstaticsitebuilds_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_getstaticsitebuilds_autorest.go deleted file mode 100644 index fe355e3d5f7..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_getstaticsitebuilds_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package staticsites - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetStaticSiteBuildsOperationResponse struct { - HttpResponse *http.Response - Model *[]StaticSiteBuildARMResource - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (GetStaticSiteBuildsOperationResponse, error) -} - -type GetStaticSiteBuildsCompleteResult struct { - Items []StaticSiteBuildARMResource -} - -func (r GetStaticSiteBuildsOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r GetStaticSiteBuildsOperationResponse) LoadMore(ctx context.Context) (resp GetStaticSiteBuildsOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// GetStaticSiteBuilds ... -func (c StaticSitesClient) GetStaticSiteBuilds(ctx context.Context, id StaticSiteId) (resp GetStaticSiteBuildsOperationResponse, err error) { - req, err := c.preparerForGetStaticSiteBuilds(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetStaticSiteBuilds", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetStaticSiteBuilds", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForGetStaticSiteBuilds(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetStaticSiteBuilds", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForGetStaticSiteBuilds prepares the GetStaticSiteBuilds request. -func (c StaticSitesClient) preparerForGetStaticSiteBuilds(ctx context.Context, id StaticSiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/builds", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForGetStaticSiteBuildsWithNextLink prepares the GetStaticSiteBuilds request with the given nextLink token. -func (c StaticSitesClient) preparerForGetStaticSiteBuildsWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetStaticSiteBuilds handles the response to the GetStaticSiteBuilds request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForGetStaticSiteBuilds(resp *http.Response) (result GetStaticSiteBuildsOperationResponse, err error) { - type page struct { - Values []StaticSiteBuildARMResource `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result GetStaticSiteBuildsOperationResponse, err error) { - req, err := c.preparerForGetStaticSiteBuildsWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetStaticSiteBuilds", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetStaticSiteBuilds", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetStaticSiteBuilds(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetStaticSiteBuilds", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// GetStaticSiteBuildsComplete retrieves all of the results into a single object -func (c StaticSitesClient) GetStaticSiteBuildsComplete(ctx context.Context, id StaticSiteId) (GetStaticSiteBuildsCompleteResult, error) { - return c.GetStaticSiteBuildsCompleteMatchingPredicate(ctx, id, StaticSiteBuildARMResourceOperationPredicate{}) -} - -// GetStaticSiteBuildsCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c StaticSitesClient) GetStaticSiteBuildsCompleteMatchingPredicate(ctx context.Context, id StaticSiteId, predicate StaticSiteBuildARMResourceOperationPredicate) (resp GetStaticSiteBuildsCompleteResult, err error) { - items := make([]StaticSiteBuildARMResource, 0) - - page, err := c.GetStaticSiteBuilds(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := GetStaticSiteBuildsCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_getstaticsitecustomdomain.go b/resource-manager/web/2022-09-01/staticsites/method_getstaticsitecustomdomain.go new file mode 100644 index 00000000000..5c334859ea6 --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_getstaticsitecustomdomain.go @@ -0,0 +1,51 @@ +package staticsites + +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 GetStaticSiteCustomDomainOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteCustomDomainOverviewARMResource +} + +// GetStaticSiteCustomDomain ... +func (c StaticSitesClient) GetStaticSiteCustomDomain(ctx context.Context, id CustomDomainId) (result GetStaticSiteCustomDomainOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_getstaticsitecustomdomain_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_getstaticsitecustomdomain_autorest.go deleted file mode 100644 index 586e3ad0eb5..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_getstaticsitecustomdomain_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package staticsites - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetStaticSiteCustomDomainOperationResponse struct { - HttpResponse *http.Response - Model *StaticSiteCustomDomainOverviewARMResource -} - -// GetStaticSiteCustomDomain ... -func (c StaticSitesClient) GetStaticSiteCustomDomain(ctx context.Context, id CustomDomainId) (result GetStaticSiteCustomDomainOperationResponse, err error) { - req, err := c.preparerForGetStaticSiteCustomDomain(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetStaticSiteCustomDomain", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetStaticSiteCustomDomain", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetStaticSiteCustomDomain(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetStaticSiteCustomDomain", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetStaticSiteCustomDomain prepares the GetStaticSiteCustomDomain request. -func (c StaticSitesClient) preparerForGetStaticSiteCustomDomain(ctx context.Context, id CustomDomainId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetStaticSiteCustomDomain handles the response to the GetStaticSiteCustomDomain request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForGetStaticSiteCustomDomain(resp *http.Response) (result GetStaticSiteCustomDomainOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_getstaticsitesbyresourcegroup.go b/resource-manager/web/2022-09-01/staticsites/method_getstaticsitesbyresourcegroup.go new file mode 100644 index 00000000000..77d2489dbaf --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_getstaticsitesbyresourcegroup.go @@ -0,0 +1,90 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 GetStaticSitesByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StaticSiteARMResource +} + +type GetStaticSitesByResourceGroupCompleteResult struct { + Items []StaticSiteARMResource +} + +// GetStaticSitesByResourceGroup ... +func (c StaticSitesClient) GetStaticSitesByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result GetStaticSitesByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/staticSites", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]StaticSiteARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetStaticSitesByResourceGroupComplete retrieves all the results into a single object +func (c StaticSitesClient) GetStaticSitesByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (GetStaticSitesByResourceGroupCompleteResult, error) { + return c.GetStaticSitesByResourceGroupCompleteMatchingPredicate(ctx, id, StaticSiteARMResourceOperationPredicate{}) +} + +// GetStaticSitesByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) GetStaticSitesByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate StaticSiteARMResourceOperationPredicate) (result GetStaticSitesByResourceGroupCompleteResult, err error) { + items := make([]StaticSiteARMResource, 0) + + resp, err := c.GetStaticSitesByResourceGroup(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetStaticSitesByResourceGroupCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_getstaticsitesbyresourcegroup_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_getstaticsitesbyresourcegroup_autorest.go deleted file mode 100644 index 10009dbfb82..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_getstaticsitesbyresourcegroup_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package staticsites - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetStaticSitesByResourceGroupOperationResponse struct { - HttpResponse *http.Response - Model *[]StaticSiteARMResource - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (GetStaticSitesByResourceGroupOperationResponse, error) -} - -type GetStaticSitesByResourceGroupCompleteResult struct { - Items []StaticSiteARMResource -} - -func (r GetStaticSitesByResourceGroupOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r GetStaticSitesByResourceGroupOperationResponse) LoadMore(ctx context.Context) (resp GetStaticSitesByResourceGroupOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// GetStaticSitesByResourceGroup ... -func (c StaticSitesClient) GetStaticSitesByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (resp GetStaticSitesByResourceGroupOperationResponse, err error) { - req, err := c.preparerForGetStaticSitesByResourceGroup(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetStaticSitesByResourceGroup", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetStaticSitesByResourceGroup", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForGetStaticSitesByResourceGroup(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetStaticSitesByResourceGroup", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForGetStaticSitesByResourceGroup prepares the GetStaticSitesByResourceGroup request. -func (c StaticSitesClient) preparerForGetStaticSitesByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Web/staticSites", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForGetStaticSitesByResourceGroupWithNextLink prepares the GetStaticSitesByResourceGroup request with the given nextLink token. -func (c StaticSitesClient) preparerForGetStaticSitesByResourceGroupWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetStaticSitesByResourceGroup handles the response to the GetStaticSitesByResourceGroup request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForGetStaticSitesByResourceGroup(resp *http.Response) (result GetStaticSitesByResourceGroupOperationResponse, err error) { - type page struct { - Values []StaticSiteARMResource `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result GetStaticSitesByResourceGroupOperationResponse, err error) { - req, err := c.preparerForGetStaticSitesByResourceGroupWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetStaticSitesByResourceGroup", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetStaticSitesByResourceGroup", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetStaticSitesByResourceGroup(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetStaticSitesByResourceGroup", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// GetStaticSitesByResourceGroupComplete retrieves all of the results into a single object -func (c StaticSitesClient) GetStaticSitesByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (GetStaticSitesByResourceGroupCompleteResult, error) { - return c.GetStaticSitesByResourceGroupCompleteMatchingPredicate(ctx, id, StaticSiteARMResourceOperationPredicate{}) -} - -// GetStaticSitesByResourceGroupCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c StaticSitesClient) GetStaticSitesByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate StaticSiteARMResourceOperationPredicate) (resp GetStaticSitesByResourceGroupCompleteResult, err error) { - items := make([]StaticSiteARMResource, 0) - - page, err := c.GetStaticSitesByResourceGroup(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := GetStaticSitesByResourceGroupCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_getuserprovidedfunctionappforstaticsite.go b/resource-manager/web/2022-09-01/staticsites/method_getuserprovidedfunctionappforstaticsite.go new file mode 100644 index 00000000000..b1513ca3bb0 --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_getuserprovidedfunctionappforstaticsite.go @@ -0,0 +1,51 @@ +package staticsites + +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 GetUserProvidedFunctionAppForStaticSiteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteUserProvidedFunctionAppARMResource +} + +// GetUserProvidedFunctionAppForStaticSite ... +func (c StaticSitesClient) GetUserProvidedFunctionAppForStaticSite(ctx context.Context, id UserProvidedFunctionAppId) (result GetUserProvidedFunctionAppForStaticSiteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_getuserprovidedfunctionappforstaticsite_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_getuserprovidedfunctionappforstaticsite_autorest.go deleted file mode 100644 index 2466b0291ed..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_getuserprovidedfunctionappforstaticsite_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package staticsites - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetUserProvidedFunctionAppForStaticSiteOperationResponse struct { - HttpResponse *http.Response - Model *StaticSiteUserProvidedFunctionAppARMResource -} - -// GetUserProvidedFunctionAppForStaticSite ... -func (c StaticSitesClient) GetUserProvidedFunctionAppForStaticSite(ctx context.Context, id UserProvidedFunctionAppId) (result GetUserProvidedFunctionAppForStaticSiteOperationResponse, err error) { - req, err := c.preparerForGetUserProvidedFunctionAppForStaticSite(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetUserProvidedFunctionAppForStaticSite", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetUserProvidedFunctionAppForStaticSite", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetUserProvidedFunctionAppForStaticSite(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetUserProvidedFunctionAppForStaticSite", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetUserProvidedFunctionAppForStaticSite prepares the GetUserProvidedFunctionAppForStaticSite request. -func (c StaticSitesClient) preparerForGetUserProvidedFunctionAppForStaticSite(ctx context.Context, id UserProvidedFunctionAppId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetUserProvidedFunctionAppForStaticSite handles the response to the GetUserProvidedFunctionAppForStaticSite request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForGetUserProvidedFunctionAppForStaticSite(resp *http.Response) (result GetUserProvidedFunctionAppForStaticSiteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_getuserprovidedfunctionappforstaticsitebuild.go b/resource-manager/web/2022-09-01/staticsites/method_getuserprovidedfunctionappforstaticsitebuild.go new file mode 100644 index 00000000000..cd618941b36 --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_getuserprovidedfunctionappforstaticsitebuild.go @@ -0,0 +1,51 @@ +package staticsites + +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 GetUserProvidedFunctionAppForStaticSiteBuildOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteUserProvidedFunctionAppARMResource +} + +// GetUserProvidedFunctionAppForStaticSiteBuild ... +func (c StaticSitesClient) GetUserProvidedFunctionAppForStaticSiteBuild(ctx context.Context, id BuildUserProvidedFunctionAppId) (result GetUserProvidedFunctionAppForStaticSiteBuildOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_getuserprovidedfunctionappforstaticsitebuild_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_getuserprovidedfunctionappforstaticsitebuild_autorest.go deleted file mode 100644 index 6d67e4e36de..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_getuserprovidedfunctionappforstaticsitebuild_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package staticsites - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetUserProvidedFunctionAppForStaticSiteBuildOperationResponse struct { - HttpResponse *http.Response - Model *StaticSiteUserProvidedFunctionAppARMResource -} - -// GetUserProvidedFunctionAppForStaticSiteBuild ... -func (c StaticSitesClient) GetUserProvidedFunctionAppForStaticSiteBuild(ctx context.Context, id BuildUserProvidedFunctionAppId) (result GetUserProvidedFunctionAppForStaticSiteBuildOperationResponse, err error) { - req, err := c.preparerForGetUserProvidedFunctionAppForStaticSiteBuild(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetUserProvidedFunctionAppForStaticSiteBuild", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetUserProvidedFunctionAppForStaticSiteBuild", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetUserProvidedFunctionAppForStaticSiteBuild(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetUserProvidedFunctionAppForStaticSiteBuild", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetUserProvidedFunctionAppForStaticSiteBuild prepares the GetUserProvidedFunctionAppForStaticSiteBuild request. -func (c StaticSitesClient) preparerForGetUserProvidedFunctionAppForStaticSiteBuild(ctx context.Context, id BuildUserProvidedFunctionAppId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetUserProvidedFunctionAppForStaticSiteBuild handles the response to the GetUserProvidedFunctionAppForStaticSiteBuild request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForGetUserProvidedFunctionAppForStaticSiteBuild(resp *http.Response) (result GetUserProvidedFunctionAppForStaticSiteBuildOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_getuserprovidedfunctionappsforstaticsite.go b/resource-manager/web/2022-09-01/staticsites/method_getuserprovidedfunctionappsforstaticsite.go new file mode 100644 index 00000000000..db8a126668b --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_getuserprovidedfunctionappsforstaticsite.go @@ -0,0 +1,89 @@ +package staticsites + +import ( + "context" + "fmt" + "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 GetUserProvidedFunctionAppsForStaticSiteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StaticSiteUserProvidedFunctionAppARMResource +} + +type GetUserProvidedFunctionAppsForStaticSiteCompleteResult struct { + Items []StaticSiteUserProvidedFunctionAppARMResource +} + +// GetUserProvidedFunctionAppsForStaticSite ... +func (c StaticSitesClient) GetUserProvidedFunctionAppsForStaticSite(ctx context.Context, id StaticSiteId) (result GetUserProvidedFunctionAppsForStaticSiteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/userProvidedFunctionApps", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]StaticSiteUserProvidedFunctionAppARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetUserProvidedFunctionAppsForStaticSiteComplete retrieves all the results into a single object +func (c StaticSitesClient) GetUserProvidedFunctionAppsForStaticSiteComplete(ctx context.Context, id StaticSiteId) (GetUserProvidedFunctionAppsForStaticSiteCompleteResult, error) { + return c.GetUserProvidedFunctionAppsForStaticSiteCompleteMatchingPredicate(ctx, id, StaticSiteUserProvidedFunctionAppARMResourceOperationPredicate{}) +} + +// GetUserProvidedFunctionAppsForStaticSiteCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) GetUserProvidedFunctionAppsForStaticSiteCompleteMatchingPredicate(ctx context.Context, id StaticSiteId, predicate StaticSiteUserProvidedFunctionAppARMResourceOperationPredicate) (result GetUserProvidedFunctionAppsForStaticSiteCompleteResult, err error) { + items := make([]StaticSiteUserProvidedFunctionAppARMResource, 0) + + resp, err := c.GetUserProvidedFunctionAppsForStaticSite(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetUserProvidedFunctionAppsForStaticSiteCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_getuserprovidedfunctionappsforstaticsite_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_getuserprovidedfunctionappsforstaticsite_autorest.go deleted file mode 100644 index ecda465b8c7..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_getuserprovidedfunctionappsforstaticsite_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package staticsites - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetUserProvidedFunctionAppsForStaticSiteOperationResponse struct { - HttpResponse *http.Response - Model *[]StaticSiteUserProvidedFunctionAppARMResource - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (GetUserProvidedFunctionAppsForStaticSiteOperationResponse, error) -} - -type GetUserProvidedFunctionAppsForStaticSiteCompleteResult struct { - Items []StaticSiteUserProvidedFunctionAppARMResource -} - -func (r GetUserProvidedFunctionAppsForStaticSiteOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r GetUserProvidedFunctionAppsForStaticSiteOperationResponse) LoadMore(ctx context.Context) (resp GetUserProvidedFunctionAppsForStaticSiteOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// GetUserProvidedFunctionAppsForStaticSite ... -func (c StaticSitesClient) GetUserProvidedFunctionAppsForStaticSite(ctx context.Context, id StaticSiteId) (resp GetUserProvidedFunctionAppsForStaticSiteOperationResponse, err error) { - req, err := c.preparerForGetUserProvidedFunctionAppsForStaticSite(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetUserProvidedFunctionAppsForStaticSite", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetUserProvidedFunctionAppsForStaticSite", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForGetUserProvidedFunctionAppsForStaticSite(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetUserProvidedFunctionAppsForStaticSite", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForGetUserProvidedFunctionAppsForStaticSite prepares the GetUserProvidedFunctionAppsForStaticSite request. -func (c StaticSitesClient) preparerForGetUserProvidedFunctionAppsForStaticSite(ctx context.Context, id StaticSiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/userProvidedFunctionApps", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForGetUserProvidedFunctionAppsForStaticSiteWithNextLink prepares the GetUserProvidedFunctionAppsForStaticSite request with the given nextLink token. -func (c StaticSitesClient) preparerForGetUserProvidedFunctionAppsForStaticSiteWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetUserProvidedFunctionAppsForStaticSite handles the response to the GetUserProvidedFunctionAppsForStaticSite request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForGetUserProvidedFunctionAppsForStaticSite(resp *http.Response) (result GetUserProvidedFunctionAppsForStaticSiteOperationResponse, err error) { - type page struct { - Values []StaticSiteUserProvidedFunctionAppARMResource `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result GetUserProvidedFunctionAppsForStaticSiteOperationResponse, err error) { - req, err := c.preparerForGetUserProvidedFunctionAppsForStaticSiteWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetUserProvidedFunctionAppsForStaticSite", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetUserProvidedFunctionAppsForStaticSite", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetUserProvidedFunctionAppsForStaticSite(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetUserProvidedFunctionAppsForStaticSite", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// GetUserProvidedFunctionAppsForStaticSiteComplete retrieves all of the results into a single object -func (c StaticSitesClient) GetUserProvidedFunctionAppsForStaticSiteComplete(ctx context.Context, id StaticSiteId) (GetUserProvidedFunctionAppsForStaticSiteCompleteResult, error) { - return c.GetUserProvidedFunctionAppsForStaticSiteCompleteMatchingPredicate(ctx, id, StaticSiteUserProvidedFunctionAppARMResourceOperationPredicate{}) -} - -// GetUserProvidedFunctionAppsForStaticSiteCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c StaticSitesClient) GetUserProvidedFunctionAppsForStaticSiteCompleteMatchingPredicate(ctx context.Context, id StaticSiteId, predicate StaticSiteUserProvidedFunctionAppARMResourceOperationPredicate) (resp GetUserProvidedFunctionAppsForStaticSiteCompleteResult, err error) { - items := make([]StaticSiteUserProvidedFunctionAppARMResource, 0) - - page, err := c.GetUserProvidedFunctionAppsForStaticSite(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := GetUserProvidedFunctionAppsForStaticSiteCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_getuserprovidedfunctionappsforstaticsitebuild.go b/resource-manager/web/2022-09-01/staticsites/method_getuserprovidedfunctionappsforstaticsitebuild.go new file mode 100644 index 00000000000..79a666ab54f --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_getuserprovidedfunctionappsforstaticsitebuild.go @@ -0,0 +1,89 @@ +package staticsites + +import ( + "context" + "fmt" + "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 GetUserProvidedFunctionAppsForStaticSiteBuildOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StaticSiteUserProvidedFunctionAppARMResource +} + +type GetUserProvidedFunctionAppsForStaticSiteBuildCompleteResult struct { + Items []StaticSiteUserProvidedFunctionAppARMResource +} + +// GetUserProvidedFunctionAppsForStaticSiteBuild ... +func (c StaticSitesClient) GetUserProvidedFunctionAppsForStaticSiteBuild(ctx context.Context, id BuildId) (result GetUserProvidedFunctionAppsForStaticSiteBuildOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/userProvidedFunctionApps", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]StaticSiteUserProvidedFunctionAppARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetUserProvidedFunctionAppsForStaticSiteBuildComplete retrieves all the results into a single object +func (c StaticSitesClient) GetUserProvidedFunctionAppsForStaticSiteBuildComplete(ctx context.Context, id BuildId) (GetUserProvidedFunctionAppsForStaticSiteBuildCompleteResult, error) { + return c.GetUserProvidedFunctionAppsForStaticSiteBuildCompleteMatchingPredicate(ctx, id, StaticSiteUserProvidedFunctionAppARMResourceOperationPredicate{}) +} + +// GetUserProvidedFunctionAppsForStaticSiteBuildCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) GetUserProvidedFunctionAppsForStaticSiteBuildCompleteMatchingPredicate(ctx context.Context, id BuildId, predicate StaticSiteUserProvidedFunctionAppARMResourceOperationPredicate) (result GetUserProvidedFunctionAppsForStaticSiteBuildCompleteResult, err error) { + items := make([]StaticSiteUserProvidedFunctionAppARMResource, 0) + + resp, err := c.GetUserProvidedFunctionAppsForStaticSiteBuild(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetUserProvidedFunctionAppsForStaticSiteBuildCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_getuserprovidedfunctionappsforstaticsitebuild_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_getuserprovidedfunctionappsforstaticsitebuild_autorest.go deleted file mode 100644 index 364caa3bfa0..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_getuserprovidedfunctionappsforstaticsitebuild_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package staticsites - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetUserProvidedFunctionAppsForStaticSiteBuildOperationResponse struct { - HttpResponse *http.Response - Model *[]StaticSiteUserProvidedFunctionAppARMResource - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (GetUserProvidedFunctionAppsForStaticSiteBuildOperationResponse, error) -} - -type GetUserProvidedFunctionAppsForStaticSiteBuildCompleteResult struct { - Items []StaticSiteUserProvidedFunctionAppARMResource -} - -func (r GetUserProvidedFunctionAppsForStaticSiteBuildOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r GetUserProvidedFunctionAppsForStaticSiteBuildOperationResponse) LoadMore(ctx context.Context) (resp GetUserProvidedFunctionAppsForStaticSiteBuildOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// GetUserProvidedFunctionAppsForStaticSiteBuild ... -func (c StaticSitesClient) GetUserProvidedFunctionAppsForStaticSiteBuild(ctx context.Context, id BuildId) (resp GetUserProvidedFunctionAppsForStaticSiteBuildOperationResponse, err error) { - req, err := c.preparerForGetUserProvidedFunctionAppsForStaticSiteBuild(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetUserProvidedFunctionAppsForStaticSiteBuild", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetUserProvidedFunctionAppsForStaticSiteBuild", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForGetUserProvidedFunctionAppsForStaticSiteBuild(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetUserProvidedFunctionAppsForStaticSiteBuild", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForGetUserProvidedFunctionAppsForStaticSiteBuild prepares the GetUserProvidedFunctionAppsForStaticSiteBuild request. -func (c StaticSitesClient) preparerForGetUserProvidedFunctionAppsForStaticSiteBuild(ctx context.Context, id BuildId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/userProvidedFunctionApps", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForGetUserProvidedFunctionAppsForStaticSiteBuildWithNextLink prepares the GetUserProvidedFunctionAppsForStaticSiteBuild request with the given nextLink token. -func (c StaticSitesClient) preparerForGetUserProvidedFunctionAppsForStaticSiteBuildWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetUserProvidedFunctionAppsForStaticSiteBuild handles the response to the GetUserProvidedFunctionAppsForStaticSiteBuild request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForGetUserProvidedFunctionAppsForStaticSiteBuild(resp *http.Response) (result GetUserProvidedFunctionAppsForStaticSiteBuildOperationResponse, err error) { - type page struct { - Values []StaticSiteUserProvidedFunctionAppARMResource `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result GetUserProvidedFunctionAppsForStaticSiteBuildOperationResponse, err error) { - req, err := c.preparerForGetUserProvidedFunctionAppsForStaticSiteBuildWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetUserProvidedFunctionAppsForStaticSiteBuild", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetUserProvidedFunctionAppsForStaticSiteBuild", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetUserProvidedFunctionAppsForStaticSiteBuild(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "GetUserProvidedFunctionAppsForStaticSiteBuild", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// GetUserProvidedFunctionAppsForStaticSiteBuildComplete retrieves all of the results into a single object -func (c StaticSitesClient) GetUserProvidedFunctionAppsForStaticSiteBuildComplete(ctx context.Context, id BuildId) (GetUserProvidedFunctionAppsForStaticSiteBuildCompleteResult, error) { - return c.GetUserProvidedFunctionAppsForStaticSiteBuildCompleteMatchingPredicate(ctx, id, StaticSiteUserProvidedFunctionAppARMResourceOperationPredicate{}) -} - -// GetUserProvidedFunctionAppsForStaticSiteBuildCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c StaticSitesClient) GetUserProvidedFunctionAppsForStaticSiteBuildCompleteMatchingPredicate(ctx context.Context, id BuildId, predicate StaticSiteUserProvidedFunctionAppARMResourceOperationPredicate) (resp GetUserProvidedFunctionAppsForStaticSiteBuildCompleteResult, err error) { - items := make([]StaticSiteUserProvidedFunctionAppARMResource, 0) - - page, err := c.GetUserProvidedFunctionAppsForStaticSiteBuild(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := GetUserProvidedFunctionAppsForStaticSiteBuildCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_linkbackend.go b/resource-manager/web/2022-09-01/staticsites/method_linkbackend.go new file mode 100644 index 00000000000..6883f27166c --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_linkbackend.go @@ -0,0 +1,73 @@ +package staticsites + +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 LinkBackendOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// LinkBackend ... +func (c StaticSitesClient) LinkBackend(ctx context.Context, id LinkedBackendId, input StaticSiteLinkedBackendARMResource) (result LinkBackendOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 +} + +// LinkBackendThenPoll performs LinkBackend then polls until it's completed +func (c StaticSitesClient) LinkBackendThenPoll(ctx context.Context, id LinkedBackendId, input StaticSiteLinkedBackendARMResource) error { + result, err := c.LinkBackend(ctx, id, input) + if err != nil { + return fmt.Errorf("performing LinkBackend: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after LinkBackend: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_linkbackend_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_linkbackend_autorest.go deleted file mode 100644 index 3a0e6478323..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_linkbackend_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package staticsites - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type LinkBackendOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// LinkBackend ... -func (c StaticSitesClient) LinkBackend(ctx context.Context, id LinkedBackendId, input StaticSiteLinkedBackendARMResource) (result LinkBackendOperationResponse, err error) { - req, err := c.preparerForLinkBackend(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "LinkBackend", nil, "Failure preparing request") - return - } - - result, err = c.senderForLinkBackend(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "LinkBackend", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// LinkBackendThenPoll performs LinkBackend then polls until it's completed -func (c StaticSitesClient) LinkBackendThenPoll(ctx context.Context, id LinkedBackendId, input StaticSiteLinkedBackendARMResource) error { - result, err := c.LinkBackend(ctx, id, input) - if err != nil { - return fmt.Errorf("performing LinkBackend: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after LinkBackend: %+v", err) - } - - return nil -} - -// preparerForLinkBackend prepares the LinkBackend request. -func (c StaticSitesClient) preparerForLinkBackend(ctx context.Context, id LinkedBackendId, input StaticSiteLinkedBackendARMResource) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForLinkBackend sends the LinkBackend request. The method will close the -// http.Response Body if it receives an error. -func (c StaticSitesClient) senderForLinkBackend(ctx context.Context, req *http.Request) (future LinkBackendOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_linkbackendtobuild.go b/resource-manager/web/2022-09-01/staticsites/method_linkbackendtobuild.go new file mode 100644 index 00000000000..96345d78537 --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_linkbackendtobuild.go @@ -0,0 +1,73 @@ +package staticsites + +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 LinkBackendToBuildOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// LinkBackendToBuild ... +func (c StaticSitesClient) LinkBackendToBuild(ctx context.Context, id BuildLinkedBackendId, input StaticSiteLinkedBackendARMResource) (result LinkBackendToBuildOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 +} + +// LinkBackendToBuildThenPoll performs LinkBackendToBuild then polls until it's completed +func (c StaticSitesClient) LinkBackendToBuildThenPoll(ctx context.Context, id BuildLinkedBackendId, input StaticSiteLinkedBackendARMResource) error { + result, err := c.LinkBackendToBuild(ctx, id, input) + if err != nil { + return fmt.Errorf("performing LinkBackendToBuild: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after LinkBackendToBuild: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_linkbackendtobuild_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_linkbackendtobuild_autorest.go deleted file mode 100644 index 43d5f8a7d0e..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_linkbackendtobuild_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package staticsites - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type LinkBackendToBuildOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// LinkBackendToBuild ... -func (c StaticSitesClient) LinkBackendToBuild(ctx context.Context, id BuildLinkedBackendId, input StaticSiteLinkedBackendARMResource) (result LinkBackendToBuildOperationResponse, err error) { - req, err := c.preparerForLinkBackendToBuild(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "LinkBackendToBuild", nil, "Failure preparing request") - return - } - - result, err = c.senderForLinkBackendToBuild(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "LinkBackendToBuild", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// LinkBackendToBuildThenPoll performs LinkBackendToBuild then polls until it's completed -func (c StaticSitesClient) LinkBackendToBuildThenPoll(ctx context.Context, id BuildLinkedBackendId, input StaticSiteLinkedBackendARMResource) error { - result, err := c.LinkBackendToBuild(ctx, id, input) - if err != nil { - return fmt.Errorf("performing LinkBackendToBuild: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after LinkBackendToBuild: %+v", err) - } - - return nil -} - -// preparerForLinkBackendToBuild prepares the LinkBackendToBuild request. -func (c StaticSitesClient) preparerForLinkBackendToBuild(ctx context.Context, id BuildLinkedBackendId, input StaticSiteLinkedBackendARMResource) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForLinkBackendToBuild sends the LinkBackendToBuild request. The method will close the -// http.Response Body if it receives an error. -func (c StaticSitesClient) senderForLinkBackendToBuild(ctx context.Context, req *http.Request) (future LinkBackendToBuildOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_list.go b/resource-manager/web/2022-09-01/staticsites/method_list.go new file mode 100644 index 00000000000..b96683bb938 --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_list.go @@ -0,0 +1,90 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StaticSiteARMResource +} + +type ListCompleteResult struct { + Items []StaticSiteARMResource +} + +// List ... +func (c StaticSitesClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/staticSites", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]StaticSiteARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c StaticSitesClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, StaticSiteARMResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate StaticSiteARMResourceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]StaticSiteARMResource, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_list_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_list_autorest.go deleted file mode 100644 index 720ff2ad62e..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_list_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package staticsites - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListOperationResponse struct { - HttpResponse *http.Response - Model *[]StaticSiteARMResource - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []StaticSiteARMResource -} - -func (r ListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// List ... -func (c StaticSitesClient) List(ctx context.Context, id commonids.SubscriptionId) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c StaticSitesClient) preparerForList(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Web/staticSites", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c StaticSitesClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForList handles the response to the List request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []StaticSiteARMResource `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { - req, err := c.preparerForListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c StaticSitesClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, StaticSiteARMResourceOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c StaticSitesClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate StaticSiteARMResourceOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]StaticSiteARMResource, 0) - - page, err := c.List(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_listbasicauth.go b/resource-manager/web/2022-09-01/staticsites/method_listbasicauth.go new file mode 100644 index 00000000000..12ec0e7870a --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_listbasicauth.go @@ -0,0 +1,89 @@ +package staticsites + +import ( + "context" + "fmt" + "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 ListBasicAuthOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StaticSiteBasicAuthPropertiesARMResource +} + +type ListBasicAuthCompleteResult struct { + Items []StaticSiteBasicAuthPropertiesARMResource +} + +// ListBasicAuth ... +func (c StaticSitesClient) ListBasicAuth(ctx context.Context, id StaticSiteId) (result ListBasicAuthOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/basicAuth", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]StaticSiteBasicAuthPropertiesARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBasicAuthComplete retrieves all the results into a single object +func (c StaticSitesClient) ListBasicAuthComplete(ctx context.Context, id StaticSiteId) (ListBasicAuthCompleteResult, error) { + return c.ListBasicAuthCompleteMatchingPredicate(ctx, id, StaticSiteBasicAuthPropertiesARMResourceOperationPredicate{}) +} + +// ListBasicAuthCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) ListBasicAuthCompleteMatchingPredicate(ctx context.Context, id StaticSiteId, predicate StaticSiteBasicAuthPropertiesARMResourceOperationPredicate) (result ListBasicAuthCompleteResult, err error) { + items := make([]StaticSiteBasicAuthPropertiesARMResource, 0) + + resp, err := c.ListBasicAuth(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListBasicAuthCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_listbasicauth_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_listbasicauth_autorest.go deleted file mode 100644 index b5b5c0a4361..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_listbasicauth_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package staticsites - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListBasicAuthOperationResponse struct { - HttpResponse *http.Response - Model *[]StaticSiteBasicAuthPropertiesARMResource - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListBasicAuthOperationResponse, error) -} - -type ListBasicAuthCompleteResult struct { - Items []StaticSiteBasicAuthPropertiesARMResource -} - -func (r ListBasicAuthOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListBasicAuthOperationResponse) LoadMore(ctx context.Context) (resp ListBasicAuthOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListBasicAuth ... -func (c StaticSitesClient) ListBasicAuth(ctx context.Context, id StaticSiteId) (resp ListBasicAuthOperationResponse, err error) { - req, err := c.preparerForListBasicAuth(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ListBasicAuth", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ListBasicAuth", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListBasicAuth(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ListBasicAuth", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListBasicAuth prepares the ListBasicAuth request. -func (c StaticSitesClient) preparerForListBasicAuth(ctx context.Context, id StaticSiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/basicAuth", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListBasicAuthWithNextLink prepares the ListBasicAuth request with the given nextLink token. -func (c StaticSitesClient) preparerForListBasicAuthWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListBasicAuth handles the response to the ListBasicAuth request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForListBasicAuth(resp *http.Response) (result ListBasicAuthOperationResponse, err error) { - type page struct { - Values []StaticSiteBasicAuthPropertiesARMResource `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListBasicAuthOperationResponse, err error) { - req, err := c.preparerForListBasicAuthWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ListBasicAuth", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ListBasicAuth", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListBasicAuth(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ListBasicAuth", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListBasicAuthComplete retrieves all of the results into a single object -func (c StaticSitesClient) ListBasicAuthComplete(ctx context.Context, id StaticSiteId) (ListBasicAuthCompleteResult, error) { - return c.ListBasicAuthCompleteMatchingPredicate(ctx, id, StaticSiteBasicAuthPropertiesARMResourceOperationPredicate{}) -} - -// ListBasicAuthCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c StaticSitesClient) ListBasicAuthCompleteMatchingPredicate(ctx context.Context, id StaticSiteId, predicate StaticSiteBasicAuthPropertiesARMResourceOperationPredicate) (resp ListBasicAuthCompleteResult, err error) { - items := make([]StaticSiteBasicAuthPropertiesARMResource, 0) - - page, err := c.ListBasicAuth(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListBasicAuthCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_liststaticsiteappsettings.go b/resource-manager/web/2022-09-01/staticsites/method_liststaticsiteappsettings.go new file mode 100644 index 00000000000..2bd87752e66 --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_liststaticsiteappsettings.go @@ -0,0 +1,52 @@ +package staticsites + +import ( + "context" + "fmt" + "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 ListStaticSiteAppSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// ListStaticSiteAppSettings ... +func (c StaticSitesClient) ListStaticSiteAppSettings(ctx context.Context, id StaticSiteId) (result ListStaticSiteAppSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listAppSettings", 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 +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_liststaticsiteappsettings_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_liststaticsiteappsettings_autorest.go deleted file mode 100644 index 7ca35e3d2c8..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_liststaticsiteappsettings_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package staticsites - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListStaticSiteAppSettingsOperationResponse struct { - HttpResponse *http.Response - Model *StringDictionary -} - -// ListStaticSiteAppSettings ... -func (c StaticSitesClient) ListStaticSiteAppSettings(ctx context.Context, id StaticSiteId) (result ListStaticSiteAppSettingsOperationResponse, err error) { - req, err := c.preparerForListStaticSiteAppSettings(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ListStaticSiteAppSettings", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ListStaticSiteAppSettings", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListStaticSiteAppSettings(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ListStaticSiteAppSettings", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListStaticSiteAppSettings prepares the ListStaticSiteAppSettings request. -func (c StaticSitesClient) preparerForListStaticSiteAppSettings(ctx context.Context, id StaticSiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/listAppSettings", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListStaticSiteAppSettings handles the response to the ListStaticSiteAppSettings request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForListStaticSiteAppSettings(resp *http.Response) (result ListStaticSiteAppSettingsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_liststaticsitebuildappsettings.go b/resource-manager/web/2022-09-01/staticsites/method_liststaticsitebuildappsettings.go new file mode 100644 index 00000000000..888035f618f --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_liststaticsitebuildappsettings.go @@ -0,0 +1,52 @@ +package staticsites + +import ( + "context" + "fmt" + "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 ListStaticSiteBuildAppSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// ListStaticSiteBuildAppSettings ... +func (c StaticSitesClient) ListStaticSiteBuildAppSettings(ctx context.Context, id BuildId) (result ListStaticSiteBuildAppSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listAppSettings", 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 +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_liststaticsitebuildappsettings_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_liststaticsitebuildappsettings_autorest.go deleted file mode 100644 index 9c433055dea..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_liststaticsitebuildappsettings_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package staticsites - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListStaticSiteBuildAppSettingsOperationResponse struct { - HttpResponse *http.Response - Model *StringDictionary -} - -// ListStaticSiteBuildAppSettings ... -func (c StaticSitesClient) ListStaticSiteBuildAppSettings(ctx context.Context, id BuildId) (result ListStaticSiteBuildAppSettingsOperationResponse, err error) { - req, err := c.preparerForListStaticSiteBuildAppSettings(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ListStaticSiteBuildAppSettings", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ListStaticSiteBuildAppSettings", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListStaticSiteBuildAppSettings(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ListStaticSiteBuildAppSettings", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListStaticSiteBuildAppSettings prepares the ListStaticSiteBuildAppSettings request. -func (c StaticSitesClient) preparerForListStaticSiteBuildAppSettings(ctx context.Context, id BuildId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/listAppSettings", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListStaticSiteBuildAppSettings handles the response to the ListStaticSiteBuildAppSettings request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForListStaticSiteBuildAppSettings(resp *http.Response) (result ListStaticSiteBuildAppSettingsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_liststaticsitebuildfunctionappsettings.go b/resource-manager/web/2022-09-01/staticsites/method_liststaticsitebuildfunctionappsettings.go new file mode 100644 index 00000000000..f047753cab5 --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_liststaticsitebuildfunctionappsettings.go @@ -0,0 +1,52 @@ +package staticsites + +import ( + "context" + "fmt" + "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 ListStaticSiteBuildFunctionAppSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// ListStaticSiteBuildFunctionAppSettings ... +func (c StaticSitesClient) ListStaticSiteBuildFunctionAppSettings(ctx context.Context, id BuildId) (result ListStaticSiteBuildFunctionAppSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listFunctionAppSettings", 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 +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_liststaticsitebuildfunctionappsettings_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_liststaticsitebuildfunctionappsettings_autorest.go deleted file mode 100644 index 1a9f959223c..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_liststaticsitebuildfunctionappsettings_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package staticsites - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListStaticSiteBuildFunctionAppSettingsOperationResponse struct { - HttpResponse *http.Response - Model *StringDictionary -} - -// ListStaticSiteBuildFunctionAppSettings ... -func (c StaticSitesClient) ListStaticSiteBuildFunctionAppSettings(ctx context.Context, id BuildId) (result ListStaticSiteBuildFunctionAppSettingsOperationResponse, err error) { - req, err := c.preparerForListStaticSiteBuildFunctionAppSettings(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ListStaticSiteBuildFunctionAppSettings", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ListStaticSiteBuildFunctionAppSettings", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListStaticSiteBuildFunctionAppSettings(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ListStaticSiteBuildFunctionAppSettings", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListStaticSiteBuildFunctionAppSettings prepares the ListStaticSiteBuildFunctionAppSettings request. -func (c StaticSitesClient) preparerForListStaticSiteBuildFunctionAppSettings(ctx context.Context, id BuildId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/listFunctionAppSettings", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListStaticSiteBuildFunctionAppSettings handles the response to the ListStaticSiteBuildFunctionAppSettings request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForListStaticSiteBuildFunctionAppSettings(resp *http.Response) (result ListStaticSiteBuildFunctionAppSettingsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_liststaticsitebuildfunctions.go b/resource-manager/web/2022-09-01/staticsites/method_liststaticsitebuildfunctions.go new file mode 100644 index 00000000000..3a27c32c34b --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_liststaticsitebuildfunctions.go @@ -0,0 +1,89 @@ +package staticsites + +import ( + "context" + "fmt" + "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 ListStaticSiteBuildFunctionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StaticSiteFunctionOverviewARMResource +} + +type ListStaticSiteBuildFunctionsCompleteResult struct { + Items []StaticSiteFunctionOverviewARMResource +} + +// ListStaticSiteBuildFunctions ... +func (c StaticSitesClient) ListStaticSiteBuildFunctions(ctx context.Context, id BuildId) (result ListStaticSiteBuildFunctionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/functions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]StaticSiteFunctionOverviewARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListStaticSiteBuildFunctionsComplete retrieves all the results into a single object +func (c StaticSitesClient) ListStaticSiteBuildFunctionsComplete(ctx context.Context, id BuildId) (ListStaticSiteBuildFunctionsCompleteResult, error) { + return c.ListStaticSiteBuildFunctionsCompleteMatchingPredicate(ctx, id, StaticSiteFunctionOverviewARMResourceOperationPredicate{}) +} + +// ListStaticSiteBuildFunctionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) ListStaticSiteBuildFunctionsCompleteMatchingPredicate(ctx context.Context, id BuildId, predicate StaticSiteFunctionOverviewARMResourceOperationPredicate) (result ListStaticSiteBuildFunctionsCompleteResult, err error) { + items := make([]StaticSiteFunctionOverviewARMResource, 0) + + resp, err := c.ListStaticSiteBuildFunctions(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListStaticSiteBuildFunctionsCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_liststaticsitebuildfunctions_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_liststaticsitebuildfunctions_autorest.go deleted file mode 100644 index b30f74b4602..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_liststaticsitebuildfunctions_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package staticsites - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListStaticSiteBuildFunctionsOperationResponse struct { - HttpResponse *http.Response - Model *[]StaticSiteFunctionOverviewARMResource - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListStaticSiteBuildFunctionsOperationResponse, error) -} - -type ListStaticSiteBuildFunctionsCompleteResult struct { - Items []StaticSiteFunctionOverviewARMResource -} - -func (r ListStaticSiteBuildFunctionsOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListStaticSiteBuildFunctionsOperationResponse) LoadMore(ctx context.Context) (resp ListStaticSiteBuildFunctionsOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListStaticSiteBuildFunctions ... -func (c StaticSitesClient) ListStaticSiteBuildFunctions(ctx context.Context, id BuildId) (resp ListStaticSiteBuildFunctionsOperationResponse, err error) { - req, err := c.preparerForListStaticSiteBuildFunctions(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ListStaticSiteBuildFunctions", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ListStaticSiteBuildFunctions", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListStaticSiteBuildFunctions(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ListStaticSiteBuildFunctions", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListStaticSiteBuildFunctions prepares the ListStaticSiteBuildFunctions request. -func (c StaticSitesClient) preparerForListStaticSiteBuildFunctions(ctx context.Context, id BuildId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/functions", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListStaticSiteBuildFunctionsWithNextLink prepares the ListStaticSiteBuildFunctions request with the given nextLink token. -func (c StaticSitesClient) preparerForListStaticSiteBuildFunctionsWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListStaticSiteBuildFunctions handles the response to the ListStaticSiteBuildFunctions request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForListStaticSiteBuildFunctions(resp *http.Response) (result ListStaticSiteBuildFunctionsOperationResponse, err error) { - type page struct { - Values []StaticSiteFunctionOverviewARMResource `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListStaticSiteBuildFunctionsOperationResponse, err error) { - req, err := c.preparerForListStaticSiteBuildFunctionsWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ListStaticSiteBuildFunctions", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ListStaticSiteBuildFunctions", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListStaticSiteBuildFunctions(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ListStaticSiteBuildFunctions", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListStaticSiteBuildFunctionsComplete retrieves all of the results into a single object -func (c StaticSitesClient) ListStaticSiteBuildFunctionsComplete(ctx context.Context, id BuildId) (ListStaticSiteBuildFunctionsCompleteResult, error) { - return c.ListStaticSiteBuildFunctionsCompleteMatchingPredicate(ctx, id, StaticSiteFunctionOverviewARMResourceOperationPredicate{}) -} - -// ListStaticSiteBuildFunctionsCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c StaticSitesClient) ListStaticSiteBuildFunctionsCompleteMatchingPredicate(ctx context.Context, id BuildId, predicate StaticSiteFunctionOverviewARMResourceOperationPredicate) (resp ListStaticSiteBuildFunctionsCompleteResult, err error) { - items := make([]StaticSiteFunctionOverviewARMResource, 0) - - page, err := c.ListStaticSiteBuildFunctions(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListStaticSiteBuildFunctionsCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_liststaticsiteconfiguredroles.go b/resource-manager/web/2022-09-01/staticsites/method_liststaticsiteconfiguredroles.go new file mode 100644 index 00000000000..4613646bc48 --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_liststaticsiteconfiguredroles.go @@ -0,0 +1,52 @@ +package staticsites + +import ( + "context" + "fmt" + "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 ListStaticSiteConfiguredRolesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringList +} + +// ListStaticSiteConfiguredRoles ... +func (c StaticSitesClient) ListStaticSiteConfiguredRoles(ctx context.Context, id StaticSiteId) (result ListStaticSiteConfiguredRolesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listConfiguredRoles", 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 +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_liststaticsiteconfiguredroles_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_liststaticsiteconfiguredroles_autorest.go deleted file mode 100644 index a0bf8a5166a..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_liststaticsiteconfiguredroles_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package staticsites - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListStaticSiteConfiguredRolesOperationResponse struct { - HttpResponse *http.Response - Model *StringList -} - -// ListStaticSiteConfiguredRoles ... -func (c StaticSitesClient) ListStaticSiteConfiguredRoles(ctx context.Context, id StaticSiteId) (result ListStaticSiteConfiguredRolesOperationResponse, err error) { - req, err := c.preparerForListStaticSiteConfiguredRoles(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ListStaticSiteConfiguredRoles", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ListStaticSiteConfiguredRoles", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListStaticSiteConfiguredRoles(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ListStaticSiteConfiguredRoles", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListStaticSiteConfiguredRoles prepares the ListStaticSiteConfiguredRoles request. -func (c StaticSitesClient) preparerForListStaticSiteConfiguredRoles(ctx context.Context, id StaticSiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/listConfiguredRoles", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListStaticSiteConfiguredRoles handles the response to the ListStaticSiteConfiguredRoles request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForListStaticSiteConfiguredRoles(resp *http.Response) (result ListStaticSiteConfiguredRolesOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_liststaticsitecustomdomains.go b/resource-manager/web/2022-09-01/staticsites/method_liststaticsitecustomdomains.go new file mode 100644 index 00000000000..7008535df3d --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_liststaticsitecustomdomains.go @@ -0,0 +1,89 @@ +package staticsites + +import ( + "context" + "fmt" + "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 ListStaticSiteCustomDomainsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StaticSiteCustomDomainOverviewARMResource +} + +type ListStaticSiteCustomDomainsCompleteResult struct { + Items []StaticSiteCustomDomainOverviewARMResource +} + +// ListStaticSiteCustomDomains ... +func (c StaticSitesClient) ListStaticSiteCustomDomains(ctx context.Context, id StaticSiteId) (result ListStaticSiteCustomDomainsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/customDomains", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]StaticSiteCustomDomainOverviewARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListStaticSiteCustomDomainsComplete retrieves all the results into a single object +func (c StaticSitesClient) ListStaticSiteCustomDomainsComplete(ctx context.Context, id StaticSiteId) (ListStaticSiteCustomDomainsCompleteResult, error) { + return c.ListStaticSiteCustomDomainsCompleteMatchingPredicate(ctx, id, StaticSiteCustomDomainOverviewARMResourceOperationPredicate{}) +} + +// ListStaticSiteCustomDomainsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) ListStaticSiteCustomDomainsCompleteMatchingPredicate(ctx context.Context, id StaticSiteId, predicate StaticSiteCustomDomainOverviewARMResourceOperationPredicate) (result ListStaticSiteCustomDomainsCompleteResult, err error) { + items := make([]StaticSiteCustomDomainOverviewARMResource, 0) + + resp, err := c.ListStaticSiteCustomDomains(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListStaticSiteCustomDomainsCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_liststaticsitecustomdomains_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_liststaticsitecustomdomains_autorest.go deleted file mode 100644 index 6f624bb2083..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_liststaticsitecustomdomains_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package staticsites - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListStaticSiteCustomDomainsOperationResponse struct { - HttpResponse *http.Response - Model *[]StaticSiteCustomDomainOverviewARMResource - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListStaticSiteCustomDomainsOperationResponse, error) -} - -type ListStaticSiteCustomDomainsCompleteResult struct { - Items []StaticSiteCustomDomainOverviewARMResource -} - -func (r ListStaticSiteCustomDomainsOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListStaticSiteCustomDomainsOperationResponse) LoadMore(ctx context.Context) (resp ListStaticSiteCustomDomainsOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListStaticSiteCustomDomains ... -func (c StaticSitesClient) ListStaticSiteCustomDomains(ctx context.Context, id StaticSiteId) (resp ListStaticSiteCustomDomainsOperationResponse, err error) { - req, err := c.preparerForListStaticSiteCustomDomains(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ListStaticSiteCustomDomains", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ListStaticSiteCustomDomains", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListStaticSiteCustomDomains(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ListStaticSiteCustomDomains", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListStaticSiteCustomDomains prepares the ListStaticSiteCustomDomains request. -func (c StaticSitesClient) preparerForListStaticSiteCustomDomains(ctx context.Context, id StaticSiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/customDomains", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListStaticSiteCustomDomainsWithNextLink prepares the ListStaticSiteCustomDomains request with the given nextLink token. -func (c StaticSitesClient) preparerForListStaticSiteCustomDomainsWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListStaticSiteCustomDomains handles the response to the ListStaticSiteCustomDomains request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForListStaticSiteCustomDomains(resp *http.Response) (result ListStaticSiteCustomDomainsOperationResponse, err error) { - type page struct { - Values []StaticSiteCustomDomainOverviewARMResource `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListStaticSiteCustomDomainsOperationResponse, err error) { - req, err := c.preparerForListStaticSiteCustomDomainsWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ListStaticSiteCustomDomains", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ListStaticSiteCustomDomains", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListStaticSiteCustomDomains(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ListStaticSiteCustomDomains", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListStaticSiteCustomDomainsComplete retrieves all of the results into a single object -func (c StaticSitesClient) ListStaticSiteCustomDomainsComplete(ctx context.Context, id StaticSiteId) (ListStaticSiteCustomDomainsCompleteResult, error) { - return c.ListStaticSiteCustomDomainsCompleteMatchingPredicate(ctx, id, StaticSiteCustomDomainOverviewARMResourceOperationPredicate{}) -} - -// ListStaticSiteCustomDomainsCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c StaticSitesClient) ListStaticSiteCustomDomainsCompleteMatchingPredicate(ctx context.Context, id StaticSiteId, predicate StaticSiteCustomDomainOverviewARMResourceOperationPredicate) (resp ListStaticSiteCustomDomainsCompleteResult, err error) { - items := make([]StaticSiteCustomDomainOverviewARMResource, 0) - - page, err := c.ListStaticSiteCustomDomains(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListStaticSiteCustomDomainsCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_liststaticsitefunctionappsettings.go b/resource-manager/web/2022-09-01/staticsites/method_liststaticsitefunctionappsettings.go new file mode 100644 index 00000000000..9610018b60e --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_liststaticsitefunctionappsettings.go @@ -0,0 +1,52 @@ +package staticsites + +import ( + "context" + "fmt" + "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 ListStaticSiteFunctionAppSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// ListStaticSiteFunctionAppSettings ... +func (c StaticSitesClient) ListStaticSiteFunctionAppSettings(ctx context.Context, id StaticSiteId) (result ListStaticSiteFunctionAppSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listFunctionAppSettings", 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 +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_liststaticsitefunctionappsettings_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_liststaticsitefunctionappsettings_autorest.go deleted file mode 100644 index f5e47d14b55..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_liststaticsitefunctionappsettings_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package staticsites - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListStaticSiteFunctionAppSettingsOperationResponse struct { - HttpResponse *http.Response - Model *StringDictionary -} - -// ListStaticSiteFunctionAppSettings ... -func (c StaticSitesClient) ListStaticSiteFunctionAppSettings(ctx context.Context, id StaticSiteId) (result ListStaticSiteFunctionAppSettingsOperationResponse, err error) { - req, err := c.preparerForListStaticSiteFunctionAppSettings(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ListStaticSiteFunctionAppSettings", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ListStaticSiteFunctionAppSettings", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListStaticSiteFunctionAppSettings(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ListStaticSiteFunctionAppSettings", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListStaticSiteFunctionAppSettings prepares the ListStaticSiteFunctionAppSettings request. -func (c StaticSitesClient) preparerForListStaticSiteFunctionAppSettings(ctx context.Context, id StaticSiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/listFunctionAppSettings", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListStaticSiteFunctionAppSettings handles the response to the ListStaticSiteFunctionAppSettings request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForListStaticSiteFunctionAppSettings(resp *http.Response) (result ListStaticSiteFunctionAppSettingsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_liststaticsitefunctions.go b/resource-manager/web/2022-09-01/staticsites/method_liststaticsitefunctions.go new file mode 100644 index 00000000000..b2c52d478cb --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_liststaticsitefunctions.go @@ -0,0 +1,89 @@ +package staticsites + +import ( + "context" + "fmt" + "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 ListStaticSiteFunctionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StaticSiteFunctionOverviewARMResource +} + +type ListStaticSiteFunctionsCompleteResult struct { + Items []StaticSiteFunctionOverviewARMResource +} + +// ListStaticSiteFunctions ... +func (c StaticSitesClient) ListStaticSiteFunctions(ctx context.Context, id StaticSiteId) (result ListStaticSiteFunctionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/functions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]StaticSiteFunctionOverviewARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListStaticSiteFunctionsComplete retrieves all the results into a single object +func (c StaticSitesClient) ListStaticSiteFunctionsComplete(ctx context.Context, id StaticSiteId) (ListStaticSiteFunctionsCompleteResult, error) { + return c.ListStaticSiteFunctionsCompleteMatchingPredicate(ctx, id, StaticSiteFunctionOverviewARMResourceOperationPredicate{}) +} + +// ListStaticSiteFunctionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) ListStaticSiteFunctionsCompleteMatchingPredicate(ctx context.Context, id StaticSiteId, predicate StaticSiteFunctionOverviewARMResourceOperationPredicate) (result ListStaticSiteFunctionsCompleteResult, err error) { + items := make([]StaticSiteFunctionOverviewARMResource, 0) + + resp, err := c.ListStaticSiteFunctions(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListStaticSiteFunctionsCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_liststaticsitefunctions_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_liststaticsitefunctions_autorest.go deleted file mode 100644 index 7dacd36bd22..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_liststaticsitefunctions_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package staticsites - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListStaticSiteFunctionsOperationResponse struct { - HttpResponse *http.Response - Model *[]StaticSiteFunctionOverviewARMResource - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListStaticSiteFunctionsOperationResponse, error) -} - -type ListStaticSiteFunctionsCompleteResult struct { - Items []StaticSiteFunctionOverviewARMResource -} - -func (r ListStaticSiteFunctionsOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListStaticSiteFunctionsOperationResponse) LoadMore(ctx context.Context) (resp ListStaticSiteFunctionsOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListStaticSiteFunctions ... -func (c StaticSitesClient) ListStaticSiteFunctions(ctx context.Context, id StaticSiteId) (resp ListStaticSiteFunctionsOperationResponse, err error) { - req, err := c.preparerForListStaticSiteFunctions(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ListStaticSiteFunctions", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ListStaticSiteFunctions", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListStaticSiteFunctions(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ListStaticSiteFunctions", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListStaticSiteFunctions prepares the ListStaticSiteFunctions request. -func (c StaticSitesClient) preparerForListStaticSiteFunctions(ctx context.Context, id StaticSiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/functions", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListStaticSiteFunctionsWithNextLink prepares the ListStaticSiteFunctions request with the given nextLink token. -func (c StaticSitesClient) preparerForListStaticSiteFunctionsWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListStaticSiteFunctions handles the response to the ListStaticSiteFunctions request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForListStaticSiteFunctions(resp *http.Response) (result ListStaticSiteFunctionsOperationResponse, err error) { - type page struct { - Values []StaticSiteFunctionOverviewARMResource `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListStaticSiteFunctionsOperationResponse, err error) { - req, err := c.preparerForListStaticSiteFunctionsWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ListStaticSiteFunctions", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ListStaticSiteFunctions", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListStaticSiteFunctions(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ListStaticSiteFunctions", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListStaticSiteFunctionsComplete retrieves all of the results into a single object -func (c StaticSitesClient) ListStaticSiteFunctionsComplete(ctx context.Context, id StaticSiteId) (ListStaticSiteFunctionsCompleteResult, error) { - return c.ListStaticSiteFunctionsCompleteMatchingPredicate(ctx, id, StaticSiteFunctionOverviewARMResourceOperationPredicate{}) -} - -// ListStaticSiteFunctionsCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c StaticSitesClient) ListStaticSiteFunctionsCompleteMatchingPredicate(ctx context.Context, id StaticSiteId, predicate StaticSiteFunctionOverviewARMResourceOperationPredicate) (resp ListStaticSiteFunctionsCompleteResult, err error) { - items := make([]StaticSiteFunctionOverviewARMResource, 0) - - page, err := c.ListStaticSiteFunctions(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListStaticSiteFunctionsCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_liststaticsitesecrets.go b/resource-manager/web/2022-09-01/staticsites/method_liststaticsitesecrets.go new file mode 100644 index 00000000000..fb84b46d68a --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_liststaticsitesecrets.go @@ -0,0 +1,52 @@ +package staticsites + +import ( + "context" + "fmt" + "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 ListStaticSiteSecretsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// ListStaticSiteSecrets ... +func (c StaticSitesClient) ListStaticSiteSecrets(ctx context.Context, id StaticSiteId) (result ListStaticSiteSecretsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listSecrets", 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 +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_liststaticsitesecrets_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_liststaticsitesecrets_autorest.go deleted file mode 100644 index 817400250de..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_liststaticsitesecrets_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package staticsites - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListStaticSiteSecretsOperationResponse struct { - HttpResponse *http.Response - Model *StringDictionary -} - -// ListStaticSiteSecrets ... -func (c StaticSitesClient) ListStaticSiteSecrets(ctx context.Context, id StaticSiteId) (result ListStaticSiteSecretsOperationResponse, err error) { - req, err := c.preparerForListStaticSiteSecrets(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ListStaticSiteSecrets", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ListStaticSiteSecrets", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListStaticSiteSecrets(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ListStaticSiteSecrets", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListStaticSiteSecrets prepares the ListStaticSiteSecrets request. -func (c StaticSitesClient) preparerForListStaticSiteSecrets(ctx context.Context, id StaticSiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/listSecrets", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListStaticSiteSecrets handles the response to the ListStaticSiteSecrets request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForListStaticSiteSecrets(resp *http.Response) (result ListStaticSiteSecretsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_liststaticsiteusers.go b/resource-manager/web/2022-09-01/staticsites/method_liststaticsiteusers.go new file mode 100644 index 00000000000..67361a4c84d --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_liststaticsiteusers.go @@ -0,0 +1,89 @@ +package staticsites + +import ( + "context" + "fmt" + "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 ListStaticSiteUsersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StaticSiteUserARMResource +} + +type ListStaticSiteUsersCompleteResult struct { + Items []StaticSiteUserARMResource +} + +// ListStaticSiteUsers ... +func (c StaticSitesClient) ListStaticSiteUsers(ctx context.Context, id AuthProviderId) (result ListStaticSiteUsersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listUsers", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]StaticSiteUserARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListStaticSiteUsersComplete retrieves all the results into a single object +func (c StaticSitesClient) ListStaticSiteUsersComplete(ctx context.Context, id AuthProviderId) (ListStaticSiteUsersCompleteResult, error) { + return c.ListStaticSiteUsersCompleteMatchingPredicate(ctx, id, StaticSiteUserARMResourceOperationPredicate{}) +} + +// ListStaticSiteUsersCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) ListStaticSiteUsersCompleteMatchingPredicate(ctx context.Context, id AuthProviderId, predicate StaticSiteUserARMResourceOperationPredicate) (result ListStaticSiteUsersCompleteResult, err error) { + items := make([]StaticSiteUserARMResource, 0) + + resp, err := c.ListStaticSiteUsers(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListStaticSiteUsersCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_liststaticsiteusers_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_liststaticsiteusers_autorest.go deleted file mode 100644 index ec6067ba920..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_liststaticsiteusers_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package staticsites - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListStaticSiteUsersOperationResponse struct { - HttpResponse *http.Response - Model *[]StaticSiteUserARMResource - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListStaticSiteUsersOperationResponse, error) -} - -type ListStaticSiteUsersCompleteResult struct { - Items []StaticSiteUserARMResource -} - -func (r ListStaticSiteUsersOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListStaticSiteUsersOperationResponse) LoadMore(ctx context.Context) (resp ListStaticSiteUsersOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListStaticSiteUsers ... -func (c StaticSitesClient) ListStaticSiteUsers(ctx context.Context, id AuthProviderId) (resp ListStaticSiteUsersOperationResponse, err error) { - req, err := c.preparerForListStaticSiteUsers(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ListStaticSiteUsers", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ListStaticSiteUsers", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListStaticSiteUsers(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ListStaticSiteUsers", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListStaticSiteUsers prepares the ListStaticSiteUsers request. -func (c StaticSitesClient) preparerForListStaticSiteUsers(ctx context.Context, id AuthProviderId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/listUsers", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListStaticSiteUsersWithNextLink prepares the ListStaticSiteUsers request with the given nextLink token. -func (c StaticSitesClient) preparerForListStaticSiteUsersWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListStaticSiteUsers handles the response to the ListStaticSiteUsers request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForListStaticSiteUsers(resp *http.Response) (result ListStaticSiteUsersOperationResponse, err error) { - type page struct { - Values []StaticSiteUserARMResource `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListStaticSiteUsersOperationResponse, err error) { - req, err := c.preparerForListStaticSiteUsersWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ListStaticSiteUsers", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ListStaticSiteUsers", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListStaticSiteUsers(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ListStaticSiteUsers", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListStaticSiteUsersComplete retrieves all of the results into a single object -func (c StaticSitesClient) ListStaticSiteUsersComplete(ctx context.Context, id AuthProviderId) (ListStaticSiteUsersCompleteResult, error) { - return c.ListStaticSiteUsersCompleteMatchingPredicate(ctx, id, StaticSiteUserARMResourceOperationPredicate{}) -} - -// ListStaticSiteUsersCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c StaticSitesClient) ListStaticSiteUsersCompleteMatchingPredicate(ctx context.Context, id AuthProviderId, predicate StaticSiteUserARMResourceOperationPredicate) (resp ListStaticSiteUsersCompleteResult, err error) { - items := make([]StaticSiteUserARMResource, 0) - - page, err := c.ListStaticSiteUsers(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListStaticSiteUsersCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_previewworkflow.go b/resource-manager/web/2022-09-01/staticsites/method_previewworkflow.go new file mode 100644 index 00000000000..8f9f66dcd94 --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_previewworkflow.go @@ -0,0 +1,56 @@ +package staticsites + +import ( + "context" + "fmt" + "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 PreviewWorkflowOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticSitesWorkflowPreview +} + +// PreviewWorkflow ... +func (c StaticSitesClient) PreviewWorkflow(ctx context.Context, id ProviderLocationId, input StaticSitesWorkflowPreviewRequest) (result PreviewWorkflowOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/previewStaticSiteWorkflowFile", 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 +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_previewworkflow_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_previewworkflow_autorest.go deleted file mode 100644 index 034ec9fba00..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_previewworkflow_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package staticsites - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PreviewWorkflowOperationResponse struct { - HttpResponse *http.Response - Model *StaticSitesWorkflowPreview -} - -// PreviewWorkflow ... -func (c StaticSitesClient) PreviewWorkflow(ctx context.Context, id ProviderLocationId, input StaticSitesWorkflowPreviewRequest) (result PreviewWorkflowOperationResponse, err error) { - req, err := c.preparerForPreviewWorkflow(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "PreviewWorkflow", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "PreviewWorkflow", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForPreviewWorkflow(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "PreviewWorkflow", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForPreviewWorkflow prepares the PreviewWorkflow request. -func (c StaticSitesClient) preparerForPreviewWorkflow(ctx context.Context, id ProviderLocationId, input StaticSitesWorkflowPreviewRequest) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/previewStaticSiteWorkflowFile", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForPreviewWorkflow handles the response to the PreviewWorkflow request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForPreviewWorkflow(resp *http.Response) (result PreviewWorkflowOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_registeruserprovidedfunctionappwithstaticsite.go b/resource-manager/web/2022-09-01/staticsites/method_registeruserprovidedfunctionappwithstaticsite.go new file mode 100644 index 00000000000..472ab5db8ee --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_registeruserprovidedfunctionappwithstaticsite.go @@ -0,0 +1,102 @@ +package staticsites + +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 RegisterUserProvidedFunctionAppWithStaticSiteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +type RegisterUserProvidedFunctionAppWithStaticSiteOperationOptions struct { + IsForced *bool +} + +func DefaultRegisterUserProvidedFunctionAppWithStaticSiteOperationOptions() RegisterUserProvidedFunctionAppWithStaticSiteOperationOptions { + return RegisterUserProvidedFunctionAppWithStaticSiteOperationOptions{} +} + +func (o RegisterUserProvidedFunctionAppWithStaticSiteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o RegisterUserProvidedFunctionAppWithStaticSiteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o RegisterUserProvidedFunctionAppWithStaticSiteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.IsForced != nil { + out.Append("isForced", fmt.Sprintf("%v", *o.IsForced)) + } + return &out +} + +// RegisterUserProvidedFunctionAppWithStaticSite ... +func (c StaticSitesClient) RegisterUserProvidedFunctionAppWithStaticSite(ctx context.Context, id UserProvidedFunctionAppId, input StaticSiteUserProvidedFunctionAppARMResource, options RegisterUserProvidedFunctionAppWithStaticSiteOperationOptions) (result RegisterUserProvidedFunctionAppWithStaticSiteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// RegisterUserProvidedFunctionAppWithStaticSiteThenPoll performs RegisterUserProvidedFunctionAppWithStaticSite then polls until it's completed +func (c StaticSitesClient) RegisterUserProvidedFunctionAppWithStaticSiteThenPoll(ctx context.Context, id UserProvidedFunctionAppId, input StaticSiteUserProvidedFunctionAppARMResource, options RegisterUserProvidedFunctionAppWithStaticSiteOperationOptions) error { + result, err := c.RegisterUserProvidedFunctionAppWithStaticSite(ctx, id, input, options) + if err != nil { + return fmt.Errorf("performing RegisterUserProvidedFunctionAppWithStaticSite: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RegisterUserProvidedFunctionAppWithStaticSite: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_registeruserprovidedfunctionappwithstaticsite_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_registeruserprovidedfunctionappwithstaticsite_autorest.go deleted file mode 100644 index febb81ed8e5..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_registeruserprovidedfunctionappwithstaticsite_autorest.go +++ /dev/null @@ -1,108 +0,0 @@ -package staticsites - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type RegisterUserProvidedFunctionAppWithStaticSiteOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -type RegisterUserProvidedFunctionAppWithStaticSiteOperationOptions struct { - IsForced *bool -} - -func DefaultRegisterUserProvidedFunctionAppWithStaticSiteOperationOptions() RegisterUserProvidedFunctionAppWithStaticSiteOperationOptions { - return RegisterUserProvidedFunctionAppWithStaticSiteOperationOptions{} -} - -func (o RegisterUserProvidedFunctionAppWithStaticSiteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o RegisterUserProvidedFunctionAppWithStaticSiteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IsForced != nil { - out["isForced"] = *o.IsForced - } - - return out -} - -// RegisterUserProvidedFunctionAppWithStaticSite ... -func (c StaticSitesClient) RegisterUserProvidedFunctionAppWithStaticSite(ctx context.Context, id UserProvidedFunctionAppId, input StaticSiteUserProvidedFunctionAppARMResource, options RegisterUserProvidedFunctionAppWithStaticSiteOperationOptions) (result RegisterUserProvidedFunctionAppWithStaticSiteOperationResponse, err error) { - req, err := c.preparerForRegisterUserProvidedFunctionAppWithStaticSite(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "RegisterUserProvidedFunctionAppWithStaticSite", nil, "Failure preparing request") - return - } - - result, err = c.senderForRegisterUserProvidedFunctionAppWithStaticSite(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "RegisterUserProvidedFunctionAppWithStaticSite", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// RegisterUserProvidedFunctionAppWithStaticSiteThenPoll performs RegisterUserProvidedFunctionAppWithStaticSite then polls until it's completed -func (c StaticSitesClient) RegisterUserProvidedFunctionAppWithStaticSiteThenPoll(ctx context.Context, id UserProvidedFunctionAppId, input StaticSiteUserProvidedFunctionAppARMResource, options RegisterUserProvidedFunctionAppWithStaticSiteOperationOptions) error { - result, err := c.RegisterUserProvidedFunctionAppWithStaticSite(ctx, id, input, options) - if err != nil { - return fmt.Errorf("performing RegisterUserProvidedFunctionAppWithStaticSite: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after RegisterUserProvidedFunctionAppWithStaticSite: %+v", err) - } - - return nil -} - -// preparerForRegisterUserProvidedFunctionAppWithStaticSite prepares the RegisterUserProvidedFunctionAppWithStaticSite request. -func (c StaticSitesClient) preparerForRegisterUserProvidedFunctionAppWithStaticSite(ctx context.Context, id UserProvidedFunctionAppId, input StaticSiteUserProvidedFunctionAppARMResource, options RegisterUserProvidedFunctionAppWithStaticSiteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForRegisterUserProvidedFunctionAppWithStaticSite sends the RegisterUserProvidedFunctionAppWithStaticSite request. The method will close the -// http.Response Body if it receives an error. -func (c StaticSitesClient) senderForRegisterUserProvidedFunctionAppWithStaticSite(ctx context.Context, req *http.Request) (future RegisterUserProvidedFunctionAppWithStaticSiteOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_registeruserprovidedfunctionappwithstaticsitebuild.go b/resource-manager/web/2022-09-01/staticsites/method_registeruserprovidedfunctionappwithstaticsitebuild.go new file mode 100644 index 00000000000..b1de7406824 --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_registeruserprovidedfunctionappwithstaticsitebuild.go @@ -0,0 +1,102 @@ +package staticsites + +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 RegisterUserProvidedFunctionAppWithStaticSiteBuildOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +type RegisterUserProvidedFunctionAppWithStaticSiteBuildOperationOptions struct { + IsForced *bool +} + +func DefaultRegisterUserProvidedFunctionAppWithStaticSiteBuildOperationOptions() RegisterUserProvidedFunctionAppWithStaticSiteBuildOperationOptions { + return RegisterUserProvidedFunctionAppWithStaticSiteBuildOperationOptions{} +} + +func (o RegisterUserProvidedFunctionAppWithStaticSiteBuildOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o RegisterUserProvidedFunctionAppWithStaticSiteBuildOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o RegisterUserProvidedFunctionAppWithStaticSiteBuildOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.IsForced != nil { + out.Append("isForced", fmt.Sprintf("%v", *o.IsForced)) + } + return &out +} + +// RegisterUserProvidedFunctionAppWithStaticSiteBuild ... +func (c StaticSitesClient) RegisterUserProvidedFunctionAppWithStaticSiteBuild(ctx context.Context, id BuildUserProvidedFunctionAppId, input StaticSiteUserProvidedFunctionAppARMResource, options RegisterUserProvidedFunctionAppWithStaticSiteBuildOperationOptions) (result RegisterUserProvidedFunctionAppWithStaticSiteBuildOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// RegisterUserProvidedFunctionAppWithStaticSiteBuildThenPoll performs RegisterUserProvidedFunctionAppWithStaticSiteBuild then polls until it's completed +func (c StaticSitesClient) RegisterUserProvidedFunctionAppWithStaticSiteBuildThenPoll(ctx context.Context, id BuildUserProvidedFunctionAppId, input StaticSiteUserProvidedFunctionAppARMResource, options RegisterUserProvidedFunctionAppWithStaticSiteBuildOperationOptions) error { + result, err := c.RegisterUserProvidedFunctionAppWithStaticSiteBuild(ctx, id, input, options) + if err != nil { + return fmt.Errorf("performing RegisterUserProvidedFunctionAppWithStaticSiteBuild: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RegisterUserProvidedFunctionAppWithStaticSiteBuild: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_registeruserprovidedfunctionappwithstaticsitebuild_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_registeruserprovidedfunctionappwithstaticsitebuild_autorest.go deleted file mode 100644 index 738f6467c60..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_registeruserprovidedfunctionappwithstaticsitebuild_autorest.go +++ /dev/null @@ -1,108 +0,0 @@ -package staticsites - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type RegisterUserProvidedFunctionAppWithStaticSiteBuildOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -type RegisterUserProvidedFunctionAppWithStaticSiteBuildOperationOptions struct { - IsForced *bool -} - -func DefaultRegisterUserProvidedFunctionAppWithStaticSiteBuildOperationOptions() RegisterUserProvidedFunctionAppWithStaticSiteBuildOperationOptions { - return RegisterUserProvidedFunctionAppWithStaticSiteBuildOperationOptions{} -} - -func (o RegisterUserProvidedFunctionAppWithStaticSiteBuildOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o RegisterUserProvidedFunctionAppWithStaticSiteBuildOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IsForced != nil { - out["isForced"] = *o.IsForced - } - - return out -} - -// RegisterUserProvidedFunctionAppWithStaticSiteBuild ... -func (c StaticSitesClient) RegisterUserProvidedFunctionAppWithStaticSiteBuild(ctx context.Context, id BuildUserProvidedFunctionAppId, input StaticSiteUserProvidedFunctionAppARMResource, options RegisterUserProvidedFunctionAppWithStaticSiteBuildOperationOptions) (result RegisterUserProvidedFunctionAppWithStaticSiteBuildOperationResponse, err error) { - req, err := c.preparerForRegisterUserProvidedFunctionAppWithStaticSiteBuild(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "RegisterUserProvidedFunctionAppWithStaticSiteBuild", nil, "Failure preparing request") - return - } - - result, err = c.senderForRegisterUserProvidedFunctionAppWithStaticSiteBuild(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "RegisterUserProvidedFunctionAppWithStaticSiteBuild", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// RegisterUserProvidedFunctionAppWithStaticSiteBuildThenPoll performs RegisterUserProvidedFunctionAppWithStaticSiteBuild then polls until it's completed -func (c StaticSitesClient) RegisterUserProvidedFunctionAppWithStaticSiteBuildThenPoll(ctx context.Context, id BuildUserProvidedFunctionAppId, input StaticSiteUserProvidedFunctionAppARMResource, options RegisterUserProvidedFunctionAppWithStaticSiteBuildOperationOptions) error { - result, err := c.RegisterUserProvidedFunctionAppWithStaticSiteBuild(ctx, id, input, options) - if err != nil { - return fmt.Errorf("performing RegisterUserProvidedFunctionAppWithStaticSiteBuild: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after RegisterUserProvidedFunctionAppWithStaticSiteBuild: %+v", err) - } - - return nil -} - -// preparerForRegisterUserProvidedFunctionAppWithStaticSiteBuild prepares the RegisterUserProvidedFunctionAppWithStaticSiteBuild request. -func (c StaticSitesClient) preparerForRegisterUserProvidedFunctionAppWithStaticSiteBuild(ctx context.Context, id BuildUserProvidedFunctionAppId, input StaticSiteUserProvidedFunctionAppARMResource, options RegisterUserProvidedFunctionAppWithStaticSiteBuildOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForRegisterUserProvidedFunctionAppWithStaticSiteBuild sends the RegisterUserProvidedFunctionAppWithStaticSiteBuild request. The method will close the -// http.Response Body if it receives an error. -func (c StaticSitesClient) senderForRegisterUserProvidedFunctionAppWithStaticSiteBuild(ctx context.Context, req *http.Request) (future RegisterUserProvidedFunctionAppWithStaticSiteBuildOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_resetstaticsiteapikey.go b/resource-manager/web/2022-09-01/staticsites/method_resetstaticsiteapikey.go new file mode 100644 index 00000000000..24124e02fb0 --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_resetstaticsiteapikey.go @@ -0,0 +1,51 @@ +package staticsites + +import ( + "context" + "fmt" + "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 ResetStaticSiteApiKeyOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ResetStaticSiteApiKey ... +func (c StaticSitesClient) ResetStaticSiteApiKey(ctx context.Context, id StaticSiteId, input StaticSiteResetPropertiesARMResource) (result ResetStaticSiteApiKeyOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resetapikey", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_resetstaticsiteapikey_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_resetstaticsiteapikey_autorest.go deleted file mode 100644 index e6da5dc6154..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_resetstaticsiteapikey_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package staticsites - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ResetStaticSiteApiKeyOperationResponse struct { - HttpResponse *http.Response -} - -// ResetStaticSiteApiKey ... -func (c StaticSitesClient) ResetStaticSiteApiKey(ctx context.Context, id StaticSiteId, input StaticSiteResetPropertiesARMResource) (result ResetStaticSiteApiKeyOperationResponse, err error) { - req, err := c.preparerForResetStaticSiteApiKey(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ResetStaticSiteApiKey", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ResetStaticSiteApiKey", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForResetStaticSiteApiKey(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ResetStaticSiteApiKey", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForResetStaticSiteApiKey prepares the ResetStaticSiteApiKey request. -func (c StaticSitesClient) preparerForResetStaticSiteApiKey(ctx context.Context, id StaticSiteId, input StaticSiteResetPropertiesARMResource) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/resetapikey", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForResetStaticSiteApiKey handles the response to the ResetStaticSiteApiKey request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForResetStaticSiteApiKey(resp *http.Response) (result ResetStaticSiteApiKeyOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_unlinkbackend.go b/resource-manager/web/2022-09-01/staticsites/method_unlinkbackend.go new file mode 100644 index 00000000000..9fd84645a94 --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_unlinkbackend.go @@ -0,0 +1,76 @@ +package staticsites + +import ( + "context" + "fmt" + "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 UnlinkBackendOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type UnlinkBackendOperationOptions struct { + IsCleaningAuthConfig *bool +} + +func DefaultUnlinkBackendOperationOptions() UnlinkBackendOperationOptions { + return UnlinkBackendOperationOptions{} +} + +func (o UnlinkBackendOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o UnlinkBackendOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UnlinkBackendOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.IsCleaningAuthConfig != nil { + out.Append("isCleaningAuthConfig", fmt.Sprintf("%v", *o.IsCleaningAuthConfig)) + } + return &out +} + +// UnlinkBackend ... +func (c StaticSitesClient) UnlinkBackend(ctx context.Context, id LinkedBackendId, options UnlinkBackendOperationOptions) (result UnlinkBackendOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_unlinkbackend_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_unlinkbackend_autorest.go deleted file mode 100644 index 75e71092369..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_unlinkbackend_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package staticsites - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UnlinkBackendOperationResponse struct { - HttpResponse *http.Response -} - -type UnlinkBackendOperationOptions struct { - IsCleaningAuthConfig *bool -} - -func DefaultUnlinkBackendOperationOptions() UnlinkBackendOperationOptions { - return UnlinkBackendOperationOptions{} -} - -func (o UnlinkBackendOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o UnlinkBackendOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IsCleaningAuthConfig != nil { - out["isCleaningAuthConfig"] = *o.IsCleaningAuthConfig - } - - return out -} - -// UnlinkBackend ... -func (c StaticSitesClient) UnlinkBackend(ctx context.Context, id LinkedBackendId, options UnlinkBackendOperationOptions) (result UnlinkBackendOperationResponse, err error) { - req, err := c.preparerForUnlinkBackend(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "UnlinkBackend", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "UnlinkBackend", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUnlinkBackend(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "UnlinkBackend", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUnlinkBackend prepares the UnlinkBackend request. -func (c StaticSitesClient) preparerForUnlinkBackend(ctx context.Context, id LinkedBackendId, options UnlinkBackendOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUnlinkBackend handles the response to the UnlinkBackend request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForUnlinkBackend(resp *http.Response) (result UnlinkBackendOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_unlinkbackendfrombuild.go b/resource-manager/web/2022-09-01/staticsites/method_unlinkbackendfrombuild.go new file mode 100644 index 00000000000..cd48013b639 --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_unlinkbackendfrombuild.go @@ -0,0 +1,76 @@ +package staticsites + +import ( + "context" + "fmt" + "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 UnlinkBackendFromBuildOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type UnlinkBackendFromBuildOperationOptions struct { + IsCleaningAuthConfig *bool +} + +func DefaultUnlinkBackendFromBuildOperationOptions() UnlinkBackendFromBuildOperationOptions { + return UnlinkBackendFromBuildOperationOptions{} +} + +func (o UnlinkBackendFromBuildOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o UnlinkBackendFromBuildOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UnlinkBackendFromBuildOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.IsCleaningAuthConfig != nil { + out.Append("isCleaningAuthConfig", fmt.Sprintf("%v", *o.IsCleaningAuthConfig)) + } + return &out +} + +// UnlinkBackendFromBuild ... +func (c StaticSitesClient) UnlinkBackendFromBuild(ctx context.Context, id BuildLinkedBackendId, options UnlinkBackendFromBuildOperationOptions) (result UnlinkBackendFromBuildOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_unlinkbackendfrombuild_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_unlinkbackendfrombuild_autorest.go deleted file mode 100644 index 1ccf3a6ab5b..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_unlinkbackendfrombuild_autorest.go +++ /dev/null @@ -1,95 +0,0 @@ -package staticsites - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UnlinkBackendFromBuildOperationResponse struct { - HttpResponse *http.Response -} - -type UnlinkBackendFromBuildOperationOptions struct { - IsCleaningAuthConfig *bool -} - -func DefaultUnlinkBackendFromBuildOperationOptions() UnlinkBackendFromBuildOperationOptions { - return UnlinkBackendFromBuildOperationOptions{} -} - -func (o UnlinkBackendFromBuildOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o UnlinkBackendFromBuildOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IsCleaningAuthConfig != nil { - out["isCleaningAuthConfig"] = *o.IsCleaningAuthConfig - } - - return out -} - -// UnlinkBackendFromBuild ... -func (c StaticSitesClient) UnlinkBackendFromBuild(ctx context.Context, id BuildLinkedBackendId, options UnlinkBackendFromBuildOperationOptions) (result UnlinkBackendFromBuildOperationResponse, err error) { - req, err := c.preparerForUnlinkBackendFromBuild(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "UnlinkBackendFromBuild", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "UnlinkBackendFromBuild", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUnlinkBackendFromBuild(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "UnlinkBackendFromBuild", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUnlinkBackendFromBuild prepares the UnlinkBackendFromBuild request. -func (c StaticSitesClient) preparerForUnlinkBackendFromBuild(ctx context.Context, id BuildLinkedBackendId, options UnlinkBackendFromBuildOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUnlinkBackendFromBuild handles the response to the UnlinkBackendFromBuild request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForUnlinkBackendFromBuild(resp *http.Response) (result UnlinkBackendFromBuildOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_updatebuilddatabaseconnection.go b/resource-manager/web/2022-09-01/staticsites/method_updatebuilddatabaseconnection.go new file mode 100644 index 00000000000..0a6bceecf45 --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_updatebuilddatabaseconnection.go @@ -0,0 +1,55 @@ +package staticsites + +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 UpdateBuildDatabaseConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DatabaseConnection +} + +// UpdateBuildDatabaseConnection ... +func (c StaticSitesClient) UpdateBuildDatabaseConnection(ctx context.Context, id BuildDatabaseConnectionId, input DatabaseConnectionPatchRequest) (result UpdateBuildDatabaseConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + 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 +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_updatebuilddatabaseconnection_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_updatebuilddatabaseconnection_autorest.go deleted file mode 100644 index 0cea9f697eb..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_updatebuilddatabaseconnection_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package staticsites - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateBuildDatabaseConnectionOperationResponse struct { - HttpResponse *http.Response - Model *DatabaseConnection -} - -// UpdateBuildDatabaseConnection ... -func (c StaticSitesClient) UpdateBuildDatabaseConnection(ctx context.Context, id BuildDatabaseConnectionId, input DatabaseConnectionPatchRequest) (result UpdateBuildDatabaseConnectionOperationResponse, err error) { - req, err := c.preparerForUpdateBuildDatabaseConnection(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "UpdateBuildDatabaseConnection", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "UpdateBuildDatabaseConnection", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateBuildDatabaseConnection(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "UpdateBuildDatabaseConnection", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateBuildDatabaseConnection prepares the UpdateBuildDatabaseConnection request. -func (c StaticSitesClient) preparerForUpdateBuildDatabaseConnection(ctx context.Context, id BuildDatabaseConnectionId, input DatabaseConnectionPatchRequest) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateBuildDatabaseConnection handles the response to the UpdateBuildDatabaseConnection request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForUpdateBuildDatabaseConnection(resp *http.Response) (result UpdateBuildDatabaseConnectionOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_updatedatabaseconnection.go b/resource-manager/web/2022-09-01/staticsites/method_updatedatabaseconnection.go new file mode 100644 index 00000000000..a529c3e9a3e --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_updatedatabaseconnection.go @@ -0,0 +1,55 @@ +package staticsites + +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 UpdateDatabaseConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DatabaseConnection +} + +// UpdateDatabaseConnection ... +func (c StaticSitesClient) UpdateDatabaseConnection(ctx context.Context, id DatabaseConnectionId, input DatabaseConnectionPatchRequest) (result UpdateDatabaseConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + 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 +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_updatedatabaseconnection_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_updatedatabaseconnection_autorest.go deleted file mode 100644 index 171c6bc3f09..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_updatedatabaseconnection_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package staticsites - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateDatabaseConnectionOperationResponse struct { - HttpResponse *http.Response - Model *DatabaseConnection -} - -// UpdateDatabaseConnection ... -func (c StaticSitesClient) UpdateDatabaseConnection(ctx context.Context, id DatabaseConnectionId, input DatabaseConnectionPatchRequest) (result UpdateDatabaseConnectionOperationResponse, err error) { - req, err := c.preparerForUpdateDatabaseConnection(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "UpdateDatabaseConnection", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "UpdateDatabaseConnection", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateDatabaseConnection(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "UpdateDatabaseConnection", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateDatabaseConnection prepares the UpdateDatabaseConnection request. -func (c StaticSitesClient) preparerForUpdateDatabaseConnection(ctx context.Context, id DatabaseConnectionId, input DatabaseConnectionPatchRequest) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateDatabaseConnection handles the response to the UpdateDatabaseConnection request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForUpdateDatabaseConnection(resp *http.Response) (result UpdateDatabaseConnectionOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_updatestaticsite.go b/resource-manager/web/2022-09-01/staticsites/method_updatestaticsite.go new file mode 100644 index 00000000000..14c07594aa0 --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_updatestaticsite.go @@ -0,0 +1,56 @@ +package staticsites + +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 UpdateStaticSiteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteARMResource +} + +// UpdateStaticSite ... +func (c StaticSitesClient) UpdateStaticSite(ctx context.Context, id StaticSiteId, input StaticSitePatchResource) (result UpdateStaticSiteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + 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 +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_updatestaticsite_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_updatestaticsite_autorest.go deleted file mode 100644 index f94d20cd1a7..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_updatestaticsite_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package staticsites - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateStaticSiteOperationResponse struct { - HttpResponse *http.Response - Model *StaticSiteARMResource -} - -// UpdateStaticSite ... -func (c StaticSitesClient) UpdateStaticSite(ctx context.Context, id StaticSiteId, input StaticSitePatchResource) (result UpdateStaticSiteOperationResponse, err error) { - req, err := c.preparerForUpdateStaticSite(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "UpdateStaticSite", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "UpdateStaticSite", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateStaticSite(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "UpdateStaticSite", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateStaticSite prepares the UpdateStaticSite request. -func (c StaticSitesClient) preparerForUpdateStaticSite(ctx context.Context, id StaticSiteId, input StaticSitePatchResource) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateStaticSite handles the response to the UpdateStaticSite request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForUpdateStaticSite(resp *http.Response) (result UpdateStaticSiteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_updatestaticsiteuser.go b/resource-manager/web/2022-09-01/staticsites/method_updatestaticsiteuser.go new file mode 100644 index 00000000000..2690a911ee5 --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_updatestaticsiteuser.go @@ -0,0 +1,55 @@ +package staticsites + +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 UpdateStaticSiteUserOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteUserARMResource +} + +// UpdateStaticSiteUser ... +func (c StaticSitesClient) UpdateStaticSiteUser(ctx context.Context, id UserId, input StaticSiteUserARMResource) (result UpdateStaticSiteUserOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + 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 +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_updatestaticsiteuser_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_updatestaticsiteuser_autorest.go deleted file mode 100644 index c0e41f4aa88..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_updatestaticsiteuser_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package staticsites - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateStaticSiteUserOperationResponse struct { - HttpResponse *http.Response - Model *StaticSiteUserARMResource -} - -// UpdateStaticSiteUser ... -func (c StaticSitesClient) UpdateStaticSiteUser(ctx context.Context, id UserId, input StaticSiteUserARMResource) (result UpdateStaticSiteUserOperationResponse, err error) { - req, err := c.preparerForUpdateStaticSiteUser(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "UpdateStaticSiteUser", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "UpdateStaticSiteUser", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateStaticSiteUser(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "UpdateStaticSiteUser", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateStaticSiteUser prepares the UpdateStaticSiteUser request. -func (c StaticSitesClient) preparerForUpdateStaticSiteUser(ctx context.Context, id UserId, input StaticSiteUserARMResource) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateStaticSiteUser handles the response to the UpdateStaticSiteUser request. The method always -// closes the http.Response Body. -func (c StaticSitesClient) responderForUpdateStaticSiteUser(resp *http.Response) (result UpdateStaticSiteUserOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_validatebackend.go b/resource-manager/web/2022-09-01/staticsites/method_validatebackend.go new file mode 100644 index 00000000000..516b6afea03 --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_validatebackend.go @@ -0,0 +1,74 @@ +package staticsites + +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 ValidateBackendOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ValidateBackend ... +func (c StaticSitesClient) ValidateBackend(ctx context.Context, id LinkedBackendId, input StaticSiteLinkedBackendARMResource) (result ValidateBackendOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/validate", 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 +} + +// ValidateBackendThenPoll performs ValidateBackend then polls until it's completed +func (c StaticSitesClient) ValidateBackendThenPoll(ctx context.Context, id LinkedBackendId, input StaticSiteLinkedBackendARMResource) error { + result, err := c.ValidateBackend(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ValidateBackend: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ValidateBackend: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_validatebackend_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_validatebackend_autorest.go deleted file mode 100644 index daeb8d29c24..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_validatebackend_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package staticsites - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ValidateBackendOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// ValidateBackend ... -func (c StaticSitesClient) ValidateBackend(ctx context.Context, id LinkedBackendId, input StaticSiteLinkedBackendARMResource) (result ValidateBackendOperationResponse, err error) { - req, err := c.preparerForValidateBackend(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ValidateBackend", nil, "Failure preparing request") - return - } - - result, err = c.senderForValidateBackend(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ValidateBackend", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// ValidateBackendThenPoll performs ValidateBackend then polls until it's completed -func (c StaticSitesClient) ValidateBackendThenPoll(ctx context.Context, id LinkedBackendId, input StaticSiteLinkedBackendARMResource) error { - result, err := c.ValidateBackend(ctx, id, input) - if err != nil { - return fmt.Errorf("performing ValidateBackend: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after ValidateBackend: %+v", err) - } - - return nil -} - -// preparerForValidateBackend prepares the ValidateBackend request. -func (c StaticSitesClient) preparerForValidateBackend(ctx context.Context, id LinkedBackendId, input StaticSiteLinkedBackendARMResource) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/validate", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForValidateBackend sends the ValidateBackend request. The method will close the -// http.Response Body if it receives an error. -func (c StaticSitesClient) senderForValidateBackend(ctx context.Context, req *http.Request) (future ValidateBackendOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_validatebackendforbuild.go b/resource-manager/web/2022-09-01/staticsites/method_validatebackendforbuild.go new file mode 100644 index 00000000000..4ca47a3996f --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_validatebackendforbuild.go @@ -0,0 +1,74 @@ +package staticsites + +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 ValidateBackendForBuildOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ValidateBackendForBuild ... +func (c StaticSitesClient) ValidateBackendForBuild(ctx context.Context, id BuildLinkedBackendId, input StaticSiteLinkedBackendARMResource) (result ValidateBackendForBuildOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/validate", 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 +} + +// ValidateBackendForBuildThenPoll performs ValidateBackendForBuild then polls until it's completed +func (c StaticSitesClient) ValidateBackendForBuildThenPoll(ctx context.Context, id BuildLinkedBackendId, input StaticSiteLinkedBackendARMResource) error { + result, err := c.ValidateBackendForBuild(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ValidateBackendForBuild: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ValidateBackendForBuild: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_validatebackendforbuild_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_validatebackendforbuild_autorest.go deleted file mode 100644 index 6fd80df2f27..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_validatebackendforbuild_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package staticsites - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ValidateBackendForBuildOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// ValidateBackendForBuild ... -func (c StaticSitesClient) ValidateBackendForBuild(ctx context.Context, id BuildLinkedBackendId, input StaticSiteLinkedBackendARMResource) (result ValidateBackendForBuildOperationResponse, err error) { - req, err := c.preparerForValidateBackendForBuild(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ValidateBackendForBuild", nil, "Failure preparing request") - return - } - - result, err = c.senderForValidateBackendForBuild(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ValidateBackendForBuild", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// ValidateBackendForBuildThenPoll performs ValidateBackendForBuild then polls until it's completed -func (c StaticSitesClient) ValidateBackendForBuildThenPoll(ctx context.Context, id BuildLinkedBackendId, input StaticSiteLinkedBackendARMResource) error { - result, err := c.ValidateBackendForBuild(ctx, id, input) - if err != nil { - return fmt.Errorf("performing ValidateBackendForBuild: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after ValidateBackendForBuild: %+v", err) - } - - return nil -} - -// preparerForValidateBackendForBuild prepares the ValidateBackendForBuild request. -func (c StaticSitesClient) preparerForValidateBackendForBuild(ctx context.Context, id BuildLinkedBackendId, input StaticSiteLinkedBackendARMResource) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/validate", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForValidateBackendForBuild sends the ValidateBackendForBuild request. The method will close the -// http.Response Body if it receives an error. -func (c StaticSitesClient) senderForValidateBackendForBuild(ctx context.Context, req *http.Request) (future ValidateBackendForBuildOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/staticsites/method_validatecustomdomaincanbeaddedtostaticsite.go b/resource-manager/web/2022-09-01/staticsites/method_validatecustomdomaincanbeaddedtostaticsite.go new file mode 100644 index 00000000000..68c4697c472 --- /dev/null +++ b/resource-manager/web/2022-09-01/staticsites/method_validatecustomdomaincanbeaddedtostaticsite.go @@ -0,0 +1,74 @@ +package staticsites + +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 ValidateCustomDomainCanBeAddedToStaticSiteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ValidateCustomDomainCanBeAddedToStaticSite ... +func (c StaticSitesClient) ValidateCustomDomainCanBeAddedToStaticSite(ctx context.Context, id CustomDomainId, input StaticSiteCustomDomainRequestPropertiesARMResource) (result ValidateCustomDomainCanBeAddedToStaticSiteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/validate", 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 +} + +// ValidateCustomDomainCanBeAddedToStaticSiteThenPoll performs ValidateCustomDomainCanBeAddedToStaticSite then polls until it's completed +func (c StaticSitesClient) ValidateCustomDomainCanBeAddedToStaticSiteThenPoll(ctx context.Context, id CustomDomainId, input StaticSiteCustomDomainRequestPropertiesARMResource) error { + result, err := c.ValidateCustomDomainCanBeAddedToStaticSite(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ValidateCustomDomainCanBeAddedToStaticSite: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ValidateCustomDomainCanBeAddedToStaticSite: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/staticsites/method_validatecustomdomaincanbeaddedtostaticsite_autorest.go b/resource-manager/web/2022-09-01/staticsites/method_validatecustomdomaincanbeaddedtostaticsite_autorest.go deleted file mode 100644 index f88c9c78bfd..00000000000 --- a/resource-manager/web/2022-09-01/staticsites/method_validatecustomdomaincanbeaddedtostaticsite_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package staticsites - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ValidateCustomDomainCanBeAddedToStaticSiteOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// ValidateCustomDomainCanBeAddedToStaticSite ... -func (c StaticSitesClient) ValidateCustomDomainCanBeAddedToStaticSite(ctx context.Context, id CustomDomainId, input StaticSiteCustomDomainRequestPropertiesARMResource) (result ValidateCustomDomainCanBeAddedToStaticSiteOperationResponse, err error) { - req, err := c.preparerForValidateCustomDomainCanBeAddedToStaticSite(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ValidateCustomDomainCanBeAddedToStaticSite", nil, "Failure preparing request") - return - } - - result, err = c.senderForValidateCustomDomainCanBeAddedToStaticSite(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "staticsites.StaticSitesClient", "ValidateCustomDomainCanBeAddedToStaticSite", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// ValidateCustomDomainCanBeAddedToStaticSiteThenPoll performs ValidateCustomDomainCanBeAddedToStaticSite then polls until it's completed -func (c StaticSitesClient) ValidateCustomDomainCanBeAddedToStaticSiteThenPoll(ctx context.Context, id CustomDomainId, input StaticSiteCustomDomainRequestPropertiesARMResource) error { - result, err := c.ValidateCustomDomainCanBeAddedToStaticSite(ctx, id, input) - if err != nil { - return fmt.Errorf("performing ValidateCustomDomainCanBeAddedToStaticSite: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after ValidateCustomDomainCanBeAddedToStaticSite: %+v", err) - } - - return nil -} - -// preparerForValidateCustomDomainCanBeAddedToStaticSite prepares the ValidateCustomDomainCanBeAddedToStaticSite request. -func (c StaticSitesClient) preparerForValidateCustomDomainCanBeAddedToStaticSite(ctx context.Context, id CustomDomainId, input StaticSiteCustomDomainRequestPropertiesARMResource) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/validate", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForValidateCustomDomainCanBeAddedToStaticSite sends the ValidateCustomDomainCanBeAddedToStaticSite request. The method will close the -// http.Response Body if it receives an error. -func (c StaticSitesClient) senderForValidateCustomDomainCanBeAddedToStaticSite(ctx context.Context, req *http.Request) (future ValidateCustomDomainCanBeAddedToStaticSiteOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/topleveldomains/client.go b/resource-manager/web/2022-09-01/topleveldomains/client.go index 8426d44a670..f5f3c86c992 100644 --- a/resource-manager/web/2022-09-01/topleveldomains/client.go +++ b/resource-manager/web/2022-09-01/topleveldomains/client.go @@ -1,18 +1,26 @@ package topleveldomains -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 TopLevelDomainsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewTopLevelDomainsClientWithBaseURI(endpoint string) TopLevelDomainsClient { - return TopLevelDomainsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewTopLevelDomainsClientWithBaseURI(api environments.Api) (*TopLevelDomainsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "topleveldomains", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating TopLevelDomainsClient: %+v", err) } + + return &TopLevelDomainsClient{ + Client: client, + }, nil } diff --git a/resource-manager/web/2022-09-01/topleveldomains/method_get.go b/resource-manager/web/2022-09-01/topleveldomains/method_get.go new file mode 100644 index 00000000000..e6b645920b7 --- /dev/null +++ b/resource-manager/web/2022-09-01/topleveldomains/method_get.go @@ -0,0 +1,51 @@ +package topleveldomains + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *TopLevelDomain +} + +// Get ... +func (c TopLevelDomainsClient) Get(ctx context.Context, id TopLevelDomainId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/topleveldomains/method_get_autorest.go b/resource-manager/web/2022-09-01/topleveldomains/method_get_autorest.go deleted file mode 100644 index 55b55a42151..00000000000 --- a/resource-manager/web/2022-09-01/topleveldomains/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package topleveldomains - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *TopLevelDomain -} - -// Get ... -func (c TopLevelDomainsClient) Get(ctx context.Context, id TopLevelDomainId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "topleveldomains.TopLevelDomainsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "topleveldomains.TopLevelDomainsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "topleveldomains.TopLevelDomainsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c TopLevelDomainsClient) preparerForGet(ctx context.Context, id TopLevelDomainId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c TopLevelDomainsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/topleveldomains/method_list.go b/resource-manager/web/2022-09-01/topleveldomains/method_list.go new file mode 100644 index 00000000000..021f94454f5 --- /dev/null +++ b/resource-manager/web/2022-09-01/topleveldomains/method_list.go @@ -0,0 +1,90 @@ +package topleveldomains + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]TopLevelDomain +} + +type ListCompleteResult struct { + Items []TopLevelDomain +} + +// List ... +func (c TopLevelDomainsClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.DomainRegistration/topLevelDomains", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]TopLevelDomain `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c TopLevelDomainsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, TopLevelDomainOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c TopLevelDomainsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate TopLevelDomainOperationPredicate) (result ListCompleteResult, err error) { + items := make([]TopLevelDomain, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/topleveldomains/method_list_autorest.go b/resource-manager/web/2022-09-01/topleveldomains/method_list_autorest.go deleted file mode 100644 index fea4fb10f34..00000000000 --- a/resource-manager/web/2022-09-01/topleveldomains/method_list_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package topleveldomains - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListOperationResponse struct { - HttpResponse *http.Response - Model *[]TopLevelDomain - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []TopLevelDomain -} - -func (r ListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// List ... -func (c TopLevelDomainsClient) List(ctx context.Context, id commonids.SubscriptionId) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "topleveldomains.TopLevelDomainsClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "topleveldomains.TopLevelDomainsClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "topleveldomains.TopLevelDomainsClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c TopLevelDomainsClient) preparerForList(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.DomainRegistration/topLevelDomains", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c TopLevelDomainsClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForList handles the response to the List request. The method always -// closes the http.Response Body. -func (c TopLevelDomainsClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []TopLevelDomain `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { - req, err := c.preparerForListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "topleveldomains.TopLevelDomainsClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "topleveldomains.TopLevelDomainsClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "topleveldomains.TopLevelDomainsClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c TopLevelDomainsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, TopLevelDomainOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c TopLevelDomainsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate TopLevelDomainOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]TopLevelDomain, 0) - - page, err := c.List(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/topleveldomains/method_listagreements.go b/resource-manager/web/2022-09-01/topleveldomains/method_listagreements.go new file mode 100644 index 00000000000..9850de330d9 --- /dev/null +++ b/resource-manager/web/2022-09-01/topleveldomains/method_listagreements.go @@ -0,0 +1,89 @@ +package topleveldomains + +import ( + "context" + "fmt" + "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 ListAgreementsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]TldLegalAgreement +} + +type ListAgreementsCompleteResult struct { + Items []TldLegalAgreement +} + +// ListAgreements ... +func (c TopLevelDomainsClient) ListAgreements(ctx context.Context, id TopLevelDomainId, input TopLevelDomainAgreementOption) (result ListAgreementsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listAgreements", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]TldLegalAgreement `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAgreementsComplete retrieves all the results into a single object +func (c TopLevelDomainsClient) ListAgreementsComplete(ctx context.Context, id TopLevelDomainId, input TopLevelDomainAgreementOption) (ListAgreementsCompleteResult, error) { + return c.ListAgreementsCompleteMatchingPredicate(ctx, id, input, TldLegalAgreementOperationPredicate{}) +} + +// ListAgreementsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c TopLevelDomainsClient) ListAgreementsCompleteMatchingPredicate(ctx context.Context, id TopLevelDomainId, input TopLevelDomainAgreementOption, predicate TldLegalAgreementOperationPredicate) (result ListAgreementsCompleteResult, err error) { + items := make([]TldLegalAgreement, 0) + + resp, err := c.ListAgreements(ctx, id, input) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListAgreementsCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/topleveldomains/method_listagreements_autorest.go b/resource-manager/web/2022-09-01/topleveldomains/method_listagreements_autorest.go deleted file mode 100644 index 0172f48b777..00000000000 --- a/resource-manager/web/2022-09-01/topleveldomains/method_listagreements_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package topleveldomains - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListAgreementsOperationResponse struct { - HttpResponse *http.Response - Model *[]TldLegalAgreement - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListAgreementsOperationResponse, error) -} - -type ListAgreementsCompleteResult struct { - Items []TldLegalAgreement -} - -func (r ListAgreementsOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListAgreementsOperationResponse) LoadMore(ctx context.Context) (resp ListAgreementsOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListAgreements ... -func (c TopLevelDomainsClient) ListAgreements(ctx context.Context, id TopLevelDomainId, input TopLevelDomainAgreementOption) (resp ListAgreementsOperationResponse, err error) { - req, err := c.preparerForListAgreements(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "topleveldomains.TopLevelDomainsClient", "ListAgreements", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "topleveldomains.TopLevelDomainsClient", "ListAgreements", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListAgreements(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "topleveldomains.TopLevelDomainsClient", "ListAgreements", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListAgreements prepares the ListAgreements request. -func (c TopLevelDomainsClient) preparerForListAgreements(ctx context.Context, id TopLevelDomainId, input TopLevelDomainAgreementOption) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/listAgreements", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListAgreementsWithNextLink prepares the ListAgreements request with the given nextLink token. -func (c TopLevelDomainsClient) preparerForListAgreementsWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListAgreements handles the response to the ListAgreements request. The method always -// closes the http.Response Body. -func (c TopLevelDomainsClient) responderForListAgreements(resp *http.Response) (result ListAgreementsOperationResponse, err error) { - type page struct { - Values []TldLegalAgreement `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListAgreementsOperationResponse, err error) { - req, err := c.preparerForListAgreementsWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "topleveldomains.TopLevelDomainsClient", "ListAgreements", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "topleveldomains.TopLevelDomainsClient", "ListAgreements", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListAgreements(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "topleveldomains.TopLevelDomainsClient", "ListAgreements", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListAgreementsComplete retrieves all of the results into a single object -func (c TopLevelDomainsClient) ListAgreementsComplete(ctx context.Context, id TopLevelDomainId, input TopLevelDomainAgreementOption) (ListAgreementsCompleteResult, error) { - return c.ListAgreementsCompleteMatchingPredicate(ctx, id, input, TldLegalAgreementOperationPredicate{}) -} - -// ListAgreementsCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c TopLevelDomainsClient) ListAgreementsCompleteMatchingPredicate(ctx context.Context, id TopLevelDomainId, input TopLevelDomainAgreementOption, predicate TldLegalAgreementOperationPredicate) (resp ListAgreementsCompleteResult, err error) { - items := make([]TldLegalAgreement, 0) - - page, err := c.ListAgreements(ctx, id, input) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListAgreementsCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/client.go b/resource-manager/web/2022-09-01/webapps/client.go index 538f422f8be..ff15559f091 100644 --- a/resource-manager/web/2022-09-01/webapps/client.go +++ b/resource-manager/web/2022-09-01/webapps/client.go @@ -1,18 +1,26 @@ package webapps -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 WebAppsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewWebAppsClientWithBaseURI(endpoint string) WebAppsClient { - return WebAppsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewWebAppsClientWithBaseURI(api environments.Api) (*WebAppsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "webapps", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating WebAppsClient: %+v", err) } + + return &WebAppsClient{ + Client: client, + }, nil } diff --git a/resource-manager/web/2022-09-01/webapps/constants.go b/resource-manager/web/2022-09-01/webapps/constants.go index 781b2fcf299..73ec660decf 100644 --- a/resource-manager/web/2022-09-01/webapps/constants.go +++ b/resource-manager/web/2022-09-01/webapps/constants.go @@ -1,6 +1,10 @@ package webapps -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. @@ -21,6 +25,19 @@ func PossibleValuesForAutoHealActionType() []string { } } +func (s *AutoHealActionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutoHealActionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAutoHealActionType(input string) (*AutoHealActionType, error) { vals := map[string]AutoHealActionType{ "customaction": AutoHealActionTypeCustomAction, @@ -50,6 +67,19 @@ func PossibleValuesForAzureResourceType() []string { } } +func (s *AzureResourceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureResourceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAzureResourceType(input string) (*AzureResourceType, error) { vals := map[string]AzureResourceType{ "trafficmanager": AzureResourceTypeTrafficManager, @@ -82,6 +112,19 @@ func PossibleValuesForAzureStorageState() []string { } } +func (s *AzureStorageState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureStorageState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAzureStorageState(input string) (*AzureStorageState, error) { vals := map[string]AzureStorageState{ "invalidcredentials": AzureStorageStateInvalidCredentials, @@ -112,6 +155,19 @@ func PossibleValuesForAzureStorageType() []string { } } +func (s *AzureStorageType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureStorageType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseAzureStorageType(input string) (*AzureStorageType, error) { vals := map[string]AzureStorageType{ "azureblob": AzureStorageTypeAzureBlob, @@ -156,6 +212,19 @@ func PossibleValuesForBackupItemStatus() []string { } } +func (s *BackupItemStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBackupItemStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseBackupItemStatus(input string) (*BackupItemStatus, error) { vals := map[string]BackupItemStatus{ "created": BackupItemStatusCreated, @@ -198,6 +267,19 @@ func PossibleValuesForBackupRestoreOperationType() []string { } } +func (s *BackupRestoreOperationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBackupRestoreOperationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseBackupRestoreOperationType(input string) (*BackupRestoreOperationType, error) { vals := map[string]BackupRestoreOperationType{ "clone": BackupRestoreOperationTypeClone, @@ -237,6 +319,19 @@ func PossibleValuesForBuiltInAuthenticationProvider() []string { } } +func (s *BuiltInAuthenticationProvider) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBuiltInAuthenticationProvider(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseBuiltInAuthenticationProvider(input string) (*BuiltInAuthenticationProvider, error) { vals := map[string]BuiltInAuthenticationProvider{ "azureactivedirectory": BuiltInAuthenticationProviderAzureActiveDirectory, @@ -271,6 +366,19 @@ func PossibleValuesForClientCertMode() []string { } } +func (s *ClientCertMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClientCertMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseClientCertMode(input string) (*ClientCertMode, error) { vals := map[string]ClientCertMode{ "optional": ClientCertModeOptional, @@ -298,6 +406,19 @@ func PossibleValuesForClientCredentialMethod() []string { } } +func (s *ClientCredentialMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClientCredentialMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseClientCredentialMethod(input string) (*ClientCredentialMethod, error) { vals := map[string]ClientCredentialMethod{ "clientsecretpost": ClientCredentialMethodClientSecretPost, @@ -327,6 +448,19 @@ func PossibleValuesForCloneAbilityResult() []string { } } +func (s *CloneAbilityResult) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCloneAbilityResult(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseCloneAbilityResult(input string) (*CloneAbilityResult, error) { vals := map[string]CloneAbilityResult{ "cloneable": CloneAbilityResultCloneable, @@ -354,6 +488,19 @@ func PossibleValuesForConfigReferenceSource() []string { } } +func (s *ConfigReferenceSource) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConfigReferenceSource(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseConfigReferenceSource(input string) (*ConfigReferenceSource, error) { vals := map[string]ConfigReferenceSource{ "keyvault": ConfigReferenceSourceKeyVault, @@ -399,6 +546,19 @@ func PossibleValuesForConnectionStringType() []string { } } +func (s *ConnectionStringType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConnectionStringType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseConnectionStringType(input string) (*ConnectionStringType, error) { vals := map[string]ConnectionStringType{ "apihub": ConnectionStringTypeApiHub, @@ -442,6 +602,19 @@ func PossibleValuesForContinuousWebJobStatus() []string { } } +func (s *ContinuousWebJobStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseContinuousWebJobStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseContinuousWebJobStatus(input string) (*ContinuousWebJobStatus, error) { vals := map[string]ContinuousWebJobStatus{ "initializing": ContinuousWebJobStatusInitializing, @@ -473,6 +646,19 @@ func PossibleValuesForCookieExpirationConvention() []string { } } +func (s *CookieExpirationConvention) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCookieExpirationConvention(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseCookieExpirationConvention(input string) (*CookieExpirationConvention, error) { vals := map[string]CookieExpirationConvention{ "fixedtime": CookieExpirationConventionFixedTime, @@ -501,6 +687,19 @@ func PossibleValuesForCustomHostNameDnsRecordType() []string { } } +func (s *CustomHostNameDnsRecordType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCustomHostNameDnsRecordType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseCustomHostNameDnsRecordType(input string) (*CustomHostNameDnsRecordType, error) { vals := map[string]CustomHostNameDnsRecordType{ "a": CustomHostNameDnsRecordTypeA, @@ -533,6 +732,19 @@ func PossibleValuesForDatabaseType() []string { } } +func (s *DatabaseType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDatabaseType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseDatabaseType(input string) (*DatabaseType, error) { vals := map[string]DatabaseType{ "localmysql": DatabaseTypeLocalMySql, @@ -563,6 +775,19 @@ func PossibleValuesForDefaultAction() []string { } } +func (s *DefaultAction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDefaultAction(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseDefaultAction(input string) (*DefaultAction, error) { vals := map[string]DefaultAction{ "allow": DefaultActionAllow, @@ -613,6 +838,19 @@ func PossibleValuesForDeploymentBuildStatus() []string { } } +func (s *DeploymentBuildStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDeploymentBuildStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseDeploymentBuildStatus(input string) (*DeploymentBuildStatus, error) { vals := map[string]DeploymentBuildStatus{ "buildaborted": DeploymentBuildStatusBuildAborted, @@ -654,6 +892,19 @@ func PossibleValuesForDnsVerificationTestResult() []string { } } +func (s *DnsVerificationTestResult) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDnsVerificationTestResult(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseDnsVerificationTestResult(input string) (*DnsVerificationTestResult, error) { vals := map[string]DnsVerificationTestResult{ "failed": DnsVerificationTestResultFailed, @@ -685,6 +936,19 @@ func PossibleValuesForForwardProxyConvention() []string { } } +func (s *ForwardProxyConvention) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseForwardProxyConvention(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseForwardProxyConvention(input string) (*ForwardProxyConvention, error) { vals := map[string]ForwardProxyConvention{ "custom": ForwardProxyConventionCustom, @@ -714,6 +978,19 @@ func PossibleValuesForFrequencyUnit() []string { } } +func (s *FrequencyUnit) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFrequencyUnit(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseFrequencyUnit(input string) (*FrequencyUnit, error) { vals := map[string]FrequencyUnit{ "day": FrequencyUnitDay, @@ -744,6 +1021,19 @@ func PossibleValuesForFtpsState() []string { } } +func (s *FtpsState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFtpsState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseFtpsState(input string) (*FtpsState, error) { vals := map[string]FtpsState{ "allallowed": FtpsStateAllAllowed, @@ -773,6 +1063,19 @@ func PossibleValuesForHostNameType() []string { } } +func (s *HostNameType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHostNameType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseHostNameType(input string) (*HostNameType, error) { vals := map[string]HostNameType{ "managed": HostNameTypeManaged, @@ -801,6 +1104,19 @@ func PossibleValuesForHostType() []string { } } +func (s *HostType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHostType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseHostType(input string) (*HostType, error) { vals := map[string]HostType{ "repository": HostTypeRepository, @@ -831,6 +1147,19 @@ func PossibleValuesForIPFilterTag() []string { } } +func (s *IPFilterTag) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPFilterTag(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseIPFilterTag(input string) (*IPFilterTag, error) { vals := map[string]IPFilterTag{ "default": IPFilterTagDefault, @@ -866,6 +1195,19 @@ func PossibleValuesForLogLevel() []string { } } +func (s *LogLevel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLogLevel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseLogLevel(input string) (*LogLevel, error) { vals := map[string]LogLevel{ "error": LogLevelError, @@ -899,6 +1241,19 @@ func PossibleValuesForMSDeployLogEntryType() []string { } } +func (s *MSDeployLogEntryType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMSDeployLogEntryType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseMSDeployLogEntryType(input string) (*MSDeployLogEntryType, error) { vals := map[string]MSDeployLogEntryType{ "error": MSDeployLogEntryTypeError, @@ -934,6 +1289,19 @@ func PossibleValuesForMSDeployProvisioningState() []string { } } +func (s *MSDeployProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMSDeployProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseMSDeployProvisioningState(input string) (*MSDeployProvisioningState, error) { vals := map[string]MSDeployProvisioningState{ "accepted": MSDeployProvisioningStateAccepted, @@ -965,6 +1333,19 @@ func PossibleValuesForManagedPipelineMode() []string { } } +func (s *ManagedPipelineMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedPipelineMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseManagedPipelineMode(input string) (*ManagedPipelineMode, error) { vals := map[string]ManagedPipelineMode{ "classic": ManagedPipelineModeClassic, @@ -993,6 +1374,19 @@ func PossibleValuesForMySqlMigrationType() []string { } } +func (s *MySqlMigrationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMySqlMigrationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseMySqlMigrationType(input string) (*MySqlMigrationType, error) { vals := map[string]MySqlMigrationType{ "localtoremote": MySqlMigrationTypeLocalToRemote, @@ -1027,6 +1421,19 @@ func PossibleValuesForOperationStatus() []string { } } +func (s *OperationStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOperationStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseOperationStatus(input string) (*OperationStatus, error) { vals := map[string]OperationStatus{ "created": OperationStatusCreated, @@ -1060,6 +1467,19 @@ func PossibleValuesForPublicCertificateLocation() []string { } } +func (s *PublicCertificateLocation) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicCertificateLocation(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePublicCertificateLocation(input string) (*PublicCertificateLocation, error) { vals := map[string]PublicCertificateLocation{ "currentusermy": PublicCertificateLocationCurrentUserMy, @@ -1091,6 +1511,19 @@ func PossibleValuesForPublishingProfileFormat() []string { } } +func (s *PublishingProfileFormat) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublishingProfileFormat(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parsePublishingProfileFormat(input string) (*PublishingProfileFormat, error) { vals := map[string]PublishingProfileFormat{ "filezilla3": PublishingProfileFormatFileZillaThree, @@ -1126,6 +1559,19 @@ func PossibleValuesForRedundancyMode() []string { } } +func (s *RedundancyMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRedundancyMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseRedundancyMode(input string) (*RedundancyMode, error) { vals := map[string]RedundancyMode{ "activeactive": RedundancyModeActiveActive, @@ -1175,6 +1621,19 @@ func PossibleValuesForResolveStatus() []string { } } +func (s *ResolveStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResolveStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseResolveStatus(input string) (*ResolveStatus, error) { vals := map[string]ResolveStatus{ "accesstokeyvaultdenied": ResolveStatusAccessToKeyVaultDenied, @@ -1214,6 +1673,19 @@ func PossibleValuesForRouteType() []string { } } +func (s *RouteType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRouteType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseRouteType(input string) (*RouteType, error) { vals := map[string]RouteType{ "default": RouteTypeDefault, @@ -1267,6 +1739,19 @@ func PossibleValuesForScmType() []string { } } +func (s *ScmType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseScmType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseScmType(input string) (*ScmType, error) { vals := map[string]ScmType{ "bitbucketgit": ScmTypeBitbucketGit, @@ -1309,6 +1794,19 @@ func PossibleValuesForSiteAvailabilityState() []string { } } +func (s *SiteAvailabilityState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSiteAvailabilityState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseSiteAvailabilityState(input string) (*SiteAvailabilityState, error) { vals := map[string]SiteAvailabilityState{ "disasterrecoverymode": SiteAvailabilityStateDisasterRecoveryMode, @@ -1338,6 +1836,19 @@ func PossibleValuesForSiteExtensionType() []string { } } +func (s *SiteExtensionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSiteExtensionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseSiteExtensionType(input string) (*SiteExtensionType, error) { vals := map[string]SiteExtensionType{ "gallery": SiteExtensionTypeGallery, @@ -1374,6 +1885,19 @@ func PossibleValuesForSiteLoadBalancing() []string { } } +func (s *SiteLoadBalancing) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSiteLoadBalancing(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseSiteLoadBalancing(input string) (*SiteLoadBalancing, error) { vals := map[string]SiteLoadBalancing{ "leastrequests": SiteLoadBalancingLeastRequests, @@ -1408,6 +1932,19 @@ func PossibleValuesForSiteRuntimeState() []string { } } +func (s *SiteRuntimeState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSiteRuntimeState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseSiteRuntimeState(input string) (*SiteRuntimeState, error) { vals := map[string]SiteRuntimeState{ "ready": SiteRuntimeStateREADY, @@ -1439,6 +1976,19 @@ func PossibleValuesForSslState() []string { } } +func (s *SslState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSslState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseSslState(input string) (*SslState, error) { vals := map[string]SslState{ "disabled": SslStateDisabled, @@ -1470,6 +2020,19 @@ func PossibleValuesForSupportedTlsVersions() []string { } } +func (s *SupportedTlsVersions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSupportedTlsVersions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseSupportedTlsVersions(input string) (*SupportedTlsVersions, error) { vals := map[string]SupportedTlsVersions{ "1.1": SupportedTlsVersionsOnePointOne, @@ -1501,6 +2064,19 @@ func PossibleValuesForTriggeredWebJobStatus() []string { } } +func (s *TriggeredWebJobStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTriggeredWebJobStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseTriggeredWebJobStatus(input string) (*TriggeredWebJobStatus, error) { vals := map[string]TriggeredWebJobStatus{ "error": TriggeredWebJobStatusError, @@ -1530,6 +2106,19 @@ func PossibleValuesForUnauthenticatedClientAction() []string { } } +func (s *UnauthenticatedClientAction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUnauthenticatedClientAction(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseUnauthenticatedClientAction(input string) (*UnauthenticatedClientAction, error) { vals := map[string]UnauthenticatedClientAction{ "allowanonymous": UnauthenticatedClientActionAllowAnonymous, @@ -1562,6 +2151,19 @@ func PossibleValuesForUnauthenticatedClientActionV2() []string { } } +func (s *UnauthenticatedClientActionV2) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUnauthenticatedClientActionV2(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseUnauthenticatedClientActionV2(input string) (*UnauthenticatedClientActionV2, error) { vals := map[string]UnauthenticatedClientActionV2{ "allowanonymous": UnauthenticatedClientActionV2AllowAnonymous, @@ -1592,6 +2194,19 @@ func PossibleValuesForUsageState() []string { } } +func (s *UsageState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUsageState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseUsageState(input string) (*UsageState, error) { vals := map[string]UsageState{ "exceeded": UsageStateExceeded, @@ -1620,6 +2235,19 @@ func PossibleValuesForWebJobType() []string { } } +func (s *WebJobType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWebJobType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseWebJobType(input string) (*WebJobType, error) { vals := map[string]WebJobType{ "continuous": WebJobTypeContinuous, @@ -1652,6 +2280,19 @@ func PossibleValuesForWorkflowHealthState() []string { } } +func (s *WorkflowHealthState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowHealthState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseWorkflowHealthState(input string) (*WorkflowHealthState, error) { vals := map[string]WorkflowHealthState{ "healthy": WorkflowHealthStateHealthy, @@ -1690,6 +2331,19 @@ func PossibleValuesForWorkflowState() []string { } } +func (s *WorkflowState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseWorkflowState(input string) (*WorkflowState, error) { vals := map[string]WorkflowState{ "completed": WorkflowStateCompleted, diff --git a/resource-manager/web/2022-09-01/webapps/method_addpremieraddon.go b/resource-manager/web/2022-09-01/webapps/method_addpremieraddon.go new file mode 100644 index 00000000000..f656fd2d07b --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_addpremieraddon.go @@ -0,0 +1,55 @@ +package webapps + +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 AddPremierAddOnOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PremierAddOn +} + +// AddPremierAddOn ... +func (c WebAppsClient) AddPremierAddOn(ctx context.Context, id PremierAddonId, input PremierAddOn) (result AddPremierAddOnOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_addpremieraddon_autorest.go b/resource-manager/web/2022-09-01/webapps/method_addpremieraddon_autorest.go deleted file mode 100644 index 136eb02dfc8..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_addpremieraddon_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type AddPremierAddOnOperationResponse struct { - HttpResponse *http.Response - Model *PremierAddOn -} - -// AddPremierAddOn ... -func (c WebAppsClient) AddPremierAddOn(ctx context.Context, id PremierAddonId, input PremierAddOn) (result AddPremierAddOnOperationResponse, err error) { - req, err := c.preparerForAddPremierAddOn(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "AddPremierAddOn", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "AddPremierAddOn", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForAddPremierAddOn(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "AddPremierAddOn", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForAddPremierAddOn prepares the AddPremierAddOn request. -func (c WebAppsClient) preparerForAddPremierAddOn(ctx context.Context, id PremierAddonId, input PremierAddOn) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForAddPremierAddOn handles the response to the AddPremierAddOn request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForAddPremierAddOn(resp *http.Response) (result AddPremierAddOnOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_addpremieraddonslot.go b/resource-manager/web/2022-09-01/webapps/method_addpremieraddonslot.go new file mode 100644 index 00000000000..f72d8db4283 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_addpremieraddonslot.go @@ -0,0 +1,55 @@ +package webapps + +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 AddPremierAddOnSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PremierAddOn +} + +// AddPremierAddOnSlot ... +func (c WebAppsClient) AddPremierAddOnSlot(ctx context.Context, id SlotPremierAddonId, input PremierAddOn) (result AddPremierAddOnSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_addpremieraddonslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_addpremieraddonslot_autorest.go deleted file mode 100644 index e3c3c607075..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_addpremieraddonslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type AddPremierAddOnSlotOperationResponse struct { - HttpResponse *http.Response - Model *PremierAddOn -} - -// AddPremierAddOnSlot ... -func (c WebAppsClient) AddPremierAddOnSlot(ctx context.Context, id SlotPremierAddonId, input PremierAddOn) (result AddPremierAddOnSlotOperationResponse, err error) { - req, err := c.preparerForAddPremierAddOnSlot(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "AddPremierAddOnSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "AddPremierAddOnSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForAddPremierAddOnSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "AddPremierAddOnSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForAddPremierAddOnSlot prepares the AddPremierAddOnSlot request. -func (c WebAppsClient) preparerForAddPremierAddOnSlot(ctx context.Context, id SlotPremierAddonId, input PremierAddOn) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForAddPremierAddOnSlot handles the response to the AddPremierAddOnSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForAddPremierAddOnSlot(resp *http.Response) (result AddPremierAddOnSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_analyzecustomhostname.go b/resource-manager/web/2022-09-01/webapps/method_analyzecustomhostname.go new file mode 100644 index 00000000000..c8cb2b3d87b --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_analyzecustomhostname.go @@ -0,0 +1,80 @@ +package webapps + +import ( + "context" + "fmt" + "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 AnalyzeCustomHostnameOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CustomHostnameAnalysisResult +} + +type AnalyzeCustomHostnameOperationOptions struct { + HostName *string +} + +func DefaultAnalyzeCustomHostnameOperationOptions() AnalyzeCustomHostnameOperationOptions { + return AnalyzeCustomHostnameOperationOptions{} +} + +func (o AnalyzeCustomHostnameOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o AnalyzeCustomHostnameOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o AnalyzeCustomHostnameOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.HostName != nil { + out.Append("hostName", fmt.Sprintf("%v", *o.HostName)) + } + return &out +} + +// AnalyzeCustomHostname ... +func (c WebAppsClient) AnalyzeCustomHostname(ctx context.Context, id SiteId, options AnalyzeCustomHostnameOperationOptions) (result AnalyzeCustomHostnameOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/analyzeCustomHostname", id.ID()), + OptionsObject: options, + } + + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_analyzecustomhostname_autorest.go b/resource-manager/web/2022-09-01/webapps/method_analyzecustomhostname_autorest.go deleted file mode 100644 index a2562b49d50..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_analyzecustomhostname_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type AnalyzeCustomHostnameOperationResponse struct { - HttpResponse *http.Response - Model *CustomHostnameAnalysisResult -} - -type AnalyzeCustomHostnameOperationOptions struct { - HostName *string -} - -func DefaultAnalyzeCustomHostnameOperationOptions() AnalyzeCustomHostnameOperationOptions { - return AnalyzeCustomHostnameOperationOptions{} -} - -func (o AnalyzeCustomHostnameOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o AnalyzeCustomHostnameOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.HostName != nil { - out["hostName"] = *o.HostName - } - - return out -} - -// AnalyzeCustomHostname ... -func (c WebAppsClient) AnalyzeCustomHostname(ctx context.Context, id SiteId, options AnalyzeCustomHostnameOperationOptions) (result AnalyzeCustomHostnameOperationResponse, err error) { - req, err := c.preparerForAnalyzeCustomHostname(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "AnalyzeCustomHostname", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "AnalyzeCustomHostname", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForAnalyzeCustomHostname(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "AnalyzeCustomHostname", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForAnalyzeCustomHostname prepares the AnalyzeCustomHostname request. -func (c WebAppsClient) preparerForAnalyzeCustomHostname(ctx context.Context, id SiteId, options AnalyzeCustomHostnameOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/analyzeCustomHostname", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForAnalyzeCustomHostname handles the response to the AnalyzeCustomHostname request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForAnalyzeCustomHostname(resp *http.Response) (result AnalyzeCustomHostnameOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_analyzecustomhostnameslot.go b/resource-manager/web/2022-09-01/webapps/method_analyzecustomhostnameslot.go new file mode 100644 index 00000000000..00bad53de52 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_analyzecustomhostnameslot.go @@ -0,0 +1,80 @@ +package webapps + +import ( + "context" + "fmt" + "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 AnalyzeCustomHostnameSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CustomHostnameAnalysisResult +} + +type AnalyzeCustomHostnameSlotOperationOptions struct { + HostName *string +} + +func DefaultAnalyzeCustomHostnameSlotOperationOptions() AnalyzeCustomHostnameSlotOperationOptions { + return AnalyzeCustomHostnameSlotOperationOptions{} +} + +func (o AnalyzeCustomHostnameSlotOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o AnalyzeCustomHostnameSlotOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o AnalyzeCustomHostnameSlotOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.HostName != nil { + out.Append("hostName", fmt.Sprintf("%v", *o.HostName)) + } + return &out +} + +// AnalyzeCustomHostnameSlot ... +func (c WebAppsClient) AnalyzeCustomHostnameSlot(ctx context.Context, id SlotId, options AnalyzeCustomHostnameSlotOperationOptions) (result AnalyzeCustomHostnameSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/analyzeCustomHostname", id.ID()), + OptionsObject: options, + } + + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_analyzecustomhostnameslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_analyzecustomhostnameslot_autorest.go deleted file mode 100644 index 6f89d910b4c..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_analyzecustomhostnameslot_autorest.go +++ /dev/null @@ -1,98 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type AnalyzeCustomHostnameSlotOperationResponse struct { - HttpResponse *http.Response - Model *CustomHostnameAnalysisResult -} - -type AnalyzeCustomHostnameSlotOperationOptions struct { - HostName *string -} - -func DefaultAnalyzeCustomHostnameSlotOperationOptions() AnalyzeCustomHostnameSlotOperationOptions { - return AnalyzeCustomHostnameSlotOperationOptions{} -} - -func (o AnalyzeCustomHostnameSlotOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o AnalyzeCustomHostnameSlotOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.HostName != nil { - out["hostName"] = *o.HostName - } - - return out -} - -// AnalyzeCustomHostnameSlot ... -func (c WebAppsClient) AnalyzeCustomHostnameSlot(ctx context.Context, id SlotId, options AnalyzeCustomHostnameSlotOperationOptions) (result AnalyzeCustomHostnameSlotOperationResponse, err error) { - req, err := c.preparerForAnalyzeCustomHostnameSlot(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "AnalyzeCustomHostnameSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "AnalyzeCustomHostnameSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForAnalyzeCustomHostnameSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "AnalyzeCustomHostnameSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForAnalyzeCustomHostnameSlot prepares the AnalyzeCustomHostnameSlot request. -func (c WebAppsClient) preparerForAnalyzeCustomHostnameSlot(ctx context.Context, id SlotId, options AnalyzeCustomHostnameSlotOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/analyzeCustomHostname", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForAnalyzeCustomHostnameSlot handles the response to the AnalyzeCustomHostnameSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForAnalyzeCustomHostnameSlot(resp *http.Response) (result AnalyzeCustomHostnameSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_applyslotconfigtoproduction.go b/resource-manager/web/2022-09-01/webapps/method_applyslotconfigtoproduction.go new file mode 100644 index 00000000000..715d5a52c12 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_applyslotconfigtoproduction.go @@ -0,0 +1,51 @@ +package webapps + +import ( + "context" + "fmt" + "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 ApplySlotConfigToProductionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ApplySlotConfigToProduction ... +func (c WebAppsClient) ApplySlotConfigToProduction(ctx context.Context, id SiteId, input CsmSlotEntity) (result ApplySlotConfigToProductionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/applySlotConfig", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_applyslotconfigtoproduction_autorest.go b/resource-manager/web/2022-09-01/webapps/method_applyslotconfigtoproduction_autorest.go deleted file mode 100644 index fc23ea3ef3f..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_applyslotconfigtoproduction_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ApplySlotConfigToProductionOperationResponse struct { - HttpResponse *http.Response -} - -// ApplySlotConfigToProduction ... -func (c WebAppsClient) ApplySlotConfigToProduction(ctx context.Context, id SiteId, input CsmSlotEntity) (result ApplySlotConfigToProductionOperationResponse, err error) { - req, err := c.preparerForApplySlotConfigToProduction(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ApplySlotConfigToProduction", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ApplySlotConfigToProduction", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForApplySlotConfigToProduction(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ApplySlotConfigToProduction", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForApplySlotConfigToProduction prepares the ApplySlotConfigToProduction request. -func (c WebAppsClient) preparerForApplySlotConfigToProduction(ctx context.Context, id SiteId, input CsmSlotEntity) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/applySlotConfig", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForApplySlotConfigToProduction handles the response to the ApplySlotConfigToProduction request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForApplySlotConfigToProduction(resp *http.Response) (result ApplySlotConfigToProductionOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_applyslotconfigurationslot.go b/resource-manager/web/2022-09-01/webapps/method_applyslotconfigurationslot.go new file mode 100644 index 00000000000..df6b5ebc42d --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_applyslotconfigurationslot.go @@ -0,0 +1,51 @@ +package webapps + +import ( + "context" + "fmt" + "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 ApplySlotConfigurationSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ApplySlotConfigurationSlot ... +func (c WebAppsClient) ApplySlotConfigurationSlot(ctx context.Context, id SlotId, input CsmSlotEntity) (result ApplySlotConfigurationSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/applySlotConfig", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_applyslotconfigurationslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_applyslotconfigurationslot_autorest.go deleted file mode 100644 index 39d471e19cc..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_applyslotconfigurationslot_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ApplySlotConfigurationSlotOperationResponse struct { - HttpResponse *http.Response -} - -// ApplySlotConfigurationSlot ... -func (c WebAppsClient) ApplySlotConfigurationSlot(ctx context.Context, id SlotId, input CsmSlotEntity) (result ApplySlotConfigurationSlotOperationResponse, err error) { - req, err := c.preparerForApplySlotConfigurationSlot(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ApplySlotConfigurationSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ApplySlotConfigurationSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForApplySlotConfigurationSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ApplySlotConfigurationSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForApplySlotConfigurationSlot prepares the ApplySlotConfigurationSlot request. -func (c WebAppsClient) preparerForApplySlotConfigurationSlot(ctx context.Context, id SlotId, input CsmSlotEntity) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/applySlotConfig", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForApplySlotConfigurationSlot handles the response to the ApplySlotConfigurationSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForApplySlotConfigurationSlot(resp *http.Response) (result ApplySlotConfigurationSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_approveorrejectprivateendpointconnection.go b/resource-manager/web/2022-09-01/webapps/method_approveorrejectprivateendpointconnection.go new file mode 100644 index 00000000000..98329c93d35 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_approveorrejectprivateendpointconnection.go @@ -0,0 +1,74 @@ +package webapps + +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 ApproveOrRejectPrivateEndpointConnectionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ApproveOrRejectPrivateEndpointConnection ... +func (c WebAppsClient) ApproveOrRejectPrivateEndpointConnection(ctx context.Context, id PrivateEndpointConnectionId, input PrivateLinkConnectionApprovalRequestResource) (result ApproveOrRejectPrivateEndpointConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// ApproveOrRejectPrivateEndpointConnectionThenPoll performs ApproveOrRejectPrivateEndpointConnection then polls until it's completed +func (c WebAppsClient) ApproveOrRejectPrivateEndpointConnectionThenPoll(ctx context.Context, id PrivateEndpointConnectionId, input PrivateLinkConnectionApprovalRequestResource) error { + result, err := c.ApproveOrRejectPrivateEndpointConnection(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ApproveOrRejectPrivateEndpointConnection: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ApproveOrRejectPrivateEndpointConnection: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/webapps/method_approveorrejectprivateendpointconnection_autorest.go b/resource-manager/web/2022-09-01/webapps/method_approveorrejectprivateendpointconnection_autorest.go deleted file mode 100644 index cd8bf6e9350..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_approveorrejectprivateendpointconnection_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ApproveOrRejectPrivateEndpointConnectionOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// ApproveOrRejectPrivateEndpointConnection ... -func (c WebAppsClient) ApproveOrRejectPrivateEndpointConnection(ctx context.Context, id PrivateEndpointConnectionId, input PrivateLinkConnectionApprovalRequestResource) (result ApproveOrRejectPrivateEndpointConnectionOperationResponse, err error) { - req, err := c.preparerForApproveOrRejectPrivateEndpointConnection(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ApproveOrRejectPrivateEndpointConnection", nil, "Failure preparing request") - return - } - - result, err = c.senderForApproveOrRejectPrivateEndpointConnection(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ApproveOrRejectPrivateEndpointConnection", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// ApproveOrRejectPrivateEndpointConnectionThenPoll performs ApproveOrRejectPrivateEndpointConnection then polls until it's completed -func (c WebAppsClient) ApproveOrRejectPrivateEndpointConnectionThenPoll(ctx context.Context, id PrivateEndpointConnectionId, input PrivateLinkConnectionApprovalRequestResource) error { - result, err := c.ApproveOrRejectPrivateEndpointConnection(ctx, id, input) - if err != nil { - return fmt.Errorf("performing ApproveOrRejectPrivateEndpointConnection: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after ApproveOrRejectPrivateEndpointConnection: %+v", err) - } - - return nil -} - -// preparerForApproveOrRejectPrivateEndpointConnection prepares the ApproveOrRejectPrivateEndpointConnection request. -func (c WebAppsClient) preparerForApproveOrRejectPrivateEndpointConnection(ctx context.Context, id PrivateEndpointConnectionId, input PrivateLinkConnectionApprovalRequestResource) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForApproveOrRejectPrivateEndpointConnection sends the ApproveOrRejectPrivateEndpointConnection request. The method will close the -// http.Response Body if it receives an error. -func (c WebAppsClient) senderForApproveOrRejectPrivateEndpointConnection(ctx context.Context, req *http.Request) (future ApproveOrRejectPrivateEndpointConnectionOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_approveorrejectprivateendpointconnectionslot.go b/resource-manager/web/2022-09-01/webapps/method_approveorrejectprivateendpointconnectionslot.go new file mode 100644 index 00000000000..9a8495bbafa --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_approveorrejectprivateendpointconnectionslot.go @@ -0,0 +1,74 @@ +package webapps + +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 ApproveOrRejectPrivateEndpointConnectionSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ApproveOrRejectPrivateEndpointConnectionSlot ... +func (c WebAppsClient) ApproveOrRejectPrivateEndpointConnectionSlot(ctx context.Context, id SlotPrivateEndpointConnectionId, input PrivateLinkConnectionApprovalRequestResource) (result ApproveOrRejectPrivateEndpointConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// ApproveOrRejectPrivateEndpointConnectionSlotThenPoll performs ApproveOrRejectPrivateEndpointConnectionSlot then polls until it's completed +func (c WebAppsClient) ApproveOrRejectPrivateEndpointConnectionSlotThenPoll(ctx context.Context, id SlotPrivateEndpointConnectionId, input PrivateLinkConnectionApprovalRequestResource) error { + result, err := c.ApproveOrRejectPrivateEndpointConnectionSlot(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ApproveOrRejectPrivateEndpointConnectionSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ApproveOrRejectPrivateEndpointConnectionSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/webapps/method_approveorrejectprivateendpointconnectionslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_approveorrejectprivateendpointconnectionslot_autorest.go deleted file mode 100644 index 1dee4cb9e02..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_approveorrejectprivateendpointconnectionslot_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ApproveOrRejectPrivateEndpointConnectionSlotOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// ApproveOrRejectPrivateEndpointConnectionSlot ... -func (c WebAppsClient) ApproveOrRejectPrivateEndpointConnectionSlot(ctx context.Context, id SlotPrivateEndpointConnectionId, input PrivateLinkConnectionApprovalRequestResource) (result ApproveOrRejectPrivateEndpointConnectionSlotOperationResponse, err error) { - req, err := c.preparerForApproveOrRejectPrivateEndpointConnectionSlot(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ApproveOrRejectPrivateEndpointConnectionSlot", nil, "Failure preparing request") - return - } - - result, err = c.senderForApproveOrRejectPrivateEndpointConnectionSlot(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ApproveOrRejectPrivateEndpointConnectionSlot", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// ApproveOrRejectPrivateEndpointConnectionSlotThenPoll performs ApproveOrRejectPrivateEndpointConnectionSlot then polls until it's completed -func (c WebAppsClient) ApproveOrRejectPrivateEndpointConnectionSlotThenPoll(ctx context.Context, id SlotPrivateEndpointConnectionId, input PrivateLinkConnectionApprovalRequestResource) error { - result, err := c.ApproveOrRejectPrivateEndpointConnectionSlot(ctx, id, input) - if err != nil { - return fmt.Errorf("performing ApproveOrRejectPrivateEndpointConnectionSlot: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after ApproveOrRejectPrivateEndpointConnectionSlot: %+v", err) - } - - return nil -} - -// preparerForApproveOrRejectPrivateEndpointConnectionSlot prepares the ApproveOrRejectPrivateEndpointConnectionSlot request. -func (c WebAppsClient) preparerForApproveOrRejectPrivateEndpointConnectionSlot(ctx context.Context, id SlotPrivateEndpointConnectionId, input PrivateLinkConnectionApprovalRequestResource) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForApproveOrRejectPrivateEndpointConnectionSlot sends the ApproveOrRejectPrivateEndpointConnectionSlot request. The method will close the -// http.Response Body if it receives an error. -func (c WebAppsClient) senderForApproveOrRejectPrivateEndpointConnectionSlot(ctx context.Context, req *http.Request) (future ApproveOrRejectPrivateEndpointConnectionSlotOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_backup.go b/resource-manager/web/2022-09-01/webapps/method_backup.go new file mode 100644 index 00000000000..fbb5a015ab2 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_backup.go @@ -0,0 +1,56 @@ +package webapps + +import ( + "context" + "fmt" + "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 BackupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BackupItem +} + +// Backup ... +func (c WebAppsClient) Backup(ctx context.Context, id SiteId, input BackupRequest) (result BackupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/backup", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_backup_autorest.go b/resource-manager/web/2022-09-01/webapps/method_backup_autorest.go deleted file mode 100644 index a14821e8322..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_backup_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type BackupOperationResponse struct { - HttpResponse *http.Response - Model *BackupItem -} - -// Backup ... -func (c WebAppsClient) Backup(ctx context.Context, id SiteId, input BackupRequest) (result BackupOperationResponse, err error) { - req, err := c.preparerForBackup(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "Backup", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "Backup", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForBackup(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "Backup", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForBackup prepares the Backup request. -func (c WebAppsClient) preparerForBackup(ctx context.Context, id SiteId, input BackupRequest) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/backup", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForBackup handles the response to the Backup request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForBackup(resp *http.Response) (result BackupOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_backupslot.go b/resource-manager/web/2022-09-01/webapps/method_backupslot.go new file mode 100644 index 00000000000..c5633f15f2f --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_backupslot.go @@ -0,0 +1,56 @@ +package webapps + +import ( + "context" + "fmt" + "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 BackupSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BackupItem +} + +// BackupSlot ... +func (c WebAppsClient) BackupSlot(ctx context.Context, id SlotId, input BackupRequest) (result BackupSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/backup", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_backupslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_backupslot_autorest.go deleted file mode 100644 index 69cf868d1b8..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_backupslot_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type BackupSlotOperationResponse struct { - HttpResponse *http.Response - Model *BackupItem -} - -// BackupSlot ... -func (c WebAppsClient) BackupSlot(ctx context.Context, id SlotId, input BackupRequest) (result BackupSlotOperationResponse, err error) { - req, err := c.preparerForBackupSlot(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "BackupSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "BackupSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForBackupSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "BackupSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForBackupSlot prepares the BackupSlot request. -func (c WebAppsClient) preparerForBackupSlot(ctx context.Context, id SlotId, input BackupRequest) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/backup", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForBackupSlot handles the response to the BackupSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForBackupSlot(resp *http.Response) (result BackupSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_createdeployment.go b/resource-manager/web/2022-09-01/webapps/method_createdeployment.go new file mode 100644 index 00000000000..19aa83ce79f --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_createdeployment.go @@ -0,0 +1,55 @@ +package webapps + +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 CreateDeploymentOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Deployment +} + +// CreateDeployment ... +func (c WebAppsClient) CreateDeployment(ctx context.Context, id DeploymentId, input Deployment) (result CreateDeploymentOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_createdeployment_autorest.go b/resource-manager/web/2022-09-01/webapps/method_createdeployment_autorest.go deleted file mode 100644 index 9f5ee6daa1e..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_createdeployment_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateDeploymentOperationResponse struct { - HttpResponse *http.Response - Model *Deployment -} - -// CreateDeployment ... -func (c WebAppsClient) CreateDeployment(ctx context.Context, id DeploymentId, input Deployment) (result CreateDeploymentOperationResponse, err error) { - req, err := c.preparerForCreateDeployment(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateDeployment", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateDeployment", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateDeployment(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateDeployment", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateDeployment prepares the CreateDeployment request. -func (c WebAppsClient) preparerForCreateDeployment(ctx context.Context, id DeploymentId, input Deployment) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateDeployment handles the response to the CreateDeployment request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForCreateDeployment(resp *http.Response) (result CreateDeploymentOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_createdeploymentslot.go b/resource-manager/web/2022-09-01/webapps/method_createdeploymentslot.go new file mode 100644 index 00000000000..4e321d8a480 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_createdeploymentslot.go @@ -0,0 +1,55 @@ +package webapps + +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 CreateDeploymentSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Deployment +} + +// CreateDeploymentSlot ... +func (c WebAppsClient) CreateDeploymentSlot(ctx context.Context, id SlotDeploymentId, input Deployment) (result CreateDeploymentSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_createdeploymentslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_createdeploymentslot_autorest.go deleted file mode 100644 index 784927e7d7d..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_createdeploymentslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateDeploymentSlotOperationResponse struct { - HttpResponse *http.Response - Model *Deployment -} - -// CreateDeploymentSlot ... -func (c WebAppsClient) CreateDeploymentSlot(ctx context.Context, id SlotDeploymentId, input Deployment) (result CreateDeploymentSlotOperationResponse, err error) { - req, err := c.preparerForCreateDeploymentSlot(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateDeploymentSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateDeploymentSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateDeploymentSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateDeploymentSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateDeploymentSlot prepares the CreateDeploymentSlot request. -func (c WebAppsClient) preparerForCreateDeploymentSlot(ctx context.Context, id SlotDeploymentId, input Deployment) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateDeploymentSlot handles the response to the CreateDeploymentSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForCreateDeploymentSlot(resp *http.Response) (result CreateDeploymentSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_createfunction.go b/resource-manager/web/2022-09-01/webapps/method_createfunction.go new file mode 100644 index 00000000000..0ee6da433aa --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_createfunction.go @@ -0,0 +1,73 @@ +package webapps + +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 CreateFunctionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// CreateFunction ... +func (c WebAppsClient) CreateFunction(ctx context.Context, id FunctionId, input FunctionEnvelope) (result CreateFunctionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + 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 +} + +// CreateFunctionThenPoll performs CreateFunction then polls until it's completed +func (c WebAppsClient) CreateFunctionThenPoll(ctx context.Context, id FunctionId, input FunctionEnvelope) error { + result, err := c.CreateFunction(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateFunction: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateFunction: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/webapps/method_createfunction_autorest.go b/resource-manager/web/2022-09-01/webapps/method_createfunction_autorest.go deleted file mode 100644 index 2ef5a1196ea..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_createfunction_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateFunctionOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateFunction ... -func (c WebAppsClient) CreateFunction(ctx context.Context, id FunctionId, input FunctionEnvelope) (result CreateFunctionOperationResponse, err error) { - req, err := c.preparerForCreateFunction(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateFunction", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateFunction(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateFunction", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateFunctionThenPoll performs CreateFunction then polls until it's completed -func (c WebAppsClient) CreateFunctionThenPoll(ctx context.Context, id FunctionId, input FunctionEnvelope) error { - result, err := c.CreateFunction(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateFunction: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateFunction: %+v", err) - } - - return nil -} - -// preparerForCreateFunction prepares the CreateFunction request. -func (c WebAppsClient) preparerForCreateFunction(ctx context.Context, id FunctionId, input FunctionEnvelope) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateFunction sends the CreateFunction request. The method will close the -// http.Response Body if it receives an error. -func (c WebAppsClient) senderForCreateFunction(ctx context.Context, req *http.Request) (future CreateFunctionOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_createinstancefunctionslot.go b/resource-manager/web/2022-09-01/webapps/method_createinstancefunctionslot.go new file mode 100644 index 00000000000..cc4e4b078d5 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_createinstancefunctionslot.go @@ -0,0 +1,73 @@ +package webapps + +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 CreateInstanceFunctionSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// CreateInstanceFunctionSlot ... +func (c WebAppsClient) CreateInstanceFunctionSlot(ctx context.Context, id SlotFunctionId, input FunctionEnvelope) (result CreateInstanceFunctionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + 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 +} + +// CreateInstanceFunctionSlotThenPoll performs CreateInstanceFunctionSlot then polls until it's completed +func (c WebAppsClient) CreateInstanceFunctionSlotThenPoll(ctx context.Context, id SlotFunctionId, input FunctionEnvelope) error { + result, err := c.CreateInstanceFunctionSlot(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateInstanceFunctionSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateInstanceFunctionSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/webapps/method_createinstancefunctionslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_createinstancefunctionslot_autorest.go deleted file mode 100644 index 2082ab0f3f5..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_createinstancefunctionslot_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateInstanceFunctionSlotOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateInstanceFunctionSlot ... -func (c WebAppsClient) CreateInstanceFunctionSlot(ctx context.Context, id SlotFunctionId, input FunctionEnvelope) (result CreateInstanceFunctionSlotOperationResponse, err error) { - req, err := c.preparerForCreateInstanceFunctionSlot(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateInstanceFunctionSlot", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateInstanceFunctionSlot(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateInstanceFunctionSlot", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateInstanceFunctionSlotThenPoll performs CreateInstanceFunctionSlot then polls until it's completed -func (c WebAppsClient) CreateInstanceFunctionSlotThenPoll(ctx context.Context, id SlotFunctionId, input FunctionEnvelope) error { - result, err := c.CreateInstanceFunctionSlot(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateInstanceFunctionSlot: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateInstanceFunctionSlot: %+v", err) - } - - return nil -} - -// preparerForCreateInstanceFunctionSlot prepares the CreateInstanceFunctionSlot request. -func (c WebAppsClient) preparerForCreateInstanceFunctionSlot(ctx context.Context, id SlotFunctionId, input FunctionEnvelope) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateInstanceFunctionSlot sends the CreateInstanceFunctionSlot request. The method will close the -// http.Response Body if it receives an error. -func (c WebAppsClient) senderForCreateInstanceFunctionSlot(ctx context.Context, req *http.Request) (future CreateInstanceFunctionSlotOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_createinstancemsdeployoperation.go b/resource-manager/web/2022-09-01/webapps/method_createinstancemsdeployoperation.go new file mode 100644 index 00000000000..d61f2f09c38 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_createinstancemsdeployoperation.go @@ -0,0 +1,73 @@ +package webapps + +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 CreateInstanceMSDeployOperationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// CreateInstanceMSDeployOperation ... +func (c WebAppsClient) CreateInstanceMSDeployOperation(ctx context.Context, id InstanceId, input MSDeploy) (result CreateInstanceMSDeployOperationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/extensions/mSDeploy", 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 +} + +// CreateInstanceMSDeployOperationThenPoll performs CreateInstanceMSDeployOperation then polls until it's completed +func (c WebAppsClient) CreateInstanceMSDeployOperationThenPoll(ctx context.Context, id InstanceId, input MSDeploy) error { + result, err := c.CreateInstanceMSDeployOperation(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateInstanceMSDeployOperation: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateInstanceMSDeployOperation: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/webapps/method_createinstancemsdeployoperation_autorest.go b/resource-manager/web/2022-09-01/webapps/method_createinstancemsdeployoperation_autorest.go deleted file mode 100644 index 925fea4c930..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_createinstancemsdeployoperation_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateInstanceMSDeployOperationOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateInstanceMSDeployOperation ... -func (c WebAppsClient) CreateInstanceMSDeployOperation(ctx context.Context, id InstanceId, input MSDeploy) (result CreateInstanceMSDeployOperationOperationResponse, err error) { - req, err := c.preparerForCreateInstanceMSDeployOperation(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateInstanceMSDeployOperation", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateInstanceMSDeployOperation(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateInstanceMSDeployOperation", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateInstanceMSDeployOperationThenPoll performs CreateInstanceMSDeployOperation then polls until it's completed -func (c WebAppsClient) CreateInstanceMSDeployOperationThenPoll(ctx context.Context, id InstanceId, input MSDeploy) error { - result, err := c.CreateInstanceMSDeployOperation(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateInstanceMSDeployOperation: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateInstanceMSDeployOperation: %+v", err) - } - - return nil -} - -// preparerForCreateInstanceMSDeployOperation prepares the CreateInstanceMSDeployOperation request. -func (c WebAppsClient) preparerForCreateInstanceMSDeployOperation(ctx context.Context, id InstanceId, input MSDeploy) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/extensions/mSDeploy", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateInstanceMSDeployOperation sends the CreateInstanceMSDeployOperation request. The method will close the -// http.Response Body if it receives an error. -func (c WebAppsClient) senderForCreateInstanceMSDeployOperation(ctx context.Context, req *http.Request) (future CreateInstanceMSDeployOperationOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_createinstancemsdeployoperationslot.go b/resource-manager/web/2022-09-01/webapps/method_createinstancemsdeployoperationslot.go new file mode 100644 index 00000000000..7fe832e8822 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_createinstancemsdeployoperationslot.go @@ -0,0 +1,73 @@ +package webapps + +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 CreateInstanceMSDeployOperationSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// CreateInstanceMSDeployOperationSlot ... +func (c WebAppsClient) CreateInstanceMSDeployOperationSlot(ctx context.Context, id SlotInstanceId, input MSDeploy) (result CreateInstanceMSDeployOperationSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/extensions/mSDeploy", 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 +} + +// CreateInstanceMSDeployOperationSlotThenPoll performs CreateInstanceMSDeployOperationSlot then polls until it's completed +func (c WebAppsClient) CreateInstanceMSDeployOperationSlotThenPoll(ctx context.Context, id SlotInstanceId, input MSDeploy) error { + result, err := c.CreateInstanceMSDeployOperationSlot(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateInstanceMSDeployOperationSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateInstanceMSDeployOperationSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/webapps/method_createinstancemsdeployoperationslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_createinstancemsdeployoperationslot_autorest.go deleted file mode 100644 index 20c2e181b2e..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_createinstancemsdeployoperationslot_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateInstanceMSDeployOperationSlotOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateInstanceMSDeployOperationSlot ... -func (c WebAppsClient) CreateInstanceMSDeployOperationSlot(ctx context.Context, id SlotInstanceId, input MSDeploy) (result CreateInstanceMSDeployOperationSlotOperationResponse, err error) { - req, err := c.preparerForCreateInstanceMSDeployOperationSlot(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateInstanceMSDeployOperationSlot", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateInstanceMSDeployOperationSlot(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateInstanceMSDeployOperationSlot", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateInstanceMSDeployOperationSlotThenPoll performs CreateInstanceMSDeployOperationSlot then polls until it's completed -func (c WebAppsClient) CreateInstanceMSDeployOperationSlotThenPoll(ctx context.Context, id SlotInstanceId, input MSDeploy) error { - result, err := c.CreateInstanceMSDeployOperationSlot(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateInstanceMSDeployOperationSlot: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateInstanceMSDeployOperationSlot: %+v", err) - } - - return nil -} - -// preparerForCreateInstanceMSDeployOperationSlot prepares the CreateInstanceMSDeployOperationSlot request. -func (c WebAppsClient) preparerForCreateInstanceMSDeployOperationSlot(ctx context.Context, id SlotInstanceId, input MSDeploy) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/extensions/mSDeploy", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateInstanceMSDeployOperationSlot sends the CreateInstanceMSDeployOperationSlot request. The method will close the -// http.Response Body if it receives an error. -func (c WebAppsClient) senderForCreateInstanceMSDeployOperationSlot(ctx context.Context, req *http.Request) (future CreateInstanceMSDeployOperationSlotOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_createmsdeployoperation.go b/resource-manager/web/2022-09-01/webapps/method_createmsdeployoperation.go new file mode 100644 index 00000000000..88509b64c7e --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_createmsdeployoperation.go @@ -0,0 +1,73 @@ +package webapps + +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 CreateMSDeployOperationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// CreateMSDeployOperation ... +func (c WebAppsClient) CreateMSDeployOperation(ctx context.Context, id SiteId, input MSDeploy) (result CreateMSDeployOperationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/extensions/mSDeploy", 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 +} + +// CreateMSDeployOperationThenPoll performs CreateMSDeployOperation then polls until it's completed +func (c WebAppsClient) CreateMSDeployOperationThenPoll(ctx context.Context, id SiteId, input MSDeploy) error { + result, err := c.CreateMSDeployOperation(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateMSDeployOperation: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateMSDeployOperation: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/webapps/method_createmsdeployoperation_autorest.go b/resource-manager/web/2022-09-01/webapps/method_createmsdeployoperation_autorest.go deleted file mode 100644 index 5a005473e27..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_createmsdeployoperation_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateMSDeployOperationOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateMSDeployOperation ... -func (c WebAppsClient) CreateMSDeployOperation(ctx context.Context, id SiteId, input MSDeploy) (result CreateMSDeployOperationOperationResponse, err error) { - req, err := c.preparerForCreateMSDeployOperation(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateMSDeployOperation", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateMSDeployOperation(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateMSDeployOperation", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateMSDeployOperationThenPoll performs CreateMSDeployOperation then polls until it's completed -func (c WebAppsClient) CreateMSDeployOperationThenPoll(ctx context.Context, id SiteId, input MSDeploy) error { - result, err := c.CreateMSDeployOperation(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateMSDeployOperation: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateMSDeployOperation: %+v", err) - } - - return nil -} - -// preparerForCreateMSDeployOperation prepares the CreateMSDeployOperation request. -func (c WebAppsClient) preparerForCreateMSDeployOperation(ctx context.Context, id SiteId, input MSDeploy) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/extensions/mSDeploy", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateMSDeployOperation sends the CreateMSDeployOperation request. The method will close the -// http.Response Body if it receives an error. -func (c WebAppsClient) senderForCreateMSDeployOperation(ctx context.Context, req *http.Request) (future CreateMSDeployOperationOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_createmsdeployoperationslot.go b/resource-manager/web/2022-09-01/webapps/method_createmsdeployoperationslot.go new file mode 100644 index 00000000000..5e8d0ea76a9 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_createmsdeployoperationslot.go @@ -0,0 +1,73 @@ +package webapps + +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 CreateMSDeployOperationSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// CreateMSDeployOperationSlot ... +func (c WebAppsClient) CreateMSDeployOperationSlot(ctx context.Context, id SlotId, input MSDeploy) (result CreateMSDeployOperationSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/extensions/mSDeploy", 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 +} + +// CreateMSDeployOperationSlotThenPoll performs CreateMSDeployOperationSlot then polls until it's completed +func (c WebAppsClient) CreateMSDeployOperationSlotThenPoll(ctx context.Context, id SlotId, input MSDeploy) error { + result, err := c.CreateMSDeployOperationSlot(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateMSDeployOperationSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateMSDeployOperationSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/webapps/method_createmsdeployoperationslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_createmsdeployoperationslot_autorest.go deleted file mode 100644 index 87839e757bb..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_createmsdeployoperationslot_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateMSDeployOperationSlotOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateMSDeployOperationSlot ... -func (c WebAppsClient) CreateMSDeployOperationSlot(ctx context.Context, id SlotId, input MSDeploy) (result CreateMSDeployOperationSlotOperationResponse, err error) { - req, err := c.preparerForCreateMSDeployOperationSlot(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateMSDeployOperationSlot", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateMSDeployOperationSlot(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateMSDeployOperationSlot", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateMSDeployOperationSlotThenPoll performs CreateMSDeployOperationSlot then polls until it's completed -func (c WebAppsClient) CreateMSDeployOperationSlotThenPoll(ctx context.Context, id SlotId, input MSDeploy) error { - result, err := c.CreateMSDeployOperationSlot(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateMSDeployOperationSlot: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateMSDeployOperationSlot: %+v", err) - } - - return nil -} - -// preparerForCreateMSDeployOperationSlot prepares the CreateMSDeployOperationSlot request. -func (c WebAppsClient) preparerForCreateMSDeployOperationSlot(ctx context.Context, id SlotId, input MSDeploy) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/extensions/mSDeploy", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateMSDeployOperationSlot sends the CreateMSDeployOperationSlot request. The method will close the -// http.Response Body if it receives an error. -func (c WebAppsClient) senderForCreateMSDeployOperationSlot(ctx context.Context, req *http.Request) (future CreateMSDeployOperationSlotOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_createonedeployoperation.go b/resource-manager/web/2022-09-01/webapps/method_createonedeployoperation.go new file mode 100644 index 00000000000..3c7d4d0082c --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_createonedeployoperation.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 CreateOneDeployOperationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *interface{} +} + +// CreateOneDeployOperation ... +func (c WebAppsClient) CreateOneDeployOperation(ctx context.Context, id SiteId) (result CreateOneDeployOperationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/extensions/onedeploy", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_createonedeployoperation_autorest.go b/resource-manager/web/2022-09-01/webapps/method_createonedeployoperation_autorest.go deleted file mode 100644 index 6a931b9ea0e..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_createonedeployoperation_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOneDeployOperationOperationResponse struct { - HttpResponse *http.Response - Model *interface{} -} - -// CreateOneDeployOperation ... -func (c WebAppsClient) CreateOneDeployOperation(ctx context.Context, id SiteId) (result CreateOneDeployOperationOperationResponse, err error) { - req, err := c.preparerForCreateOneDeployOperation(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOneDeployOperation", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOneDeployOperation", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOneDeployOperation(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOneDeployOperation", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOneDeployOperation prepares the CreateOneDeployOperation request. -func (c WebAppsClient) preparerForCreateOneDeployOperation(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/extensions/onedeploy", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateOneDeployOperation handles the response to the CreateOneDeployOperation request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForCreateOneDeployOperation(resp *http.Response) (result CreateOneDeployOperationOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_createorupdate.go b/resource-manager/web/2022-09-01/webapps/method_createorupdate.go new file mode 100644 index 00000000000..dcaaad20c96 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_createorupdate.go @@ -0,0 +1,74 @@ +package webapps + +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 +} + +// CreateOrUpdate ... +func (c WebAppsClient) CreateOrUpdate(ctx context.Context, id SiteId, input Site) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 WebAppsClient) CreateOrUpdateThenPoll(ctx context.Context, id SiteId, input Site) 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_createorupdate_autorest.go b/resource-manager/web/2022-09-01/webapps/method_createorupdate_autorest.go deleted file mode 100644 index 355d31008d3..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_createorupdate_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// 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 polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateOrUpdate ... -func (c WebAppsClient) CreateOrUpdate(ctx context.Context, id SiteId, input Site) (result CreateOrUpdateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdate(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed -func (c WebAppsClient) CreateOrUpdateThenPoll(ctx context.Context, id SiteId, input Site) error { - result, err := c.CreateOrUpdate(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateOrUpdate: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateOrUpdate: %+v", err) - } - - return nil -} - -// preparerForCreateOrUpdate prepares the CreateOrUpdate request. -func (c WebAppsClient) preparerForCreateOrUpdate(ctx context.Context, id SiteId, input Site) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateOrUpdate sends the CreateOrUpdate request. The method will close the -// http.Response Body if it receives an error. -func (c WebAppsClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_createorupdateconfiguration.go b/resource-manager/web/2022-09-01/webapps/method_createorupdateconfiguration.go new file mode 100644 index 00000000000..56cc79894a4 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_createorupdateconfiguration.go @@ -0,0 +1,56 @@ +package webapps + +import ( + "context" + "fmt" + "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 CreateOrUpdateConfigurationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteConfigResource +} + +// CreateOrUpdateConfiguration ... +func (c WebAppsClient) CreateOrUpdateConfiguration(ctx context.Context, id SiteId, input SiteConfigResource) (result CreateOrUpdateConfigurationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/web", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_createorupdateconfiguration_autorest.go b/resource-manager/web/2022-09-01/webapps/method_createorupdateconfiguration_autorest.go deleted file mode 100644 index f5ac62b101e..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_createorupdateconfiguration_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateConfigurationOperationResponse struct { - HttpResponse *http.Response - Model *SiteConfigResource -} - -// CreateOrUpdateConfiguration ... -func (c WebAppsClient) CreateOrUpdateConfiguration(ctx context.Context, id SiteId, input SiteConfigResource) (result CreateOrUpdateConfigurationOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdateConfiguration(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateConfiguration", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateConfiguration", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdateConfiguration(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateConfiguration", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdateConfiguration prepares the CreateOrUpdateConfiguration request. -func (c WebAppsClient) preparerForCreateOrUpdateConfiguration(ctx context.Context, id SiteId, input SiteConfigResource) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/web", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateOrUpdateConfiguration handles the response to the CreateOrUpdateConfiguration request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForCreateOrUpdateConfiguration(resp *http.Response) (result CreateOrUpdateConfigurationOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_createorupdateconfigurationslot.go b/resource-manager/web/2022-09-01/webapps/method_createorupdateconfigurationslot.go new file mode 100644 index 00000000000..0b80ad9143a --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_createorupdateconfigurationslot.go @@ -0,0 +1,56 @@ +package webapps + +import ( + "context" + "fmt" + "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 CreateOrUpdateConfigurationSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteConfigResource +} + +// CreateOrUpdateConfigurationSlot ... +func (c WebAppsClient) CreateOrUpdateConfigurationSlot(ctx context.Context, id SlotId, input SiteConfigResource) (result CreateOrUpdateConfigurationSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/web", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_createorupdateconfigurationslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_createorupdateconfigurationslot_autorest.go deleted file mode 100644 index 7dadfa96f41..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_createorupdateconfigurationslot_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateConfigurationSlotOperationResponse struct { - HttpResponse *http.Response - Model *SiteConfigResource -} - -// CreateOrUpdateConfigurationSlot ... -func (c WebAppsClient) CreateOrUpdateConfigurationSlot(ctx context.Context, id SlotId, input SiteConfigResource) (result CreateOrUpdateConfigurationSlotOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdateConfigurationSlot(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateConfigurationSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateConfigurationSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdateConfigurationSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateConfigurationSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdateConfigurationSlot prepares the CreateOrUpdateConfigurationSlot request. -func (c WebAppsClient) preparerForCreateOrUpdateConfigurationSlot(ctx context.Context, id SlotId, input SiteConfigResource) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/web", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateOrUpdateConfigurationSlot handles the response to the CreateOrUpdateConfigurationSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForCreateOrUpdateConfigurationSlot(resp *http.Response) (result CreateOrUpdateConfigurationSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_createorupdatedomainownershipidentifier.go b/resource-manager/web/2022-09-01/webapps/method_createorupdatedomainownershipidentifier.go new file mode 100644 index 00000000000..14ce1ddc0bc --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_createorupdatedomainownershipidentifier.go @@ -0,0 +1,55 @@ +package webapps + +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 CreateOrUpdateDomainOwnershipIdentifierOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Identifier +} + +// CreateOrUpdateDomainOwnershipIdentifier ... +func (c WebAppsClient) CreateOrUpdateDomainOwnershipIdentifier(ctx context.Context, id DomainOwnershipIdentifierId, input Identifier) (result CreateOrUpdateDomainOwnershipIdentifierOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_createorupdatedomainownershipidentifier_autorest.go b/resource-manager/web/2022-09-01/webapps/method_createorupdatedomainownershipidentifier_autorest.go deleted file mode 100644 index 932bb4fefe5..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_createorupdatedomainownershipidentifier_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateDomainOwnershipIdentifierOperationResponse struct { - HttpResponse *http.Response - Model *Identifier -} - -// CreateOrUpdateDomainOwnershipIdentifier ... -func (c WebAppsClient) CreateOrUpdateDomainOwnershipIdentifier(ctx context.Context, id DomainOwnershipIdentifierId, input Identifier) (result CreateOrUpdateDomainOwnershipIdentifierOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdateDomainOwnershipIdentifier(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateDomainOwnershipIdentifier", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateDomainOwnershipIdentifier", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdateDomainOwnershipIdentifier(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateDomainOwnershipIdentifier", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdateDomainOwnershipIdentifier prepares the CreateOrUpdateDomainOwnershipIdentifier request. -func (c WebAppsClient) preparerForCreateOrUpdateDomainOwnershipIdentifier(ctx context.Context, id DomainOwnershipIdentifierId, input Identifier) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateOrUpdateDomainOwnershipIdentifier handles the response to the CreateOrUpdateDomainOwnershipIdentifier request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForCreateOrUpdateDomainOwnershipIdentifier(resp *http.Response) (result CreateOrUpdateDomainOwnershipIdentifierOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_createorupdatedomainownershipidentifierslot.go b/resource-manager/web/2022-09-01/webapps/method_createorupdatedomainownershipidentifierslot.go new file mode 100644 index 00000000000..bda2a445b34 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_createorupdatedomainownershipidentifierslot.go @@ -0,0 +1,55 @@ +package webapps + +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 CreateOrUpdateDomainOwnershipIdentifierSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Identifier +} + +// CreateOrUpdateDomainOwnershipIdentifierSlot ... +func (c WebAppsClient) CreateOrUpdateDomainOwnershipIdentifierSlot(ctx context.Context, id SlotDomainOwnershipIdentifierId, input Identifier) (result CreateOrUpdateDomainOwnershipIdentifierSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_createorupdatedomainownershipidentifierslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_createorupdatedomainownershipidentifierslot_autorest.go deleted file mode 100644 index 63ae3904fa2..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_createorupdatedomainownershipidentifierslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateDomainOwnershipIdentifierSlotOperationResponse struct { - HttpResponse *http.Response - Model *Identifier -} - -// CreateOrUpdateDomainOwnershipIdentifierSlot ... -func (c WebAppsClient) CreateOrUpdateDomainOwnershipIdentifierSlot(ctx context.Context, id SlotDomainOwnershipIdentifierId, input Identifier) (result CreateOrUpdateDomainOwnershipIdentifierSlotOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdateDomainOwnershipIdentifierSlot(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateDomainOwnershipIdentifierSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateDomainOwnershipIdentifierSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdateDomainOwnershipIdentifierSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateDomainOwnershipIdentifierSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdateDomainOwnershipIdentifierSlot prepares the CreateOrUpdateDomainOwnershipIdentifierSlot request. -func (c WebAppsClient) preparerForCreateOrUpdateDomainOwnershipIdentifierSlot(ctx context.Context, id SlotDomainOwnershipIdentifierId, input Identifier) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateOrUpdateDomainOwnershipIdentifierSlot handles the response to the CreateOrUpdateDomainOwnershipIdentifierSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForCreateOrUpdateDomainOwnershipIdentifierSlot(resp *http.Response) (result CreateOrUpdateDomainOwnershipIdentifierSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_createorupdatefunctionsecret.go b/resource-manager/web/2022-09-01/webapps/method_createorupdatefunctionsecret.go new file mode 100644 index 00000000000..00bb32f9a44 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_createorupdatefunctionsecret.go @@ -0,0 +1,56 @@ +package webapps + +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 CreateOrUpdateFunctionSecretOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *KeyInfo +} + +// CreateOrUpdateFunctionSecret ... +func (c WebAppsClient) CreateOrUpdateFunctionSecret(ctx context.Context, id KeyId, input KeyInfo) (result CreateOrUpdateFunctionSecretOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_createorupdatefunctionsecret_autorest.go b/resource-manager/web/2022-09-01/webapps/method_createorupdatefunctionsecret_autorest.go deleted file mode 100644 index 5eec335da5e..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_createorupdatefunctionsecret_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateFunctionSecretOperationResponse struct { - HttpResponse *http.Response - Model *KeyInfo -} - -// CreateOrUpdateFunctionSecret ... -func (c WebAppsClient) CreateOrUpdateFunctionSecret(ctx context.Context, id KeyId, input KeyInfo) (result CreateOrUpdateFunctionSecretOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdateFunctionSecret(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateFunctionSecret", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateFunctionSecret", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdateFunctionSecret(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateFunctionSecret", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdateFunctionSecret prepares the CreateOrUpdateFunctionSecret request. -func (c WebAppsClient) preparerForCreateOrUpdateFunctionSecret(ctx context.Context, id KeyId, input KeyInfo) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateOrUpdateFunctionSecret handles the response to the CreateOrUpdateFunctionSecret request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForCreateOrUpdateFunctionSecret(resp *http.Response) (result CreateOrUpdateFunctionSecretOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_createorupdatefunctionsecretslot.go b/resource-manager/web/2022-09-01/webapps/method_createorupdatefunctionsecretslot.go new file mode 100644 index 00000000000..daff6d61b9a --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_createorupdatefunctionsecretslot.go @@ -0,0 +1,56 @@ +package webapps + +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 CreateOrUpdateFunctionSecretSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *KeyInfo +} + +// CreateOrUpdateFunctionSecretSlot ... +func (c WebAppsClient) CreateOrUpdateFunctionSecretSlot(ctx context.Context, id FunctionKeyId, input KeyInfo) (result CreateOrUpdateFunctionSecretSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_createorupdatefunctionsecretslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_createorupdatefunctionsecretslot_autorest.go deleted file mode 100644 index 5c8d36855b2..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_createorupdatefunctionsecretslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateFunctionSecretSlotOperationResponse struct { - HttpResponse *http.Response - Model *KeyInfo -} - -// CreateOrUpdateFunctionSecretSlot ... -func (c WebAppsClient) CreateOrUpdateFunctionSecretSlot(ctx context.Context, id FunctionKeyId, input KeyInfo) (result CreateOrUpdateFunctionSecretSlotOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdateFunctionSecretSlot(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateFunctionSecretSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateFunctionSecretSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdateFunctionSecretSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateFunctionSecretSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdateFunctionSecretSlot prepares the CreateOrUpdateFunctionSecretSlot request. -func (c WebAppsClient) preparerForCreateOrUpdateFunctionSecretSlot(ctx context.Context, id FunctionKeyId, input KeyInfo) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateOrUpdateFunctionSecretSlot handles the response to the CreateOrUpdateFunctionSecretSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForCreateOrUpdateFunctionSecretSlot(resp *http.Response) (result CreateOrUpdateFunctionSecretSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_createorupdatehostnamebinding.go b/resource-manager/web/2022-09-01/webapps/method_createorupdatehostnamebinding.go new file mode 100644 index 00000000000..983ff77aec2 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_createorupdatehostnamebinding.go @@ -0,0 +1,55 @@ +package webapps + +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 CreateOrUpdateHostNameBindingOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HostNameBinding +} + +// CreateOrUpdateHostNameBinding ... +func (c WebAppsClient) CreateOrUpdateHostNameBinding(ctx context.Context, id HostNameBindingId, input HostNameBinding) (result CreateOrUpdateHostNameBindingOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_createorupdatehostnamebinding_autorest.go b/resource-manager/web/2022-09-01/webapps/method_createorupdatehostnamebinding_autorest.go deleted file mode 100644 index cf764adb684..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_createorupdatehostnamebinding_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateHostNameBindingOperationResponse struct { - HttpResponse *http.Response - Model *HostNameBinding -} - -// CreateOrUpdateHostNameBinding ... -func (c WebAppsClient) CreateOrUpdateHostNameBinding(ctx context.Context, id HostNameBindingId, input HostNameBinding) (result CreateOrUpdateHostNameBindingOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdateHostNameBinding(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateHostNameBinding", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateHostNameBinding", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdateHostNameBinding(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateHostNameBinding", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdateHostNameBinding prepares the CreateOrUpdateHostNameBinding request. -func (c WebAppsClient) preparerForCreateOrUpdateHostNameBinding(ctx context.Context, id HostNameBindingId, input HostNameBinding) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateOrUpdateHostNameBinding handles the response to the CreateOrUpdateHostNameBinding request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForCreateOrUpdateHostNameBinding(resp *http.Response) (result CreateOrUpdateHostNameBindingOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_createorupdatehostnamebindingslot.go b/resource-manager/web/2022-09-01/webapps/method_createorupdatehostnamebindingslot.go new file mode 100644 index 00000000000..a8a47e22dc3 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_createorupdatehostnamebindingslot.go @@ -0,0 +1,55 @@ +package webapps + +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 CreateOrUpdateHostNameBindingSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HostNameBinding +} + +// CreateOrUpdateHostNameBindingSlot ... +func (c WebAppsClient) CreateOrUpdateHostNameBindingSlot(ctx context.Context, id SlotHostNameBindingId, input HostNameBinding) (result CreateOrUpdateHostNameBindingSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_createorupdatehostnamebindingslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_createorupdatehostnamebindingslot_autorest.go deleted file mode 100644 index 728860b8c20..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_createorupdatehostnamebindingslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateHostNameBindingSlotOperationResponse struct { - HttpResponse *http.Response - Model *HostNameBinding -} - -// CreateOrUpdateHostNameBindingSlot ... -func (c WebAppsClient) CreateOrUpdateHostNameBindingSlot(ctx context.Context, id SlotHostNameBindingId, input HostNameBinding) (result CreateOrUpdateHostNameBindingSlotOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdateHostNameBindingSlot(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateHostNameBindingSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateHostNameBindingSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdateHostNameBindingSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateHostNameBindingSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdateHostNameBindingSlot prepares the CreateOrUpdateHostNameBindingSlot request. -func (c WebAppsClient) preparerForCreateOrUpdateHostNameBindingSlot(ctx context.Context, id SlotHostNameBindingId, input HostNameBinding) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateOrUpdateHostNameBindingSlot handles the response to the CreateOrUpdateHostNameBindingSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForCreateOrUpdateHostNameBindingSlot(resp *http.Response) (result CreateOrUpdateHostNameBindingSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_createorupdatehostsecret.go b/resource-manager/web/2022-09-01/webapps/method_createorupdatehostsecret.go new file mode 100644 index 00000000000..d77e3bb35ff --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_createorupdatehostsecret.go @@ -0,0 +1,56 @@ +package webapps + +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 CreateOrUpdateHostSecretOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *KeyInfo +} + +// CreateOrUpdateHostSecret ... +func (c WebAppsClient) CreateOrUpdateHostSecret(ctx context.Context, id DefaultId, input KeyInfo) (result CreateOrUpdateHostSecretOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_createorupdatehostsecret_autorest.go b/resource-manager/web/2022-09-01/webapps/method_createorupdatehostsecret_autorest.go deleted file mode 100644 index 0f776e16f9e..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_createorupdatehostsecret_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateHostSecretOperationResponse struct { - HttpResponse *http.Response - Model *KeyInfo -} - -// CreateOrUpdateHostSecret ... -func (c WebAppsClient) CreateOrUpdateHostSecret(ctx context.Context, id DefaultId, input KeyInfo) (result CreateOrUpdateHostSecretOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdateHostSecret(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateHostSecret", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateHostSecret", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdateHostSecret(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateHostSecret", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdateHostSecret prepares the CreateOrUpdateHostSecret request. -func (c WebAppsClient) preparerForCreateOrUpdateHostSecret(ctx context.Context, id DefaultId, input KeyInfo) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateOrUpdateHostSecret handles the response to the CreateOrUpdateHostSecret request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForCreateOrUpdateHostSecret(resp *http.Response) (result CreateOrUpdateHostSecretOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_createorupdatehostsecretslot.go b/resource-manager/web/2022-09-01/webapps/method_createorupdatehostsecretslot.go new file mode 100644 index 00000000000..1dba1ce6bbf --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_createorupdatehostsecretslot.go @@ -0,0 +1,56 @@ +package webapps + +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 CreateOrUpdateHostSecretSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *KeyInfo +} + +// CreateOrUpdateHostSecretSlot ... +func (c WebAppsClient) CreateOrUpdateHostSecretSlot(ctx context.Context, id HostDefaultId, input KeyInfo) (result CreateOrUpdateHostSecretSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_createorupdatehostsecretslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_createorupdatehostsecretslot_autorest.go deleted file mode 100644 index 8d1c371e442..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_createorupdatehostsecretslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateHostSecretSlotOperationResponse struct { - HttpResponse *http.Response - Model *KeyInfo -} - -// CreateOrUpdateHostSecretSlot ... -func (c WebAppsClient) CreateOrUpdateHostSecretSlot(ctx context.Context, id HostDefaultId, input KeyInfo) (result CreateOrUpdateHostSecretSlotOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdateHostSecretSlot(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateHostSecretSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateHostSecretSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdateHostSecretSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateHostSecretSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdateHostSecretSlot prepares the CreateOrUpdateHostSecretSlot request. -func (c WebAppsClient) preparerForCreateOrUpdateHostSecretSlot(ctx context.Context, id HostDefaultId, input KeyInfo) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateOrUpdateHostSecretSlot handles the response to the CreateOrUpdateHostSecretSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForCreateOrUpdateHostSecretSlot(resp *http.Response) (result CreateOrUpdateHostSecretSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_createorupdatehybridconnection.go b/resource-manager/web/2022-09-01/webapps/method_createorupdatehybridconnection.go new file mode 100644 index 00000000000..fd01dc9ef75 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_createorupdatehybridconnection.go @@ -0,0 +1,55 @@ +package webapps + +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 CreateOrUpdateHybridConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HybridConnection +} + +// CreateOrUpdateHybridConnection ... +func (c WebAppsClient) CreateOrUpdateHybridConnection(ctx context.Context, id RelayId, input HybridConnection) (result CreateOrUpdateHybridConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_createorupdatehybridconnection_autorest.go b/resource-manager/web/2022-09-01/webapps/method_createorupdatehybridconnection_autorest.go deleted file mode 100644 index fe60deedb94..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_createorupdatehybridconnection_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateHybridConnectionOperationResponse struct { - HttpResponse *http.Response - Model *HybridConnection -} - -// CreateOrUpdateHybridConnection ... -func (c WebAppsClient) CreateOrUpdateHybridConnection(ctx context.Context, id RelayId, input HybridConnection) (result CreateOrUpdateHybridConnectionOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdateHybridConnection(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateHybridConnection", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateHybridConnection", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdateHybridConnection(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateHybridConnection", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdateHybridConnection prepares the CreateOrUpdateHybridConnection request. -func (c WebAppsClient) preparerForCreateOrUpdateHybridConnection(ctx context.Context, id RelayId, input HybridConnection) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateOrUpdateHybridConnection handles the response to the CreateOrUpdateHybridConnection request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForCreateOrUpdateHybridConnection(resp *http.Response) (result CreateOrUpdateHybridConnectionOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_createorupdatehybridconnectionslot.go b/resource-manager/web/2022-09-01/webapps/method_createorupdatehybridconnectionslot.go new file mode 100644 index 00000000000..01844d36af7 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_createorupdatehybridconnectionslot.go @@ -0,0 +1,55 @@ +package webapps + +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 CreateOrUpdateHybridConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HybridConnection +} + +// CreateOrUpdateHybridConnectionSlot ... +func (c WebAppsClient) CreateOrUpdateHybridConnectionSlot(ctx context.Context, id SlotHybridConnectionNamespaceRelayId, input HybridConnection) (result CreateOrUpdateHybridConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_createorupdatehybridconnectionslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_createorupdatehybridconnectionslot_autorest.go deleted file mode 100644 index fbc3911ba9a..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_createorupdatehybridconnectionslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateHybridConnectionSlotOperationResponse struct { - HttpResponse *http.Response - Model *HybridConnection -} - -// CreateOrUpdateHybridConnectionSlot ... -func (c WebAppsClient) CreateOrUpdateHybridConnectionSlot(ctx context.Context, id SlotHybridConnectionNamespaceRelayId, input HybridConnection) (result CreateOrUpdateHybridConnectionSlotOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdateHybridConnectionSlot(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateHybridConnectionSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateHybridConnectionSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdateHybridConnectionSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateHybridConnectionSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdateHybridConnectionSlot prepares the CreateOrUpdateHybridConnectionSlot request. -func (c WebAppsClient) preparerForCreateOrUpdateHybridConnectionSlot(ctx context.Context, id SlotHybridConnectionNamespaceRelayId, input HybridConnection) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateOrUpdateHybridConnectionSlot handles the response to the CreateOrUpdateHybridConnectionSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForCreateOrUpdateHybridConnectionSlot(resp *http.Response) (result CreateOrUpdateHybridConnectionSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_createorupdatepubliccertificate.go b/resource-manager/web/2022-09-01/webapps/method_createorupdatepubliccertificate.go new file mode 100644 index 00000000000..62db0307a8b --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_createorupdatepubliccertificate.go @@ -0,0 +1,55 @@ +package webapps + +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 CreateOrUpdatePublicCertificateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PublicCertificate +} + +// CreateOrUpdatePublicCertificate ... +func (c WebAppsClient) CreateOrUpdatePublicCertificate(ctx context.Context, id PublicCertificateId, input PublicCertificate) (result CreateOrUpdatePublicCertificateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_createorupdatepubliccertificate_autorest.go b/resource-manager/web/2022-09-01/webapps/method_createorupdatepubliccertificate_autorest.go deleted file mode 100644 index 93ee9eae036..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_createorupdatepubliccertificate_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdatePublicCertificateOperationResponse struct { - HttpResponse *http.Response - Model *PublicCertificate -} - -// CreateOrUpdatePublicCertificate ... -func (c WebAppsClient) CreateOrUpdatePublicCertificate(ctx context.Context, id PublicCertificateId, input PublicCertificate) (result CreateOrUpdatePublicCertificateOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdatePublicCertificate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdatePublicCertificate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdatePublicCertificate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdatePublicCertificate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdatePublicCertificate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdatePublicCertificate prepares the CreateOrUpdatePublicCertificate request. -func (c WebAppsClient) preparerForCreateOrUpdatePublicCertificate(ctx context.Context, id PublicCertificateId, input PublicCertificate) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateOrUpdatePublicCertificate handles the response to the CreateOrUpdatePublicCertificate request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForCreateOrUpdatePublicCertificate(resp *http.Response) (result CreateOrUpdatePublicCertificateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_createorupdatepubliccertificateslot.go b/resource-manager/web/2022-09-01/webapps/method_createorupdatepubliccertificateslot.go new file mode 100644 index 00000000000..41f745305bf --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_createorupdatepubliccertificateslot.go @@ -0,0 +1,55 @@ +package webapps + +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 CreateOrUpdatePublicCertificateSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PublicCertificate +} + +// CreateOrUpdatePublicCertificateSlot ... +func (c WebAppsClient) CreateOrUpdatePublicCertificateSlot(ctx context.Context, id SlotPublicCertificateId, input PublicCertificate) (result CreateOrUpdatePublicCertificateSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_createorupdatepubliccertificateslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_createorupdatepubliccertificateslot_autorest.go deleted file mode 100644 index d65cb5708a9..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_createorupdatepubliccertificateslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdatePublicCertificateSlotOperationResponse struct { - HttpResponse *http.Response - Model *PublicCertificate -} - -// CreateOrUpdatePublicCertificateSlot ... -func (c WebAppsClient) CreateOrUpdatePublicCertificateSlot(ctx context.Context, id SlotPublicCertificateId, input PublicCertificate) (result CreateOrUpdatePublicCertificateSlotOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdatePublicCertificateSlot(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdatePublicCertificateSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdatePublicCertificateSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdatePublicCertificateSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdatePublicCertificateSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdatePublicCertificateSlot prepares the CreateOrUpdatePublicCertificateSlot request. -func (c WebAppsClient) preparerForCreateOrUpdatePublicCertificateSlot(ctx context.Context, id SlotPublicCertificateId, input PublicCertificate) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateOrUpdatePublicCertificateSlot handles the response to the CreateOrUpdatePublicCertificateSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForCreateOrUpdatePublicCertificateSlot(resp *http.Response) (result CreateOrUpdatePublicCertificateSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_createorupdaterelayserviceconnection.go b/resource-manager/web/2022-09-01/webapps/method_createorupdaterelayserviceconnection.go new file mode 100644 index 00000000000..d6470e7ac67 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_createorupdaterelayserviceconnection.go @@ -0,0 +1,55 @@ +package webapps + +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 CreateOrUpdateRelayServiceConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RelayServiceConnectionEntity +} + +// CreateOrUpdateRelayServiceConnection ... +func (c WebAppsClient) CreateOrUpdateRelayServiceConnection(ctx context.Context, id HybridConnectionId, input RelayServiceConnectionEntity) (result CreateOrUpdateRelayServiceConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_createorupdaterelayserviceconnection_autorest.go b/resource-manager/web/2022-09-01/webapps/method_createorupdaterelayserviceconnection_autorest.go deleted file mode 100644 index 34c9d4d82f5..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_createorupdaterelayserviceconnection_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateRelayServiceConnectionOperationResponse struct { - HttpResponse *http.Response - Model *RelayServiceConnectionEntity -} - -// CreateOrUpdateRelayServiceConnection ... -func (c WebAppsClient) CreateOrUpdateRelayServiceConnection(ctx context.Context, id HybridConnectionId, input RelayServiceConnectionEntity) (result CreateOrUpdateRelayServiceConnectionOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdateRelayServiceConnection(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateRelayServiceConnection", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateRelayServiceConnection", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdateRelayServiceConnection(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateRelayServiceConnection", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdateRelayServiceConnection prepares the CreateOrUpdateRelayServiceConnection request. -func (c WebAppsClient) preparerForCreateOrUpdateRelayServiceConnection(ctx context.Context, id HybridConnectionId, input RelayServiceConnectionEntity) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateOrUpdateRelayServiceConnection handles the response to the CreateOrUpdateRelayServiceConnection request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForCreateOrUpdateRelayServiceConnection(resp *http.Response) (result CreateOrUpdateRelayServiceConnectionOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_createorupdaterelayserviceconnectionslot.go b/resource-manager/web/2022-09-01/webapps/method_createorupdaterelayserviceconnectionslot.go new file mode 100644 index 00000000000..ad750b12dc5 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_createorupdaterelayserviceconnectionslot.go @@ -0,0 +1,55 @@ +package webapps + +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 CreateOrUpdateRelayServiceConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RelayServiceConnectionEntity +} + +// CreateOrUpdateRelayServiceConnectionSlot ... +func (c WebAppsClient) CreateOrUpdateRelayServiceConnectionSlot(ctx context.Context, id SlotHybridConnectionId, input RelayServiceConnectionEntity) (result CreateOrUpdateRelayServiceConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_createorupdaterelayserviceconnectionslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_createorupdaterelayserviceconnectionslot_autorest.go deleted file mode 100644 index e7f73f1a056..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_createorupdaterelayserviceconnectionslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateRelayServiceConnectionSlotOperationResponse struct { - HttpResponse *http.Response - Model *RelayServiceConnectionEntity -} - -// CreateOrUpdateRelayServiceConnectionSlot ... -func (c WebAppsClient) CreateOrUpdateRelayServiceConnectionSlot(ctx context.Context, id SlotHybridConnectionId, input RelayServiceConnectionEntity) (result CreateOrUpdateRelayServiceConnectionSlotOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdateRelayServiceConnectionSlot(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateRelayServiceConnectionSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateRelayServiceConnectionSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdateRelayServiceConnectionSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateRelayServiceConnectionSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdateRelayServiceConnectionSlot prepares the CreateOrUpdateRelayServiceConnectionSlot request. -func (c WebAppsClient) preparerForCreateOrUpdateRelayServiceConnectionSlot(ctx context.Context, id SlotHybridConnectionId, input RelayServiceConnectionEntity) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateOrUpdateRelayServiceConnectionSlot handles the response to the CreateOrUpdateRelayServiceConnectionSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForCreateOrUpdateRelayServiceConnectionSlot(resp *http.Response) (result CreateOrUpdateRelayServiceConnectionSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_createorupdateslot.go b/resource-manager/web/2022-09-01/webapps/method_createorupdateslot.go new file mode 100644 index 00000000000..3a405c8c13e --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_createorupdateslot.go @@ -0,0 +1,74 @@ +package webapps + +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 CreateOrUpdateSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// CreateOrUpdateSlot ... +func (c WebAppsClient) CreateOrUpdateSlot(ctx context.Context, id SlotId, input Site) (result CreateOrUpdateSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// CreateOrUpdateSlotThenPoll performs CreateOrUpdateSlot then polls until it's completed +func (c WebAppsClient) CreateOrUpdateSlotThenPoll(ctx context.Context, id SlotId, input Site) error { + result, err := c.CreateOrUpdateSlot(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdateSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdateSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/webapps/method_createorupdateslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_createorupdateslot_autorest.go deleted file mode 100644 index 3846345244a..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_createorupdateslot_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateSlotOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateOrUpdateSlot ... -func (c WebAppsClient) CreateOrUpdateSlot(ctx context.Context, id SlotId, input Site) (result CreateOrUpdateSlotOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdateSlot(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateSlot", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdateSlot(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateSlot", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateSlotThenPoll performs CreateOrUpdateSlot then polls until it's completed -func (c WebAppsClient) CreateOrUpdateSlotThenPoll(ctx context.Context, id SlotId, input Site) error { - result, err := c.CreateOrUpdateSlot(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateOrUpdateSlot: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateOrUpdateSlot: %+v", err) - } - - return nil -} - -// preparerForCreateOrUpdateSlot prepares the CreateOrUpdateSlot request. -func (c WebAppsClient) preparerForCreateOrUpdateSlot(ctx context.Context, id SlotId, input Site) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateOrUpdateSlot sends the CreateOrUpdateSlot request. The method will close the -// http.Response Body if it receives an error. -func (c WebAppsClient) senderForCreateOrUpdateSlot(ctx context.Context, req *http.Request) (future CreateOrUpdateSlotOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_createorupdatesourcecontrol.go b/resource-manager/web/2022-09-01/webapps/method_createorupdatesourcecontrol.go new file mode 100644 index 00000000000..37567f8a182 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_createorupdatesourcecontrol.go @@ -0,0 +1,75 @@ +package webapps + +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 CreateOrUpdateSourceControlOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// CreateOrUpdateSourceControl ... +func (c WebAppsClient) CreateOrUpdateSourceControl(ctx context.Context, id SiteId, input SiteSourceControl) (result CreateOrUpdateSourceControlOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/sourceControls/web", 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 +} + +// CreateOrUpdateSourceControlThenPoll performs CreateOrUpdateSourceControl then polls until it's completed +func (c WebAppsClient) CreateOrUpdateSourceControlThenPoll(ctx context.Context, id SiteId, input SiteSourceControl) error { + result, err := c.CreateOrUpdateSourceControl(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdateSourceControl: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdateSourceControl: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/webapps/method_createorupdatesourcecontrol_autorest.go b/resource-manager/web/2022-09-01/webapps/method_createorupdatesourcecontrol_autorest.go deleted file mode 100644 index e3700b54fa6..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_createorupdatesourcecontrol_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateSourceControlOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateOrUpdateSourceControl ... -func (c WebAppsClient) CreateOrUpdateSourceControl(ctx context.Context, id SiteId, input SiteSourceControl) (result CreateOrUpdateSourceControlOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdateSourceControl(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateSourceControl", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdateSourceControl(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateSourceControl", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateSourceControlThenPoll performs CreateOrUpdateSourceControl then polls until it's completed -func (c WebAppsClient) CreateOrUpdateSourceControlThenPoll(ctx context.Context, id SiteId, input SiteSourceControl) error { - result, err := c.CreateOrUpdateSourceControl(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateOrUpdateSourceControl: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateOrUpdateSourceControl: %+v", err) - } - - return nil -} - -// preparerForCreateOrUpdateSourceControl prepares the CreateOrUpdateSourceControl request. -func (c WebAppsClient) preparerForCreateOrUpdateSourceControl(ctx context.Context, id SiteId, input SiteSourceControl) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/sourceControls/web", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateOrUpdateSourceControl sends the CreateOrUpdateSourceControl request. The method will close the -// http.Response Body if it receives an error. -func (c WebAppsClient) senderForCreateOrUpdateSourceControl(ctx context.Context, req *http.Request) (future CreateOrUpdateSourceControlOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_createorupdatesourcecontrolslot.go b/resource-manager/web/2022-09-01/webapps/method_createorupdatesourcecontrolslot.go new file mode 100644 index 00000000000..0c8d41c14b0 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_createorupdatesourcecontrolslot.go @@ -0,0 +1,75 @@ +package webapps + +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 CreateOrUpdateSourceControlSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// CreateOrUpdateSourceControlSlot ... +func (c WebAppsClient) CreateOrUpdateSourceControlSlot(ctx context.Context, id SlotId, input SiteSourceControl) (result CreateOrUpdateSourceControlSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/sourceControls/web", 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 +} + +// CreateOrUpdateSourceControlSlotThenPoll performs CreateOrUpdateSourceControlSlot then polls until it's completed +func (c WebAppsClient) CreateOrUpdateSourceControlSlotThenPoll(ctx context.Context, id SlotId, input SiteSourceControl) error { + result, err := c.CreateOrUpdateSourceControlSlot(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdateSourceControlSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdateSourceControlSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/webapps/method_createorupdatesourcecontrolslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_createorupdatesourcecontrolslot_autorest.go deleted file mode 100644 index 15ccd1a8c5c..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_createorupdatesourcecontrolslot_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateSourceControlSlotOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// CreateOrUpdateSourceControlSlot ... -func (c WebAppsClient) CreateOrUpdateSourceControlSlot(ctx context.Context, id SlotId, input SiteSourceControl) (result CreateOrUpdateSourceControlSlotOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdateSourceControlSlot(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateSourceControlSlot", nil, "Failure preparing request") - return - } - - result, err = c.senderForCreateOrUpdateSourceControlSlot(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateSourceControlSlot", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// CreateOrUpdateSourceControlSlotThenPoll performs CreateOrUpdateSourceControlSlot then polls until it's completed -func (c WebAppsClient) CreateOrUpdateSourceControlSlotThenPoll(ctx context.Context, id SlotId, input SiteSourceControl) error { - result, err := c.CreateOrUpdateSourceControlSlot(ctx, id, input) - if err != nil { - return fmt.Errorf("performing CreateOrUpdateSourceControlSlot: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after CreateOrUpdateSourceControlSlot: %+v", err) - } - - return nil -} - -// preparerForCreateOrUpdateSourceControlSlot prepares the CreateOrUpdateSourceControlSlot request. -func (c WebAppsClient) preparerForCreateOrUpdateSourceControlSlot(ctx context.Context, id SlotId, input SiteSourceControl) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/sourceControls/web", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForCreateOrUpdateSourceControlSlot sends the CreateOrUpdateSourceControlSlot request. The method will close the -// http.Response Body if it receives an error. -func (c WebAppsClient) senderForCreateOrUpdateSourceControlSlot(ctx context.Context, req *http.Request) (future CreateOrUpdateSourceControlSlotOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_createorupdateswiftvirtualnetworkconnectionwithcheck.go b/resource-manager/web/2022-09-01/webapps/method_createorupdateswiftvirtualnetworkconnectionwithcheck.go new file mode 100644 index 00000000000..c604b89a9e9 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_createorupdateswiftvirtualnetworkconnectionwithcheck.go @@ -0,0 +1,56 @@ +package webapps + +import ( + "context" + "fmt" + "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 CreateOrUpdateSwiftVirtualNetworkConnectionWithCheckOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SwiftVirtualNetwork +} + +// CreateOrUpdateSwiftVirtualNetworkConnectionWithCheck ... +func (c WebAppsClient) CreateOrUpdateSwiftVirtualNetworkConnectionWithCheck(ctx context.Context, id SiteId, input SwiftVirtualNetwork) (result CreateOrUpdateSwiftVirtualNetworkConnectionWithCheckOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/networkConfig/virtualNetwork", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_createorupdateswiftvirtualnetworkconnectionwithcheck_autorest.go b/resource-manager/web/2022-09-01/webapps/method_createorupdateswiftvirtualnetworkconnectionwithcheck_autorest.go deleted file mode 100644 index 15d1568d601..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_createorupdateswiftvirtualnetworkconnectionwithcheck_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateSwiftVirtualNetworkConnectionWithCheckOperationResponse struct { - HttpResponse *http.Response - Model *SwiftVirtualNetwork -} - -// CreateOrUpdateSwiftVirtualNetworkConnectionWithCheck ... -func (c WebAppsClient) CreateOrUpdateSwiftVirtualNetworkConnectionWithCheck(ctx context.Context, id SiteId, input SwiftVirtualNetwork) (result CreateOrUpdateSwiftVirtualNetworkConnectionWithCheckOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdateSwiftVirtualNetworkConnectionWithCheck(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateSwiftVirtualNetworkConnectionWithCheck", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateSwiftVirtualNetworkConnectionWithCheck", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdateSwiftVirtualNetworkConnectionWithCheck(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateSwiftVirtualNetworkConnectionWithCheck", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdateSwiftVirtualNetworkConnectionWithCheck prepares the CreateOrUpdateSwiftVirtualNetworkConnectionWithCheck request. -func (c WebAppsClient) preparerForCreateOrUpdateSwiftVirtualNetworkConnectionWithCheck(ctx context.Context, id SiteId, input SwiftVirtualNetwork) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/networkConfig/virtualNetwork", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateOrUpdateSwiftVirtualNetworkConnectionWithCheck handles the response to the CreateOrUpdateSwiftVirtualNetworkConnectionWithCheck request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForCreateOrUpdateSwiftVirtualNetworkConnectionWithCheck(resp *http.Response) (result CreateOrUpdateSwiftVirtualNetworkConnectionWithCheckOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_createorupdateswiftvirtualnetworkconnectionwithcheckslot.go b/resource-manager/web/2022-09-01/webapps/method_createorupdateswiftvirtualnetworkconnectionwithcheckslot.go new file mode 100644 index 00000000000..18cc25026a6 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_createorupdateswiftvirtualnetworkconnectionwithcheckslot.go @@ -0,0 +1,56 @@ +package webapps + +import ( + "context" + "fmt" + "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 CreateOrUpdateSwiftVirtualNetworkConnectionWithCheckSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SwiftVirtualNetwork +} + +// CreateOrUpdateSwiftVirtualNetworkConnectionWithCheckSlot ... +func (c WebAppsClient) CreateOrUpdateSwiftVirtualNetworkConnectionWithCheckSlot(ctx context.Context, id SlotId, input SwiftVirtualNetwork) (result CreateOrUpdateSwiftVirtualNetworkConnectionWithCheckSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/networkConfig/virtualNetwork", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_createorupdateswiftvirtualnetworkconnectionwithcheckslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_createorupdateswiftvirtualnetworkconnectionwithcheckslot_autorest.go deleted file mode 100644 index 60cf6635eb7..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_createorupdateswiftvirtualnetworkconnectionwithcheckslot_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateSwiftVirtualNetworkConnectionWithCheckSlotOperationResponse struct { - HttpResponse *http.Response - Model *SwiftVirtualNetwork -} - -// CreateOrUpdateSwiftVirtualNetworkConnectionWithCheckSlot ... -func (c WebAppsClient) CreateOrUpdateSwiftVirtualNetworkConnectionWithCheckSlot(ctx context.Context, id SlotId, input SwiftVirtualNetwork) (result CreateOrUpdateSwiftVirtualNetworkConnectionWithCheckSlotOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdateSwiftVirtualNetworkConnectionWithCheckSlot(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateSwiftVirtualNetworkConnectionWithCheckSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateSwiftVirtualNetworkConnectionWithCheckSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdateSwiftVirtualNetworkConnectionWithCheckSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateSwiftVirtualNetworkConnectionWithCheckSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdateSwiftVirtualNetworkConnectionWithCheckSlot prepares the CreateOrUpdateSwiftVirtualNetworkConnectionWithCheckSlot request. -func (c WebAppsClient) preparerForCreateOrUpdateSwiftVirtualNetworkConnectionWithCheckSlot(ctx context.Context, id SlotId, input SwiftVirtualNetwork) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/networkConfig/virtualNetwork", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateOrUpdateSwiftVirtualNetworkConnectionWithCheckSlot handles the response to the CreateOrUpdateSwiftVirtualNetworkConnectionWithCheckSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForCreateOrUpdateSwiftVirtualNetworkConnectionWithCheckSlot(resp *http.Response) (result CreateOrUpdateSwiftVirtualNetworkConnectionWithCheckSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_createorupdatevnetconnection.go b/resource-manager/web/2022-09-01/webapps/method_createorupdatevnetconnection.go new file mode 100644 index 00000000000..cdee15bfb9b --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_createorupdatevnetconnection.go @@ -0,0 +1,55 @@ +package webapps + +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 CreateOrUpdateVnetConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetInfoResource +} + +// CreateOrUpdateVnetConnection ... +func (c WebAppsClient) CreateOrUpdateVnetConnection(ctx context.Context, id VirtualNetworkConnectionId, input VnetInfoResource) (result CreateOrUpdateVnetConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_createorupdatevnetconnection_autorest.go b/resource-manager/web/2022-09-01/webapps/method_createorupdatevnetconnection_autorest.go deleted file mode 100644 index 76dab168d50..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_createorupdatevnetconnection_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateVnetConnectionOperationResponse struct { - HttpResponse *http.Response - Model *VnetInfoResource -} - -// CreateOrUpdateVnetConnection ... -func (c WebAppsClient) CreateOrUpdateVnetConnection(ctx context.Context, id VirtualNetworkConnectionId, input VnetInfoResource) (result CreateOrUpdateVnetConnectionOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdateVnetConnection(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateVnetConnection", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateVnetConnection", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdateVnetConnection(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateVnetConnection", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdateVnetConnection prepares the CreateOrUpdateVnetConnection request. -func (c WebAppsClient) preparerForCreateOrUpdateVnetConnection(ctx context.Context, id VirtualNetworkConnectionId, input VnetInfoResource) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateOrUpdateVnetConnection handles the response to the CreateOrUpdateVnetConnection request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForCreateOrUpdateVnetConnection(resp *http.Response) (result CreateOrUpdateVnetConnectionOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_createorupdatevnetconnectiongateway.go b/resource-manager/web/2022-09-01/webapps/method_createorupdatevnetconnectiongateway.go new file mode 100644 index 00000000000..8299659c5bc --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_createorupdatevnetconnectiongateway.go @@ -0,0 +1,55 @@ +package webapps + +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 CreateOrUpdateVnetConnectionGatewayOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetGateway +} + +// CreateOrUpdateVnetConnectionGateway ... +func (c WebAppsClient) CreateOrUpdateVnetConnectionGateway(ctx context.Context, id GatewayId, input VnetGateway) (result CreateOrUpdateVnetConnectionGatewayOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_createorupdatevnetconnectiongateway_autorest.go b/resource-manager/web/2022-09-01/webapps/method_createorupdatevnetconnectiongateway_autorest.go deleted file mode 100644 index 993338103da..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_createorupdatevnetconnectiongateway_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateVnetConnectionGatewayOperationResponse struct { - HttpResponse *http.Response - Model *VnetGateway -} - -// CreateOrUpdateVnetConnectionGateway ... -func (c WebAppsClient) CreateOrUpdateVnetConnectionGateway(ctx context.Context, id GatewayId, input VnetGateway) (result CreateOrUpdateVnetConnectionGatewayOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdateVnetConnectionGateway(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateVnetConnectionGateway", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateVnetConnectionGateway", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdateVnetConnectionGateway(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateVnetConnectionGateway", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdateVnetConnectionGateway prepares the CreateOrUpdateVnetConnectionGateway request. -func (c WebAppsClient) preparerForCreateOrUpdateVnetConnectionGateway(ctx context.Context, id GatewayId, input VnetGateway) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateOrUpdateVnetConnectionGateway handles the response to the CreateOrUpdateVnetConnectionGateway request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForCreateOrUpdateVnetConnectionGateway(resp *http.Response) (result CreateOrUpdateVnetConnectionGatewayOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_createorupdatevnetconnectiongatewayslot.go b/resource-manager/web/2022-09-01/webapps/method_createorupdatevnetconnectiongatewayslot.go new file mode 100644 index 00000000000..b9275562753 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_createorupdatevnetconnectiongatewayslot.go @@ -0,0 +1,55 @@ +package webapps + +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 CreateOrUpdateVnetConnectionGatewaySlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetGateway +} + +// CreateOrUpdateVnetConnectionGatewaySlot ... +func (c WebAppsClient) CreateOrUpdateVnetConnectionGatewaySlot(ctx context.Context, id SlotVirtualNetworkConnectionGatewayId, input VnetGateway) (result CreateOrUpdateVnetConnectionGatewaySlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_createorupdatevnetconnectiongatewayslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_createorupdatevnetconnectiongatewayslot_autorest.go deleted file mode 100644 index f0494c209a3..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_createorupdatevnetconnectiongatewayslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateVnetConnectionGatewaySlotOperationResponse struct { - HttpResponse *http.Response - Model *VnetGateway -} - -// CreateOrUpdateVnetConnectionGatewaySlot ... -func (c WebAppsClient) CreateOrUpdateVnetConnectionGatewaySlot(ctx context.Context, id SlotVirtualNetworkConnectionGatewayId, input VnetGateway) (result CreateOrUpdateVnetConnectionGatewaySlotOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdateVnetConnectionGatewaySlot(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateVnetConnectionGatewaySlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateVnetConnectionGatewaySlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdateVnetConnectionGatewaySlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateVnetConnectionGatewaySlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdateVnetConnectionGatewaySlot prepares the CreateOrUpdateVnetConnectionGatewaySlot request. -func (c WebAppsClient) preparerForCreateOrUpdateVnetConnectionGatewaySlot(ctx context.Context, id SlotVirtualNetworkConnectionGatewayId, input VnetGateway) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateOrUpdateVnetConnectionGatewaySlot handles the response to the CreateOrUpdateVnetConnectionGatewaySlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForCreateOrUpdateVnetConnectionGatewaySlot(resp *http.Response) (result CreateOrUpdateVnetConnectionGatewaySlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_createorupdatevnetconnectionslot.go b/resource-manager/web/2022-09-01/webapps/method_createorupdatevnetconnectionslot.go new file mode 100644 index 00000000000..ccc486c6817 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_createorupdatevnetconnectionslot.go @@ -0,0 +1,55 @@ +package webapps + +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 CreateOrUpdateVnetConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetInfoResource +} + +// CreateOrUpdateVnetConnectionSlot ... +func (c WebAppsClient) CreateOrUpdateVnetConnectionSlot(ctx context.Context, id SlotVirtualNetworkConnectionId, input VnetInfoResource) (result CreateOrUpdateVnetConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_createorupdatevnetconnectionslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_createorupdatevnetconnectionslot_autorest.go deleted file mode 100644 index 9d7a6a58756..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_createorupdatevnetconnectionslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CreateOrUpdateVnetConnectionSlotOperationResponse struct { - HttpResponse *http.Response - Model *VnetInfoResource -} - -// CreateOrUpdateVnetConnectionSlot ... -func (c WebAppsClient) CreateOrUpdateVnetConnectionSlot(ctx context.Context, id SlotVirtualNetworkConnectionId, input VnetInfoResource) (result CreateOrUpdateVnetConnectionSlotOperationResponse, err error) { - req, err := c.preparerForCreateOrUpdateVnetConnectionSlot(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateVnetConnectionSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateVnetConnectionSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCreateOrUpdateVnetConnectionSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "CreateOrUpdateVnetConnectionSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCreateOrUpdateVnetConnectionSlot prepares the CreateOrUpdateVnetConnectionSlot request. -func (c WebAppsClient) preparerForCreateOrUpdateVnetConnectionSlot(ctx context.Context, id SlotVirtualNetworkConnectionId, input VnetInfoResource) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCreateOrUpdateVnetConnectionSlot handles the response to the CreateOrUpdateVnetConnectionSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForCreateOrUpdateVnetConnectionSlot(resp *http.Response) (result CreateOrUpdateVnetConnectionSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_delete.go b/resource-manager/web/2022-09-01/webapps/method_delete.go new file mode 100644 index 00000000000..85122563705 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_delete.go @@ -0,0 +1,80 @@ +package webapps + +import ( + "context" + "fmt" + "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 +} + +type DeleteOperationOptions struct { + DeleteEmptyServerFarm *bool + DeleteMetrics *bool +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.DeleteEmptyServerFarm != nil { + out.Append("deleteEmptyServerFarm", fmt.Sprintf("%v", *o.DeleteEmptyServerFarm)) + } + if o.DeleteMetrics != nil { + out.Append("deleteMetrics", fmt.Sprintf("%v", *o.DeleteMetrics)) + } + return &out +} + +// Delete ... +func (c WebAppsClient) Delete(ctx context.Context, id SiteId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_delete_autorest.go b/resource-manager/web/2022-09-01/webapps/method_delete_autorest.go deleted file mode 100644 index 216b360f8e4..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_delete_autorest.go +++ /dev/null @@ -1,100 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// 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 -} - -type DeleteOperationOptions struct { - DeleteEmptyServerFarm *bool - DeleteMetrics *bool -} - -func DefaultDeleteOperationOptions() DeleteOperationOptions { - return DeleteOperationOptions{} -} - -func (o DeleteOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o DeleteOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.DeleteEmptyServerFarm != nil { - out["deleteEmptyServerFarm"] = *o.DeleteEmptyServerFarm - } - - if o.DeleteMetrics != nil { - out["deleteMetrics"] = *o.DeleteMetrics - } - - return out -} - -// Delete ... -func (c WebAppsClient) Delete(ctx context.Context, id SiteId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { - req, err := c.preparerForDelete(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "Delete", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "Delete", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDelete(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "Delete", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDelete prepares the Delete request. -func (c WebAppsClient) preparerForDelete(ctx context.Context, id SiteId, options DeleteOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletebackup.go b/resource-manager/web/2022-09-01/webapps/method_deletebackup.go new file mode 100644 index 00000000000..ed9755843cc --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_deletebackup.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteBackupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteBackup ... +func (c WebAppsClient) DeleteBackup(ctx context.Context, id BackupId) (result DeleteBackupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletebackup_autorest.go b/resource-manager/web/2022-09-01/webapps/method_deletebackup_autorest.go deleted file mode 100644 index 70e2e9f765b..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_deletebackup_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteBackupOperationResponse struct { - HttpResponse *http.Response -} - -// DeleteBackup ... -func (c WebAppsClient) DeleteBackup(ctx context.Context, id BackupId) (result DeleteBackupOperationResponse, err error) { - req, err := c.preparerForDeleteBackup(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteBackup", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteBackup", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeleteBackup(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteBackup", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeleteBackup prepares the DeleteBackup request. -func (c WebAppsClient) preparerForDeleteBackup(ctx context.Context, id BackupId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeleteBackup handles the response to the DeleteBackup request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForDeleteBackup(resp *http.Response) (result DeleteBackupOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletebackupconfiguration.go b/resource-manager/web/2022-09-01/webapps/method_deletebackupconfiguration.go new file mode 100644 index 00000000000..4aee8886538 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_deletebackupconfiguration.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "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 DeleteBackupConfigurationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteBackupConfiguration ... +func (c WebAppsClient) DeleteBackupConfiguration(ctx context.Context, id SiteId) (result DeleteBackupConfigurationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: fmt.Sprintf("%s/config/backup", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletebackupconfiguration_autorest.go b/resource-manager/web/2022-09-01/webapps/method_deletebackupconfiguration_autorest.go deleted file mode 100644 index e6a21387ceb..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_deletebackupconfiguration_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteBackupConfigurationOperationResponse struct { - HttpResponse *http.Response -} - -// DeleteBackupConfiguration ... -func (c WebAppsClient) DeleteBackupConfiguration(ctx context.Context, id SiteId) (result DeleteBackupConfigurationOperationResponse, err error) { - req, err := c.preparerForDeleteBackupConfiguration(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteBackupConfiguration", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteBackupConfiguration", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeleteBackupConfiguration(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteBackupConfiguration", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeleteBackupConfiguration prepares the DeleteBackupConfiguration request. -func (c WebAppsClient) preparerForDeleteBackupConfiguration(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/backup", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeleteBackupConfiguration handles the response to the DeleteBackupConfiguration request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForDeleteBackupConfiguration(resp *http.Response) (result DeleteBackupConfigurationOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletebackupconfigurationslot.go b/resource-manager/web/2022-09-01/webapps/method_deletebackupconfigurationslot.go new file mode 100644 index 00000000000..d22a89f0fb4 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_deletebackupconfigurationslot.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "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 DeleteBackupConfigurationSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteBackupConfigurationSlot ... +func (c WebAppsClient) DeleteBackupConfigurationSlot(ctx context.Context, id SlotId) (result DeleteBackupConfigurationSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: fmt.Sprintf("%s/config/backup", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletebackupconfigurationslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_deletebackupconfigurationslot_autorest.go deleted file mode 100644 index 7563702ad74..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_deletebackupconfigurationslot_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteBackupConfigurationSlotOperationResponse struct { - HttpResponse *http.Response -} - -// DeleteBackupConfigurationSlot ... -func (c WebAppsClient) DeleteBackupConfigurationSlot(ctx context.Context, id SlotId) (result DeleteBackupConfigurationSlotOperationResponse, err error) { - req, err := c.preparerForDeleteBackupConfigurationSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteBackupConfigurationSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteBackupConfigurationSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeleteBackupConfigurationSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteBackupConfigurationSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeleteBackupConfigurationSlot prepares the DeleteBackupConfigurationSlot request. -func (c WebAppsClient) preparerForDeleteBackupConfigurationSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/backup", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeleteBackupConfigurationSlot handles the response to the DeleteBackupConfigurationSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForDeleteBackupConfigurationSlot(resp *http.Response) (result DeleteBackupConfigurationSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletebackupslot.go b/resource-manager/web/2022-09-01/webapps/method_deletebackupslot.go new file mode 100644 index 00000000000..1306301529d --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_deletebackupslot.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteBackupSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteBackupSlot ... +func (c WebAppsClient) DeleteBackupSlot(ctx context.Context, id SlotBackupId) (result DeleteBackupSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletebackupslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_deletebackupslot_autorest.go deleted file mode 100644 index c551fe1e8d6..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_deletebackupslot_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteBackupSlotOperationResponse struct { - HttpResponse *http.Response -} - -// DeleteBackupSlot ... -func (c WebAppsClient) DeleteBackupSlot(ctx context.Context, id SlotBackupId) (result DeleteBackupSlotOperationResponse, err error) { - req, err := c.preparerForDeleteBackupSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteBackupSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteBackupSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeleteBackupSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteBackupSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeleteBackupSlot prepares the DeleteBackupSlot request. -func (c WebAppsClient) preparerForDeleteBackupSlot(ctx context.Context, id SlotBackupId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeleteBackupSlot handles the response to the DeleteBackupSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForDeleteBackupSlot(resp *http.Response) (result DeleteBackupSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletecontinuouswebjob.go b/resource-manager/web/2022-09-01/webapps/method_deletecontinuouswebjob.go new file mode 100644 index 00000000000..15ba50ef5b1 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_deletecontinuouswebjob.go @@ -0,0 +1,47 @@ +package webapps + +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 DeleteContinuousWebJobOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteContinuousWebJob ... +func (c WebAppsClient) DeleteContinuousWebJob(ctx context.Context, id ContinuousWebJobId) (result DeleteContinuousWebJobOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletecontinuouswebjob_autorest.go b/resource-manager/web/2022-09-01/webapps/method_deletecontinuouswebjob_autorest.go deleted file mode 100644 index cb5e94a5342..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_deletecontinuouswebjob_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteContinuousWebJobOperationResponse struct { - HttpResponse *http.Response -} - -// DeleteContinuousWebJob ... -func (c WebAppsClient) DeleteContinuousWebJob(ctx context.Context, id ContinuousWebJobId) (result DeleteContinuousWebJobOperationResponse, err error) { - req, err := c.preparerForDeleteContinuousWebJob(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteContinuousWebJob", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteContinuousWebJob", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeleteContinuousWebJob(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteContinuousWebJob", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeleteContinuousWebJob prepares the DeleteContinuousWebJob request. -func (c WebAppsClient) preparerForDeleteContinuousWebJob(ctx context.Context, id ContinuousWebJobId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeleteContinuousWebJob handles the response to the DeleteContinuousWebJob request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForDeleteContinuousWebJob(resp *http.Response) (result DeleteContinuousWebJobOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletecontinuouswebjobslot.go b/resource-manager/web/2022-09-01/webapps/method_deletecontinuouswebjobslot.go new file mode 100644 index 00000000000..ecf9f44f57a --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_deletecontinuouswebjobslot.go @@ -0,0 +1,47 @@ +package webapps + +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 DeleteContinuousWebJobSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteContinuousWebJobSlot ... +func (c WebAppsClient) DeleteContinuousWebJobSlot(ctx context.Context, id SlotContinuousWebJobId) (result DeleteContinuousWebJobSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletecontinuouswebjobslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_deletecontinuouswebjobslot_autorest.go deleted file mode 100644 index d01c1188d64..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_deletecontinuouswebjobslot_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteContinuousWebJobSlotOperationResponse struct { - HttpResponse *http.Response -} - -// DeleteContinuousWebJobSlot ... -func (c WebAppsClient) DeleteContinuousWebJobSlot(ctx context.Context, id SlotContinuousWebJobId) (result DeleteContinuousWebJobSlotOperationResponse, err error) { - req, err := c.preparerForDeleteContinuousWebJobSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteContinuousWebJobSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteContinuousWebJobSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeleteContinuousWebJobSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteContinuousWebJobSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeleteContinuousWebJobSlot prepares the DeleteContinuousWebJobSlot request. -func (c WebAppsClient) preparerForDeleteContinuousWebJobSlot(ctx context.Context, id SlotContinuousWebJobId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeleteContinuousWebJobSlot handles the response to the DeleteContinuousWebJobSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForDeleteContinuousWebJobSlot(resp *http.Response) (result DeleteContinuousWebJobSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletedeployment.go b/resource-manager/web/2022-09-01/webapps/method_deletedeployment.go new file mode 100644 index 00000000000..b5a9c1afb8e --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_deletedeployment.go @@ -0,0 +1,47 @@ +package webapps + +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 DeleteDeploymentOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteDeployment ... +func (c WebAppsClient) DeleteDeployment(ctx context.Context, id DeploymentId) (result DeleteDeploymentOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletedeployment_autorest.go b/resource-manager/web/2022-09-01/webapps/method_deletedeployment_autorest.go deleted file mode 100644 index 941e15ab12b..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_deletedeployment_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteDeploymentOperationResponse struct { - HttpResponse *http.Response -} - -// DeleteDeployment ... -func (c WebAppsClient) DeleteDeployment(ctx context.Context, id DeploymentId) (result DeleteDeploymentOperationResponse, err error) { - req, err := c.preparerForDeleteDeployment(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteDeployment", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteDeployment", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeleteDeployment(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteDeployment", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeleteDeployment prepares the DeleteDeployment request. -func (c WebAppsClient) preparerForDeleteDeployment(ctx context.Context, id DeploymentId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeleteDeployment handles the response to the DeleteDeployment request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForDeleteDeployment(resp *http.Response) (result DeleteDeploymentOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletedeploymentslot.go b/resource-manager/web/2022-09-01/webapps/method_deletedeploymentslot.go new file mode 100644 index 00000000000..2085236a562 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_deletedeploymentslot.go @@ -0,0 +1,47 @@ +package webapps + +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 DeleteDeploymentSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteDeploymentSlot ... +func (c WebAppsClient) DeleteDeploymentSlot(ctx context.Context, id SlotDeploymentId) (result DeleteDeploymentSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletedeploymentslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_deletedeploymentslot_autorest.go deleted file mode 100644 index 592451640d5..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_deletedeploymentslot_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteDeploymentSlotOperationResponse struct { - HttpResponse *http.Response -} - -// DeleteDeploymentSlot ... -func (c WebAppsClient) DeleteDeploymentSlot(ctx context.Context, id SlotDeploymentId) (result DeleteDeploymentSlotOperationResponse, err error) { - req, err := c.preparerForDeleteDeploymentSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteDeploymentSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteDeploymentSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeleteDeploymentSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteDeploymentSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeleteDeploymentSlot prepares the DeleteDeploymentSlot request. -func (c WebAppsClient) preparerForDeleteDeploymentSlot(ctx context.Context, id SlotDeploymentId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeleteDeploymentSlot handles the response to the DeleteDeploymentSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForDeleteDeploymentSlot(resp *http.Response) (result DeleteDeploymentSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletedomainownershipidentifier.go b/resource-manager/web/2022-09-01/webapps/method_deletedomainownershipidentifier.go new file mode 100644 index 00000000000..f2af6b45fa2 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_deletedomainownershipidentifier.go @@ -0,0 +1,47 @@ +package webapps + +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 DeleteDomainOwnershipIdentifierOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteDomainOwnershipIdentifier ... +func (c WebAppsClient) DeleteDomainOwnershipIdentifier(ctx context.Context, id DomainOwnershipIdentifierId) (result DeleteDomainOwnershipIdentifierOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletedomainownershipidentifier_autorest.go b/resource-manager/web/2022-09-01/webapps/method_deletedomainownershipidentifier_autorest.go deleted file mode 100644 index 00ca0f37bee..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_deletedomainownershipidentifier_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteDomainOwnershipIdentifierOperationResponse struct { - HttpResponse *http.Response -} - -// DeleteDomainOwnershipIdentifier ... -func (c WebAppsClient) DeleteDomainOwnershipIdentifier(ctx context.Context, id DomainOwnershipIdentifierId) (result DeleteDomainOwnershipIdentifierOperationResponse, err error) { - req, err := c.preparerForDeleteDomainOwnershipIdentifier(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteDomainOwnershipIdentifier", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteDomainOwnershipIdentifier", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeleteDomainOwnershipIdentifier(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteDomainOwnershipIdentifier", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeleteDomainOwnershipIdentifier prepares the DeleteDomainOwnershipIdentifier request. -func (c WebAppsClient) preparerForDeleteDomainOwnershipIdentifier(ctx context.Context, id DomainOwnershipIdentifierId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeleteDomainOwnershipIdentifier handles the response to the DeleteDomainOwnershipIdentifier request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForDeleteDomainOwnershipIdentifier(resp *http.Response) (result DeleteDomainOwnershipIdentifierOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletedomainownershipidentifierslot.go b/resource-manager/web/2022-09-01/webapps/method_deletedomainownershipidentifierslot.go new file mode 100644 index 00000000000..e5c4e68d77b --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_deletedomainownershipidentifierslot.go @@ -0,0 +1,47 @@ +package webapps + +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 DeleteDomainOwnershipIdentifierSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteDomainOwnershipIdentifierSlot ... +func (c WebAppsClient) DeleteDomainOwnershipIdentifierSlot(ctx context.Context, id SlotDomainOwnershipIdentifierId) (result DeleteDomainOwnershipIdentifierSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletedomainownershipidentifierslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_deletedomainownershipidentifierslot_autorest.go deleted file mode 100644 index ac8047e63dc..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_deletedomainownershipidentifierslot_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteDomainOwnershipIdentifierSlotOperationResponse struct { - HttpResponse *http.Response -} - -// DeleteDomainOwnershipIdentifierSlot ... -func (c WebAppsClient) DeleteDomainOwnershipIdentifierSlot(ctx context.Context, id SlotDomainOwnershipIdentifierId) (result DeleteDomainOwnershipIdentifierSlotOperationResponse, err error) { - req, err := c.preparerForDeleteDomainOwnershipIdentifierSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteDomainOwnershipIdentifierSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteDomainOwnershipIdentifierSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeleteDomainOwnershipIdentifierSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteDomainOwnershipIdentifierSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeleteDomainOwnershipIdentifierSlot prepares the DeleteDomainOwnershipIdentifierSlot request. -func (c WebAppsClient) preparerForDeleteDomainOwnershipIdentifierSlot(ctx context.Context, id SlotDomainOwnershipIdentifierId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeleteDomainOwnershipIdentifierSlot handles the response to the DeleteDomainOwnershipIdentifierSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForDeleteDomainOwnershipIdentifierSlot(resp *http.Response) (result DeleteDomainOwnershipIdentifierSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletefunction.go b/resource-manager/web/2022-09-01/webapps/method_deletefunction.go new file mode 100644 index 00000000000..c1c3fd5122b --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_deletefunction.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteFunctionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteFunction ... +func (c WebAppsClient) DeleteFunction(ctx context.Context, id FunctionId) (result DeleteFunctionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletefunction_autorest.go b/resource-manager/web/2022-09-01/webapps/method_deletefunction_autorest.go deleted file mode 100644 index 53af4d1a32f..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_deletefunction_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteFunctionOperationResponse struct { - HttpResponse *http.Response -} - -// DeleteFunction ... -func (c WebAppsClient) DeleteFunction(ctx context.Context, id FunctionId) (result DeleteFunctionOperationResponse, err error) { - req, err := c.preparerForDeleteFunction(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteFunction", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteFunction", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeleteFunction(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteFunction", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeleteFunction prepares the DeleteFunction request. -func (c WebAppsClient) preparerForDeleteFunction(ctx context.Context, id FunctionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeleteFunction handles the response to the DeleteFunction request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForDeleteFunction(resp *http.Response) (result DeleteFunctionOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletefunctionsecret.go b/resource-manager/web/2022-09-01/webapps/method_deletefunctionsecret.go new file mode 100644 index 00000000000..c245c85fd48 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_deletefunctionsecret.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteFunctionSecretOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteFunctionSecret ... +func (c WebAppsClient) DeleteFunctionSecret(ctx context.Context, id KeyId) (result DeleteFunctionSecretOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletefunctionsecret_autorest.go b/resource-manager/web/2022-09-01/webapps/method_deletefunctionsecret_autorest.go deleted file mode 100644 index 5dd6987bc2e..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_deletefunctionsecret_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteFunctionSecretOperationResponse struct { - HttpResponse *http.Response -} - -// DeleteFunctionSecret ... -func (c WebAppsClient) DeleteFunctionSecret(ctx context.Context, id KeyId) (result DeleteFunctionSecretOperationResponse, err error) { - req, err := c.preparerForDeleteFunctionSecret(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteFunctionSecret", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteFunctionSecret", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeleteFunctionSecret(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteFunctionSecret", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeleteFunctionSecret prepares the DeleteFunctionSecret request. -func (c WebAppsClient) preparerForDeleteFunctionSecret(ctx context.Context, id KeyId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeleteFunctionSecret handles the response to the DeleteFunctionSecret request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForDeleteFunctionSecret(resp *http.Response) (result DeleteFunctionSecretOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletefunctionsecretslot.go b/resource-manager/web/2022-09-01/webapps/method_deletefunctionsecretslot.go new file mode 100644 index 00000000000..d7c6179d9b9 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_deletefunctionsecretslot.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteFunctionSecretSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteFunctionSecretSlot ... +func (c WebAppsClient) DeleteFunctionSecretSlot(ctx context.Context, id FunctionKeyId) (result DeleteFunctionSecretSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletefunctionsecretslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_deletefunctionsecretslot_autorest.go deleted file mode 100644 index b3845bf186c..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_deletefunctionsecretslot_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteFunctionSecretSlotOperationResponse struct { - HttpResponse *http.Response -} - -// DeleteFunctionSecretSlot ... -func (c WebAppsClient) DeleteFunctionSecretSlot(ctx context.Context, id FunctionKeyId) (result DeleteFunctionSecretSlotOperationResponse, err error) { - req, err := c.preparerForDeleteFunctionSecretSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteFunctionSecretSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteFunctionSecretSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeleteFunctionSecretSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteFunctionSecretSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeleteFunctionSecretSlot prepares the DeleteFunctionSecretSlot request. -func (c WebAppsClient) preparerForDeleteFunctionSecretSlot(ctx context.Context, id FunctionKeyId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeleteFunctionSecretSlot handles the response to the DeleteFunctionSecretSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForDeleteFunctionSecretSlot(resp *http.Response) (result DeleteFunctionSecretSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletehostnamebinding.go b/resource-manager/web/2022-09-01/webapps/method_deletehostnamebinding.go new file mode 100644 index 00000000000..89df4787e41 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_deletehostnamebinding.go @@ -0,0 +1,47 @@ +package webapps + +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 DeleteHostNameBindingOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteHostNameBinding ... +func (c WebAppsClient) DeleteHostNameBinding(ctx context.Context, id HostNameBindingId) (result DeleteHostNameBindingOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletehostnamebinding_autorest.go b/resource-manager/web/2022-09-01/webapps/method_deletehostnamebinding_autorest.go deleted file mode 100644 index d84c82ba7bc..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_deletehostnamebinding_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteHostNameBindingOperationResponse struct { - HttpResponse *http.Response -} - -// DeleteHostNameBinding ... -func (c WebAppsClient) DeleteHostNameBinding(ctx context.Context, id HostNameBindingId) (result DeleteHostNameBindingOperationResponse, err error) { - req, err := c.preparerForDeleteHostNameBinding(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteHostNameBinding", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteHostNameBinding", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeleteHostNameBinding(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteHostNameBinding", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeleteHostNameBinding prepares the DeleteHostNameBinding request. -func (c WebAppsClient) preparerForDeleteHostNameBinding(ctx context.Context, id HostNameBindingId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeleteHostNameBinding handles the response to the DeleteHostNameBinding request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForDeleteHostNameBinding(resp *http.Response) (result DeleteHostNameBindingOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletehostnamebindingslot.go b/resource-manager/web/2022-09-01/webapps/method_deletehostnamebindingslot.go new file mode 100644 index 00000000000..cde7886dfa2 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_deletehostnamebindingslot.go @@ -0,0 +1,47 @@ +package webapps + +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 DeleteHostNameBindingSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteHostNameBindingSlot ... +func (c WebAppsClient) DeleteHostNameBindingSlot(ctx context.Context, id SlotHostNameBindingId) (result DeleteHostNameBindingSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletehostnamebindingslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_deletehostnamebindingslot_autorest.go deleted file mode 100644 index d72606ea204..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_deletehostnamebindingslot_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteHostNameBindingSlotOperationResponse struct { - HttpResponse *http.Response -} - -// DeleteHostNameBindingSlot ... -func (c WebAppsClient) DeleteHostNameBindingSlot(ctx context.Context, id SlotHostNameBindingId) (result DeleteHostNameBindingSlotOperationResponse, err error) { - req, err := c.preparerForDeleteHostNameBindingSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteHostNameBindingSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteHostNameBindingSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeleteHostNameBindingSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteHostNameBindingSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeleteHostNameBindingSlot prepares the DeleteHostNameBindingSlot request. -func (c WebAppsClient) preparerForDeleteHostNameBindingSlot(ctx context.Context, id SlotHostNameBindingId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeleteHostNameBindingSlot handles the response to the DeleteHostNameBindingSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForDeleteHostNameBindingSlot(resp *http.Response) (result DeleteHostNameBindingSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletehostsecret.go b/resource-manager/web/2022-09-01/webapps/method_deletehostsecret.go new file mode 100644 index 00000000000..261b9781399 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_deletehostsecret.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteHostSecretOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteHostSecret ... +func (c WebAppsClient) DeleteHostSecret(ctx context.Context, id DefaultId) (result DeleteHostSecretOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletehostsecret_autorest.go b/resource-manager/web/2022-09-01/webapps/method_deletehostsecret_autorest.go deleted file mode 100644 index 16c28a3d725..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_deletehostsecret_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteHostSecretOperationResponse struct { - HttpResponse *http.Response -} - -// DeleteHostSecret ... -func (c WebAppsClient) DeleteHostSecret(ctx context.Context, id DefaultId) (result DeleteHostSecretOperationResponse, err error) { - req, err := c.preparerForDeleteHostSecret(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteHostSecret", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteHostSecret", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeleteHostSecret(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteHostSecret", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeleteHostSecret prepares the DeleteHostSecret request. -func (c WebAppsClient) preparerForDeleteHostSecret(ctx context.Context, id DefaultId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeleteHostSecret handles the response to the DeleteHostSecret request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForDeleteHostSecret(resp *http.Response) (result DeleteHostSecretOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletehostsecretslot.go b/resource-manager/web/2022-09-01/webapps/method_deletehostsecretslot.go new file mode 100644 index 00000000000..06fbc8c6f47 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_deletehostsecretslot.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteHostSecretSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteHostSecretSlot ... +func (c WebAppsClient) DeleteHostSecretSlot(ctx context.Context, id HostDefaultId) (result DeleteHostSecretSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletehostsecretslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_deletehostsecretslot_autorest.go deleted file mode 100644 index 44d29c84b70..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_deletehostsecretslot_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteHostSecretSlotOperationResponse struct { - HttpResponse *http.Response -} - -// DeleteHostSecretSlot ... -func (c WebAppsClient) DeleteHostSecretSlot(ctx context.Context, id HostDefaultId) (result DeleteHostSecretSlotOperationResponse, err error) { - req, err := c.preparerForDeleteHostSecretSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteHostSecretSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteHostSecretSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeleteHostSecretSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteHostSecretSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeleteHostSecretSlot prepares the DeleteHostSecretSlot request. -func (c WebAppsClient) preparerForDeleteHostSecretSlot(ctx context.Context, id HostDefaultId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeleteHostSecretSlot handles the response to the DeleteHostSecretSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForDeleteHostSecretSlot(resp *http.Response) (result DeleteHostSecretSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletehybridconnection.go b/resource-manager/web/2022-09-01/webapps/method_deletehybridconnection.go new file mode 100644 index 00000000000..945ea7260d8 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_deletehybridconnection.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteHybridConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteHybridConnection ... +func (c WebAppsClient) DeleteHybridConnection(ctx context.Context, id RelayId) (result DeleteHybridConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletehybridconnection_autorest.go b/resource-manager/web/2022-09-01/webapps/method_deletehybridconnection_autorest.go deleted file mode 100644 index 0a2515040ac..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_deletehybridconnection_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteHybridConnectionOperationResponse struct { - HttpResponse *http.Response -} - -// DeleteHybridConnection ... -func (c WebAppsClient) DeleteHybridConnection(ctx context.Context, id RelayId) (result DeleteHybridConnectionOperationResponse, err error) { - req, err := c.preparerForDeleteHybridConnection(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteHybridConnection", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteHybridConnection", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeleteHybridConnection(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteHybridConnection", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeleteHybridConnection prepares the DeleteHybridConnection request. -func (c WebAppsClient) preparerForDeleteHybridConnection(ctx context.Context, id RelayId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeleteHybridConnection handles the response to the DeleteHybridConnection request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForDeleteHybridConnection(resp *http.Response) (result DeleteHybridConnectionOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletehybridconnectionslot.go b/resource-manager/web/2022-09-01/webapps/method_deletehybridconnectionslot.go new file mode 100644 index 00000000000..53e6125e2e2 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_deletehybridconnectionslot.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteHybridConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteHybridConnectionSlot ... +func (c WebAppsClient) DeleteHybridConnectionSlot(ctx context.Context, id SlotHybridConnectionNamespaceRelayId) (result DeleteHybridConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletehybridconnectionslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_deletehybridconnectionslot_autorest.go deleted file mode 100644 index 37eb2414d3a..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_deletehybridconnectionslot_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteHybridConnectionSlotOperationResponse struct { - HttpResponse *http.Response -} - -// DeleteHybridConnectionSlot ... -func (c WebAppsClient) DeleteHybridConnectionSlot(ctx context.Context, id SlotHybridConnectionNamespaceRelayId) (result DeleteHybridConnectionSlotOperationResponse, err error) { - req, err := c.preparerForDeleteHybridConnectionSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteHybridConnectionSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteHybridConnectionSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeleteHybridConnectionSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteHybridConnectionSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeleteHybridConnectionSlot prepares the DeleteHybridConnectionSlot request. -func (c WebAppsClient) preparerForDeleteHybridConnectionSlot(ctx context.Context, id SlotHybridConnectionNamespaceRelayId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeleteHybridConnectionSlot handles the response to the DeleteHybridConnectionSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForDeleteHybridConnectionSlot(resp *http.Response) (result DeleteHybridConnectionSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_deleteinstancefunctionslot.go b/resource-manager/web/2022-09-01/webapps/method_deleteinstancefunctionslot.go new file mode 100644 index 00000000000..f17ccd19c6f --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_deleteinstancefunctionslot.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteInstanceFunctionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteInstanceFunctionSlot ... +func (c WebAppsClient) DeleteInstanceFunctionSlot(ctx context.Context, id SlotFunctionId) (result DeleteInstanceFunctionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_deleteinstancefunctionslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_deleteinstancefunctionslot_autorest.go deleted file mode 100644 index aa8861a5c34..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_deleteinstancefunctionslot_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteInstanceFunctionSlotOperationResponse struct { - HttpResponse *http.Response -} - -// DeleteInstanceFunctionSlot ... -func (c WebAppsClient) DeleteInstanceFunctionSlot(ctx context.Context, id SlotFunctionId) (result DeleteInstanceFunctionSlotOperationResponse, err error) { - req, err := c.preparerForDeleteInstanceFunctionSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteInstanceFunctionSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteInstanceFunctionSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeleteInstanceFunctionSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteInstanceFunctionSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeleteInstanceFunctionSlot prepares the DeleteInstanceFunctionSlot request. -func (c WebAppsClient) preparerForDeleteInstanceFunctionSlot(ctx context.Context, id SlotFunctionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeleteInstanceFunctionSlot handles the response to the DeleteInstanceFunctionSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForDeleteInstanceFunctionSlot(resp *http.Response) (result DeleteInstanceFunctionSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_deleteinstanceprocess.go b/resource-manager/web/2022-09-01/webapps/method_deleteinstanceprocess.go new file mode 100644 index 00000000000..b9aa4120532 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_deleteinstanceprocess.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteInstanceProcessOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteInstanceProcess ... +func (c WebAppsClient) DeleteInstanceProcess(ctx context.Context, id InstanceProcessId) (result DeleteInstanceProcessOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_deleteinstanceprocess_autorest.go b/resource-manager/web/2022-09-01/webapps/method_deleteinstanceprocess_autorest.go deleted file mode 100644 index 01326ee5fe5..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_deleteinstanceprocess_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteInstanceProcessOperationResponse struct { - HttpResponse *http.Response -} - -// DeleteInstanceProcess ... -func (c WebAppsClient) DeleteInstanceProcess(ctx context.Context, id InstanceProcessId) (result DeleteInstanceProcessOperationResponse, err error) { - req, err := c.preparerForDeleteInstanceProcess(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteInstanceProcess", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteInstanceProcess", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeleteInstanceProcess(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteInstanceProcess", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeleteInstanceProcess prepares the DeleteInstanceProcess request. -func (c WebAppsClient) preparerForDeleteInstanceProcess(ctx context.Context, id InstanceProcessId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeleteInstanceProcess handles the response to the DeleteInstanceProcess request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForDeleteInstanceProcess(resp *http.Response) (result DeleteInstanceProcessOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_deleteinstanceprocessslot.go b/resource-manager/web/2022-09-01/webapps/method_deleteinstanceprocessslot.go new file mode 100644 index 00000000000..07fa6571a52 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_deleteinstanceprocessslot.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteInstanceProcessSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteInstanceProcessSlot ... +func (c WebAppsClient) DeleteInstanceProcessSlot(ctx context.Context, id SlotInstanceProcessId) (result DeleteInstanceProcessSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_deleteinstanceprocessslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_deleteinstanceprocessslot_autorest.go deleted file mode 100644 index 9c0c94c0f45..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_deleteinstanceprocessslot_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteInstanceProcessSlotOperationResponse struct { - HttpResponse *http.Response -} - -// DeleteInstanceProcessSlot ... -func (c WebAppsClient) DeleteInstanceProcessSlot(ctx context.Context, id SlotInstanceProcessId) (result DeleteInstanceProcessSlotOperationResponse, err error) { - req, err := c.preparerForDeleteInstanceProcessSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteInstanceProcessSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteInstanceProcessSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeleteInstanceProcessSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteInstanceProcessSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeleteInstanceProcessSlot prepares the DeleteInstanceProcessSlot request. -func (c WebAppsClient) preparerForDeleteInstanceProcessSlot(ctx context.Context, id SlotInstanceProcessId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeleteInstanceProcessSlot handles the response to the DeleteInstanceProcessSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForDeleteInstanceProcessSlot(resp *http.Response) (result DeleteInstanceProcessSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletepremieraddon.go b/resource-manager/web/2022-09-01/webapps/method_deletepremieraddon.go new file mode 100644 index 00000000000..dfa8dae247a --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_deletepremieraddon.go @@ -0,0 +1,46 @@ +package webapps + +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 DeletePremierAddOnOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeletePremierAddOn ... +func (c WebAppsClient) DeletePremierAddOn(ctx context.Context, id PremierAddonId) (result DeletePremierAddOnOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletepremieraddon_autorest.go b/resource-manager/web/2022-09-01/webapps/method_deletepremieraddon_autorest.go deleted file mode 100644 index d9e7b38897d..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_deletepremieraddon_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeletePremierAddOnOperationResponse struct { - HttpResponse *http.Response -} - -// DeletePremierAddOn ... -func (c WebAppsClient) DeletePremierAddOn(ctx context.Context, id PremierAddonId) (result DeletePremierAddOnOperationResponse, err error) { - req, err := c.preparerForDeletePremierAddOn(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeletePremierAddOn", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeletePremierAddOn", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeletePremierAddOn(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeletePremierAddOn", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeletePremierAddOn prepares the DeletePremierAddOn request. -func (c WebAppsClient) preparerForDeletePremierAddOn(ctx context.Context, id PremierAddonId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeletePremierAddOn handles the response to the DeletePremierAddOn request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForDeletePremierAddOn(resp *http.Response) (result DeletePremierAddOnOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletepremieraddonslot.go b/resource-manager/web/2022-09-01/webapps/method_deletepremieraddonslot.go new file mode 100644 index 00000000000..29d2170686a --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_deletepremieraddonslot.go @@ -0,0 +1,46 @@ +package webapps + +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 DeletePremierAddOnSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeletePremierAddOnSlot ... +func (c WebAppsClient) DeletePremierAddOnSlot(ctx context.Context, id SlotPremierAddonId) (result DeletePremierAddOnSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletepremieraddonslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_deletepremieraddonslot_autorest.go deleted file mode 100644 index 833a202604b..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_deletepremieraddonslot_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeletePremierAddOnSlotOperationResponse struct { - HttpResponse *http.Response -} - -// DeletePremierAddOnSlot ... -func (c WebAppsClient) DeletePremierAddOnSlot(ctx context.Context, id SlotPremierAddonId) (result DeletePremierAddOnSlotOperationResponse, err error) { - req, err := c.preparerForDeletePremierAddOnSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeletePremierAddOnSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeletePremierAddOnSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeletePremierAddOnSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeletePremierAddOnSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeletePremierAddOnSlot prepares the DeletePremierAddOnSlot request. -func (c WebAppsClient) preparerForDeletePremierAddOnSlot(ctx context.Context, id SlotPremierAddonId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeletePremierAddOnSlot handles the response to the DeletePremierAddOnSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForDeletePremierAddOnSlot(resp *http.Response) (result DeletePremierAddOnSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_deleteprivateendpointconnection.go b/resource-manager/web/2022-09-01/webapps/method_deleteprivateendpointconnection.go new file mode 100644 index 00000000000..601445466b7 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_deleteprivateendpointconnection.go @@ -0,0 +1,71 @@ +package webapps + +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 DeletePrivateEndpointConnectionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// DeletePrivateEndpointConnection ... +func (c WebAppsClient) DeletePrivateEndpointConnection(ctx context.Context, id PrivateEndpointConnectionId) (result DeletePrivateEndpointConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 +} + +// DeletePrivateEndpointConnectionThenPoll performs DeletePrivateEndpointConnection then polls until it's completed +func (c WebAppsClient) DeletePrivateEndpointConnectionThenPoll(ctx context.Context, id PrivateEndpointConnectionId) error { + result, err := c.DeletePrivateEndpointConnection(ctx, id) + if err != nil { + return fmt.Errorf("performing DeletePrivateEndpointConnection: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DeletePrivateEndpointConnection: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/webapps/method_deleteprivateendpointconnection_autorest.go b/resource-manager/web/2022-09-01/webapps/method_deleteprivateendpointconnection_autorest.go deleted file mode 100644 index 82fd7e583ec..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_deleteprivateendpointconnection_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeletePrivateEndpointConnectionOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// DeletePrivateEndpointConnection ... -func (c WebAppsClient) DeletePrivateEndpointConnection(ctx context.Context, id PrivateEndpointConnectionId) (result DeletePrivateEndpointConnectionOperationResponse, err error) { - req, err := c.preparerForDeletePrivateEndpointConnection(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeletePrivateEndpointConnection", nil, "Failure preparing request") - return - } - - result, err = c.senderForDeletePrivateEndpointConnection(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeletePrivateEndpointConnection", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeletePrivateEndpointConnectionThenPoll performs DeletePrivateEndpointConnection then polls until it's completed -func (c WebAppsClient) DeletePrivateEndpointConnectionThenPoll(ctx context.Context, id PrivateEndpointConnectionId) error { - result, err := c.DeletePrivateEndpointConnection(ctx, id) - if err != nil { - return fmt.Errorf("performing DeletePrivateEndpointConnection: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after DeletePrivateEndpointConnection: %+v", err) - } - - return nil -} - -// preparerForDeletePrivateEndpointConnection prepares the DeletePrivateEndpointConnection request. -func (c WebAppsClient) preparerForDeletePrivateEndpointConnection(ctx context.Context, id PrivateEndpointConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDeletePrivateEndpointConnection sends the DeletePrivateEndpointConnection request. The method will close the -// http.Response Body if it receives an error. -func (c WebAppsClient) senderForDeletePrivateEndpointConnection(ctx context.Context, req *http.Request) (future DeletePrivateEndpointConnectionOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_deleteprivateendpointconnectionslot.go b/resource-manager/web/2022-09-01/webapps/method_deleteprivateendpointconnectionslot.go new file mode 100644 index 00000000000..ba52e002aa0 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_deleteprivateendpointconnectionslot.go @@ -0,0 +1,71 @@ +package webapps + +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 DeletePrivateEndpointConnectionSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// DeletePrivateEndpointConnectionSlot ... +func (c WebAppsClient) DeletePrivateEndpointConnectionSlot(ctx context.Context, id SlotPrivateEndpointConnectionId) (result DeletePrivateEndpointConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 +} + +// DeletePrivateEndpointConnectionSlotThenPoll performs DeletePrivateEndpointConnectionSlot then polls until it's completed +func (c WebAppsClient) DeletePrivateEndpointConnectionSlotThenPoll(ctx context.Context, id SlotPrivateEndpointConnectionId) error { + result, err := c.DeletePrivateEndpointConnectionSlot(ctx, id) + if err != nil { + return fmt.Errorf("performing DeletePrivateEndpointConnectionSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DeletePrivateEndpointConnectionSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/webapps/method_deleteprivateendpointconnectionslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_deleteprivateendpointconnectionslot_autorest.go deleted file mode 100644 index f3184c0ec7d..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_deleteprivateendpointconnectionslot_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeletePrivateEndpointConnectionSlotOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// DeletePrivateEndpointConnectionSlot ... -func (c WebAppsClient) DeletePrivateEndpointConnectionSlot(ctx context.Context, id SlotPrivateEndpointConnectionId) (result DeletePrivateEndpointConnectionSlotOperationResponse, err error) { - req, err := c.preparerForDeletePrivateEndpointConnectionSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeletePrivateEndpointConnectionSlot", nil, "Failure preparing request") - return - } - - result, err = c.senderForDeletePrivateEndpointConnectionSlot(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeletePrivateEndpointConnectionSlot", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// DeletePrivateEndpointConnectionSlotThenPoll performs DeletePrivateEndpointConnectionSlot then polls until it's completed -func (c WebAppsClient) DeletePrivateEndpointConnectionSlotThenPoll(ctx context.Context, id SlotPrivateEndpointConnectionId) error { - result, err := c.DeletePrivateEndpointConnectionSlot(ctx, id) - if err != nil { - return fmt.Errorf("performing DeletePrivateEndpointConnectionSlot: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after DeletePrivateEndpointConnectionSlot: %+v", err) - } - - return nil -} - -// preparerForDeletePrivateEndpointConnectionSlot prepares the DeletePrivateEndpointConnectionSlot request. -func (c WebAppsClient) preparerForDeletePrivateEndpointConnectionSlot(ctx context.Context, id SlotPrivateEndpointConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForDeletePrivateEndpointConnectionSlot sends the DeletePrivateEndpointConnectionSlot request. The method will close the -// http.Response Body if it receives an error. -func (c WebAppsClient) senderForDeletePrivateEndpointConnectionSlot(ctx context.Context, req *http.Request) (future DeletePrivateEndpointConnectionSlotOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_deleteprocess.go b/resource-manager/web/2022-09-01/webapps/method_deleteprocess.go new file mode 100644 index 00000000000..50b12dd321c --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_deleteprocess.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteProcessOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteProcess ... +func (c WebAppsClient) DeleteProcess(ctx context.Context, id ProcessId) (result DeleteProcessOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_deleteprocess_autorest.go b/resource-manager/web/2022-09-01/webapps/method_deleteprocess_autorest.go deleted file mode 100644 index f5f8543446c..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_deleteprocess_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteProcessOperationResponse struct { - HttpResponse *http.Response -} - -// DeleteProcess ... -func (c WebAppsClient) DeleteProcess(ctx context.Context, id ProcessId) (result DeleteProcessOperationResponse, err error) { - req, err := c.preparerForDeleteProcess(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteProcess", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteProcess", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeleteProcess(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteProcess", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeleteProcess prepares the DeleteProcess request. -func (c WebAppsClient) preparerForDeleteProcess(ctx context.Context, id ProcessId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeleteProcess handles the response to the DeleteProcess request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForDeleteProcess(resp *http.Response) (result DeleteProcessOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_deleteprocessslot.go b/resource-manager/web/2022-09-01/webapps/method_deleteprocessslot.go new file mode 100644 index 00000000000..6aba857b360 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_deleteprocessslot.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteProcessSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteProcessSlot ... +func (c WebAppsClient) DeleteProcessSlot(ctx context.Context, id SlotProcessId) (result DeleteProcessSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_deleteprocessslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_deleteprocessslot_autorest.go deleted file mode 100644 index 1436727d5a0..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_deleteprocessslot_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteProcessSlotOperationResponse struct { - HttpResponse *http.Response -} - -// DeleteProcessSlot ... -func (c WebAppsClient) DeleteProcessSlot(ctx context.Context, id SlotProcessId) (result DeleteProcessSlotOperationResponse, err error) { - req, err := c.preparerForDeleteProcessSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteProcessSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteProcessSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeleteProcessSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteProcessSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeleteProcessSlot prepares the DeleteProcessSlot request. -func (c WebAppsClient) preparerForDeleteProcessSlot(ctx context.Context, id SlotProcessId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeleteProcessSlot handles the response to the DeleteProcessSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForDeleteProcessSlot(resp *http.Response) (result DeleteProcessSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletepubliccertificate.go b/resource-manager/web/2022-09-01/webapps/method_deletepubliccertificate.go new file mode 100644 index 00000000000..7aca25586ab --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_deletepubliccertificate.go @@ -0,0 +1,47 @@ +package webapps + +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 DeletePublicCertificateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeletePublicCertificate ... +func (c WebAppsClient) DeletePublicCertificate(ctx context.Context, id PublicCertificateId) (result DeletePublicCertificateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletepubliccertificate_autorest.go b/resource-manager/web/2022-09-01/webapps/method_deletepubliccertificate_autorest.go deleted file mode 100644 index b9d651deeb3..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_deletepubliccertificate_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeletePublicCertificateOperationResponse struct { - HttpResponse *http.Response -} - -// DeletePublicCertificate ... -func (c WebAppsClient) DeletePublicCertificate(ctx context.Context, id PublicCertificateId) (result DeletePublicCertificateOperationResponse, err error) { - req, err := c.preparerForDeletePublicCertificate(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeletePublicCertificate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeletePublicCertificate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeletePublicCertificate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeletePublicCertificate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeletePublicCertificate prepares the DeletePublicCertificate request. -func (c WebAppsClient) preparerForDeletePublicCertificate(ctx context.Context, id PublicCertificateId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeletePublicCertificate handles the response to the DeletePublicCertificate request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForDeletePublicCertificate(resp *http.Response) (result DeletePublicCertificateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletepubliccertificateslot.go b/resource-manager/web/2022-09-01/webapps/method_deletepubliccertificateslot.go new file mode 100644 index 00000000000..6e1419d5e39 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_deletepubliccertificateslot.go @@ -0,0 +1,47 @@ +package webapps + +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 DeletePublicCertificateSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeletePublicCertificateSlot ... +func (c WebAppsClient) DeletePublicCertificateSlot(ctx context.Context, id SlotPublicCertificateId) (result DeletePublicCertificateSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletepubliccertificateslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_deletepubliccertificateslot_autorest.go deleted file mode 100644 index eb63a86cbf4..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_deletepubliccertificateslot_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeletePublicCertificateSlotOperationResponse struct { - HttpResponse *http.Response -} - -// DeletePublicCertificateSlot ... -func (c WebAppsClient) DeletePublicCertificateSlot(ctx context.Context, id SlotPublicCertificateId) (result DeletePublicCertificateSlotOperationResponse, err error) { - req, err := c.preparerForDeletePublicCertificateSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeletePublicCertificateSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeletePublicCertificateSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeletePublicCertificateSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeletePublicCertificateSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeletePublicCertificateSlot prepares the DeletePublicCertificateSlot request. -func (c WebAppsClient) preparerForDeletePublicCertificateSlot(ctx context.Context, id SlotPublicCertificateId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeletePublicCertificateSlot handles the response to the DeletePublicCertificateSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForDeletePublicCertificateSlot(resp *http.Response) (result DeletePublicCertificateSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_deleterelayserviceconnection.go b/resource-manager/web/2022-09-01/webapps/method_deleterelayserviceconnection.go new file mode 100644 index 00000000000..17cae919023 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_deleterelayserviceconnection.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteRelayServiceConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteRelayServiceConnection ... +func (c WebAppsClient) DeleteRelayServiceConnection(ctx context.Context, id HybridConnectionId) (result DeleteRelayServiceConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_deleterelayserviceconnection_autorest.go b/resource-manager/web/2022-09-01/webapps/method_deleterelayserviceconnection_autorest.go deleted file mode 100644 index cb1978bd91e..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_deleterelayserviceconnection_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteRelayServiceConnectionOperationResponse struct { - HttpResponse *http.Response -} - -// DeleteRelayServiceConnection ... -func (c WebAppsClient) DeleteRelayServiceConnection(ctx context.Context, id HybridConnectionId) (result DeleteRelayServiceConnectionOperationResponse, err error) { - req, err := c.preparerForDeleteRelayServiceConnection(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteRelayServiceConnection", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteRelayServiceConnection", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeleteRelayServiceConnection(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteRelayServiceConnection", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeleteRelayServiceConnection prepares the DeleteRelayServiceConnection request. -func (c WebAppsClient) preparerForDeleteRelayServiceConnection(ctx context.Context, id HybridConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeleteRelayServiceConnection handles the response to the DeleteRelayServiceConnection request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForDeleteRelayServiceConnection(resp *http.Response) (result DeleteRelayServiceConnectionOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_deleterelayserviceconnectionslot.go b/resource-manager/web/2022-09-01/webapps/method_deleterelayserviceconnectionslot.go new file mode 100644 index 00000000000..021b9af6535 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_deleterelayserviceconnectionslot.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteRelayServiceConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteRelayServiceConnectionSlot ... +func (c WebAppsClient) DeleteRelayServiceConnectionSlot(ctx context.Context, id SlotHybridConnectionId) (result DeleteRelayServiceConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_deleterelayserviceconnectionslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_deleterelayserviceconnectionslot_autorest.go deleted file mode 100644 index 787f867c640..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_deleterelayserviceconnectionslot_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteRelayServiceConnectionSlotOperationResponse struct { - HttpResponse *http.Response -} - -// DeleteRelayServiceConnectionSlot ... -func (c WebAppsClient) DeleteRelayServiceConnectionSlot(ctx context.Context, id SlotHybridConnectionId) (result DeleteRelayServiceConnectionSlotOperationResponse, err error) { - req, err := c.preparerForDeleteRelayServiceConnectionSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteRelayServiceConnectionSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteRelayServiceConnectionSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeleteRelayServiceConnectionSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteRelayServiceConnectionSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeleteRelayServiceConnectionSlot prepares the DeleteRelayServiceConnectionSlot request. -func (c WebAppsClient) preparerForDeleteRelayServiceConnectionSlot(ctx context.Context, id SlotHybridConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeleteRelayServiceConnectionSlot handles the response to the DeleteRelayServiceConnectionSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForDeleteRelayServiceConnectionSlot(resp *http.Response) (result DeleteRelayServiceConnectionSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletesiteextension.go b/resource-manager/web/2022-09-01/webapps/method_deletesiteextension.go new file mode 100644 index 00000000000..9494320cf78 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_deletesiteextension.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteSiteExtensionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteSiteExtension ... +func (c WebAppsClient) DeleteSiteExtension(ctx context.Context, id SiteExtensionId) (result DeleteSiteExtensionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletesiteextension_autorest.go b/resource-manager/web/2022-09-01/webapps/method_deletesiteextension_autorest.go deleted file mode 100644 index a6eded68fbf..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_deletesiteextension_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteSiteExtensionOperationResponse struct { - HttpResponse *http.Response -} - -// DeleteSiteExtension ... -func (c WebAppsClient) DeleteSiteExtension(ctx context.Context, id SiteExtensionId) (result DeleteSiteExtensionOperationResponse, err error) { - req, err := c.preparerForDeleteSiteExtension(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteSiteExtension", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteSiteExtension", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeleteSiteExtension(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteSiteExtension", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeleteSiteExtension prepares the DeleteSiteExtension request. -func (c WebAppsClient) preparerForDeleteSiteExtension(ctx context.Context, id SiteExtensionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeleteSiteExtension handles the response to the DeleteSiteExtension request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForDeleteSiteExtension(resp *http.Response) (result DeleteSiteExtensionOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletesiteextensionslot.go b/resource-manager/web/2022-09-01/webapps/method_deletesiteextensionslot.go new file mode 100644 index 00000000000..8d396afe7a0 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_deletesiteextensionslot.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteSiteExtensionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteSiteExtensionSlot ... +func (c WebAppsClient) DeleteSiteExtensionSlot(ctx context.Context, id SlotSiteExtensionId) (result DeleteSiteExtensionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletesiteextensionslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_deletesiteextensionslot_autorest.go deleted file mode 100644 index 3cac7b33433..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_deletesiteextensionslot_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteSiteExtensionSlotOperationResponse struct { - HttpResponse *http.Response -} - -// DeleteSiteExtensionSlot ... -func (c WebAppsClient) DeleteSiteExtensionSlot(ctx context.Context, id SlotSiteExtensionId) (result DeleteSiteExtensionSlotOperationResponse, err error) { - req, err := c.preparerForDeleteSiteExtensionSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteSiteExtensionSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteSiteExtensionSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeleteSiteExtensionSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteSiteExtensionSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeleteSiteExtensionSlot prepares the DeleteSiteExtensionSlot request. -func (c WebAppsClient) preparerForDeleteSiteExtensionSlot(ctx context.Context, id SlotSiteExtensionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeleteSiteExtensionSlot handles the response to the DeleteSiteExtensionSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForDeleteSiteExtensionSlot(resp *http.Response) (result DeleteSiteExtensionSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_deleteslot.go b/resource-manager/web/2022-09-01/webapps/method_deleteslot.go new file mode 100644 index 00000000000..84f82756ca4 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_deleteslot.go @@ -0,0 +1,80 @@ +package webapps + +import ( + "context" + "fmt" + "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 DeleteSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteSlotOperationOptions struct { + DeleteEmptyServerFarm *bool + DeleteMetrics *bool +} + +func DefaultDeleteSlotOperationOptions() DeleteSlotOperationOptions { + return DeleteSlotOperationOptions{} +} + +func (o DeleteSlotOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DeleteSlotOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteSlotOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.DeleteEmptyServerFarm != nil { + out.Append("deleteEmptyServerFarm", fmt.Sprintf("%v", *o.DeleteEmptyServerFarm)) + } + if o.DeleteMetrics != nil { + out.Append("deleteMetrics", fmt.Sprintf("%v", *o.DeleteMetrics)) + } + return &out +} + +// DeleteSlot ... +func (c WebAppsClient) DeleteSlot(ctx context.Context, id SlotId, options DeleteSlotOperationOptions) (result DeleteSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_deleteslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_deleteslot_autorest.go deleted file mode 100644 index 2a516d02076..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_deleteslot_autorest.go +++ /dev/null @@ -1,100 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteSlotOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteSlotOperationOptions struct { - DeleteEmptyServerFarm *bool - DeleteMetrics *bool -} - -func DefaultDeleteSlotOperationOptions() DeleteSlotOperationOptions { - return DeleteSlotOperationOptions{} -} - -func (o DeleteSlotOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o DeleteSlotOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.DeleteEmptyServerFarm != nil { - out["deleteEmptyServerFarm"] = *o.DeleteEmptyServerFarm - } - - if o.DeleteMetrics != nil { - out["deleteMetrics"] = *o.DeleteMetrics - } - - return out -} - -// DeleteSlot ... -func (c WebAppsClient) DeleteSlot(ctx context.Context, id SlotId, options DeleteSlotOperationOptions) (result DeleteSlotOperationResponse, err error) { - req, err := c.preparerForDeleteSlot(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeleteSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeleteSlot prepares the DeleteSlot request. -func (c WebAppsClient) preparerForDeleteSlot(ctx context.Context, id SlotId, options DeleteSlotOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeleteSlot handles the response to the DeleteSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForDeleteSlot(resp *http.Response) (result DeleteSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletesourcecontrol.go b/resource-manager/web/2022-09-01/webapps/method_deletesourcecontrol.go new file mode 100644 index 00000000000..52182b42c08 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_deletesourcecontrol.go @@ -0,0 +1,76 @@ +package webapps + +import ( + "context" + "fmt" + "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 DeleteSourceControlOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteSourceControlOperationOptions struct { + AdditionalFlags *string +} + +func DefaultDeleteSourceControlOperationOptions() DeleteSourceControlOperationOptions { + return DeleteSourceControlOperationOptions{} +} + +func (o DeleteSourceControlOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DeleteSourceControlOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteSourceControlOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.AdditionalFlags != nil { + out.Append("additionalFlags", fmt.Sprintf("%v", *o.AdditionalFlags)) + } + return &out +} + +// DeleteSourceControl ... +func (c WebAppsClient) DeleteSourceControl(ctx context.Context, id SiteId, options DeleteSourceControlOperationOptions) (result DeleteSourceControlOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: fmt.Sprintf("%s/sourceControls/web", id.ID()), + OptionsObject: options, + } + + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletesourcecontrol_autorest.go b/resource-manager/web/2022-09-01/webapps/method_deletesourcecontrol_autorest.go deleted file mode 100644 index 3fbe4d6a984..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_deletesourcecontrol_autorest.go +++ /dev/null @@ -1,96 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteSourceControlOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteSourceControlOperationOptions struct { - AdditionalFlags *string -} - -func DefaultDeleteSourceControlOperationOptions() DeleteSourceControlOperationOptions { - return DeleteSourceControlOperationOptions{} -} - -func (o DeleteSourceControlOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o DeleteSourceControlOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.AdditionalFlags != nil { - out["additionalFlags"] = *o.AdditionalFlags - } - - return out -} - -// DeleteSourceControl ... -func (c WebAppsClient) DeleteSourceControl(ctx context.Context, id SiteId, options DeleteSourceControlOperationOptions) (result DeleteSourceControlOperationResponse, err error) { - req, err := c.preparerForDeleteSourceControl(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteSourceControl", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteSourceControl", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeleteSourceControl(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteSourceControl", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeleteSourceControl prepares the DeleteSourceControl request. -func (c WebAppsClient) preparerForDeleteSourceControl(ctx context.Context, id SiteId, options DeleteSourceControlOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/sourceControls/web", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeleteSourceControl handles the response to the DeleteSourceControl request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForDeleteSourceControl(resp *http.Response) (result DeleteSourceControlOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletesourcecontrolslot.go b/resource-manager/web/2022-09-01/webapps/method_deletesourcecontrolslot.go new file mode 100644 index 00000000000..8cfdd195a90 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_deletesourcecontrolslot.go @@ -0,0 +1,76 @@ +package webapps + +import ( + "context" + "fmt" + "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 DeleteSourceControlSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteSourceControlSlotOperationOptions struct { + AdditionalFlags *string +} + +func DefaultDeleteSourceControlSlotOperationOptions() DeleteSourceControlSlotOperationOptions { + return DeleteSourceControlSlotOperationOptions{} +} + +func (o DeleteSourceControlSlotOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DeleteSourceControlSlotOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteSourceControlSlotOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.AdditionalFlags != nil { + out.Append("additionalFlags", fmt.Sprintf("%v", *o.AdditionalFlags)) + } + return &out +} + +// DeleteSourceControlSlot ... +func (c WebAppsClient) DeleteSourceControlSlot(ctx context.Context, id SlotId, options DeleteSourceControlSlotOperationOptions) (result DeleteSourceControlSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: fmt.Sprintf("%s/sourceControls/web", id.ID()), + OptionsObject: options, + } + + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletesourcecontrolslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_deletesourcecontrolslot_autorest.go deleted file mode 100644 index 5a7b8bea70d..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_deletesourcecontrolslot_autorest.go +++ /dev/null @@ -1,96 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteSourceControlSlotOperationResponse struct { - HttpResponse *http.Response -} - -type DeleteSourceControlSlotOperationOptions struct { - AdditionalFlags *string -} - -func DefaultDeleteSourceControlSlotOperationOptions() DeleteSourceControlSlotOperationOptions { - return DeleteSourceControlSlotOperationOptions{} -} - -func (o DeleteSourceControlSlotOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o DeleteSourceControlSlotOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.AdditionalFlags != nil { - out["additionalFlags"] = *o.AdditionalFlags - } - - return out -} - -// DeleteSourceControlSlot ... -func (c WebAppsClient) DeleteSourceControlSlot(ctx context.Context, id SlotId, options DeleteSourceControlSlotOperationOptions) (result DeleteSourceControlSlotOperationResponse, err error) { - req, err := c.preparerForDeleteSourceControlSlot(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteSourceControlSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteSourceControlSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeleteSourceControlSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteSourceControlSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeleteSourceControlSlot prepares the DeleteSourceControlSlot request. -func (c WebAppsClient) preparerForDeleteSourceControlSlot(ctx context.Context, id SlotId, options DeleteSourceControlSlotOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/sourceControls/web", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeleteSourceControlSlot handles the response to the DeleteSourceControlSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForDeleteSourceControlSlot(resp *http.Response) (result DeleteSourceControlSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_deleteswiftvirtualnetwork.go b/resource-manager/web/2022-09-01/webapps/method_deleteswiftvirtualnetwork.go new file mode 100644 index 00000000000..1192f0309e8 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_deleteswiftvirtualnetwork.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "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 DeleteSwiftVirtualNetworkOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteSwiftVirtualNetwork ... +func (c WebAppsClient) DeleteSwiftVirtualNetwork(ctx context.Context, id SiteId) (result DeleteSwiftVirtualNetworkOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: fmt.Sprintf("%s/networkConfig/virtualNetwork", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_deleteswiftvirtualnetwork_autorest.go b/resource-manager/web/2022-09-01/webapps/method_deleteswiftvirtualnetwork_autorest.go deleted file mode 100644 index 966665ee2e4..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_deleteswiftvirtualnetwork_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteSwiftVirtualNetworkOperationResponse struct { - HttpResponse *http.Response -} - -// DeleteSwiftVirtualNetwork ... -func (c WebAppsClient) DeleteSwiftVirtualNetwork(ctx context.Context, id SiteId) (result DeleteSwiftVirtualNetworkOperationResponse, err error) { - req, err := c.preparerForDeleteSwiftVirtualNetwork(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteSwiftVirtualNetwork", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteSwiftVirtualNetwork", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeleteSwiftVirtualNetwork(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteSwiftVirtualNetwork", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeleteSwiftVirtualNetwork prepares the DeleteSwiftVirtualNetwork request. -func (c WebAppsClient) preparerForDeleteSwiftVirtualNetwork(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/networkConfig/virtualNetwork", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeleteSwiftVirtualNetwork handles the response to the DeleteSwiftVirtualNetwork request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForDeleteSwiftVirtualNetwork(resp *http.Response) (result DeleteSwiftVirtualNetworkOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_deleteswiftvirtualnetworkslot.go b/resource-manager/web/2022-09-01/webapps/method_deleteswiftvirtualnetworkslot.go new file mode 100644 index 00000000000..2414bf9d13c --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_deleteswiftvirtualnetworkslot.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "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 DeleteSwiftVirtualNetworkSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteSwiftVirtualNetworkSlot ... +func (c WebAppsClient) DeleteSwiftVirtualNetworkSlot(ctx context.Context, id SlotId) (result DeleteSwiftVirtualNetworkSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: fmt.Sprintf("%s/networkConfig/virtualNetwork", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_deleteswiftvirtualnetworkslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_deleteswiftvirtualnetworkslot_autorest.go deleted file mode 100644 index f625ed27f66..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_deleteswiftvirtualnetworkslot_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteSwiftVirtualNetworkSlotOperationResponse struct { - HttpResponse *http.Response -} - -// DeleteSwiftVirtualNetworkSlot ... -func (c WebAppsClient) DeleteSwiftVirtualNetworkSlot(ctx context.Context, id SlotId) (result DeleteSwiftVirtualNetworkSlotOperationResponse, err error) { - req, err := c.preparerForDeleteSwiftVirtualNetworkSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteSwiftVirtualNetworkSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteSwiftVirtualNetworkSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeleteSwiftVirtualNetworkSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteSwiftVirtualNetworkSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeleteSwiftVirtualNetworkSlot prepares the DeleteSwiftVirtualNetworkSlot request. -func (c WebAppsClient) preparerForDeleteSwiftVirtualNetworkSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/networkConfig/virtualNetwork", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeleteSwiftVirtualNetworkSlot handles the response to the DeleteSwiftVirtualNetworkSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForDeleteSwiftVirtualNetworkSlot(resp *http.Response) (result DeleteSwiftVirtualNetworkSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletetriggeredwebjob.go b/resource-manager/web/2022-09-01/webapps/method_deletetriggeredwebjob.go new file mode 100644 index 00000000000..6dfb40eb5d5 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_deletetriggeredwebjob.go @@ -0,0 +1,47 @@ +package webapps + +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 DeleteTriggeredWebJobOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteTriggeredWebJob ... +func (c WebAppsClient) DeleteTriggeredWebJob(ctx context.Context, id TriggeredWebJobId) (result DeleteTriggeredWebJobOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletetriggeredwebjob_autorest.go b/resource-manager/web/2022-09-01/webapps/method_deletetriggeredwebjob_autorest.go deleted file mode 100644 index bc384f501c0..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_deletetriggeredwebjob_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteTriggeredWebJobOperationResponse struct { - HttpResponse *http.Response -} - -// DeleteTriggeredWebJob ... -func (c WebAppsClient) DeleteTriggeredWebJob(ctx context.Context, id TriggeredWebJobId) (result DeleteTriggeredWebJobOperationResponse, err error) { - req, err := c.preparerForDeleteTriggeredWebJob(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteTriggeredWebJob", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteTriggeredWebJob", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeleteTriggeredWebJob(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteTriggeredWebJob", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeleteTriggeredWebJob prepares the DeleteTriggeredWebJob request. -func (c WebAppsClient) preparerForDeleteTriggeredWebJob(ctx context.Context, id TriggeredWebJobId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeleteTriggeredWebJob handles the response to the DeleteTriggeredWebJob request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForDeleteTriggeredWebJob(resp *http.Response) (result DeleteTriggeredWebJobOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletetriggeredwebjobslot.go b/resource-manager/web/2022-09-01/webapps/method_deletetriggeredwebjobslot.go new file mode 100644 index 00000000000..f71454b9c84 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_deletetriggeredwebjobslot.go @@ -0,0 +1,47 @@ +package webapps + +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 DeleteTriggeredWebJobSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteTriggeredWebJobSlot ... +func (c WebAppsClient) DeleteTriggeredWebJobSlot(ctx context.Context, id SlotTriggeredWebJobId) (result DeleteTriggeredWebJobSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletetriggeredwebjobslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_deletetriggeredwebjobslot_autorest.go deleted file mode 100644 index 388008ddc05..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_deletetriggeredwebjobslot_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteTriggeredWebJobSlotOperationResponse struct { - HttpResponse *http.Response -} - -// DeleteTriggeredWebJobSlot ... -func (c WebAppsClient) DeleteTriggeredWebJobSlot(ctx context.Context, id SlotTriggeredWebJobId) (result DeleteTriggeredWebJobSlotOperationResponse, err error) { - req, err := c.preparerForDeleteTriggeredWebJobSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteTriggeredWebJobSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteTriggeredWebJobSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeleteTriggeredWebJobSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteTriggeredWebJobSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeleteTriggeredWebJobSlot prepares the DeleteTriggeredWebJobSlot request. -func (c WebAppsClient) preparerForDeleteTriggeredWebJobSlot(ctx context.Context, id SlotTriggeredWebJobId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeleteTriggeredWebJobSlot handles the response to the DeleteTriggeredWebJobSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForDeleteTriggeredWebJobSlot(resp *http.Response) (result DeleteTriggeredWebJobSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletevnetconnection.go b/resource-manager/web/2022-09-01/webapps/method_deletevnetconnection.go new file mode 100644 index 00000000000..512fa88d99e --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_deletevnetconnection.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteVnetConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteVnetConnection ... +func (c WebAppsClient) DeleteVnetConnection(ctx context.Context, id VirtualNetworkConnectionId) (result DeleteVnetConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletevnetconnection_autorest.go b/resource-manager/web/2022-09-01/webapps/method_deletevnetconnection_autorest.go deleted file mode 100644 index d73d2b79047..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_deletevnetconnection_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteVnetConnectionOperationResponse struct { - HttpResponse *http.Response -} - -// DeleteVnetConnection ... -func (c WebAppsClient) DeleteVnetConnection(ctx context.Context, id VirtualNetworkConnectionId) (result DeleteVnetConnectionOperationResponse, err error) { - req, err := c.preparerForDeleteVnetConnection(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteVnetConnection", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteVnetConnection", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeleteVnetConnection(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteVnetConnection", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeleteVnetConnection prepares the DeleteVnetConnection request. -func (c WebAppsClient) preparerForDeleteVnetConnection(ctx context.Context, id VirtualNetworkConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeleteVnetConnection handles the response to the DeleteVnetConnection request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForDeleteVnetConnection(resp *http.Response) (result DeleteVnetConnectionOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletevnetconnectionslot.go b/resource-manager/web/2022-09-01/webapps/method_deletevnetconnectionslot.go new file mode 100644 index 00000000000..a631c2066c9 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_deletevnetconnectionslot.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteVnetConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteVnetConnectionSlot ... +func (c WebAppsClient) DeleteVnetConnectionSlot(ctx context.Context, id SlotVirtualNetworkConnectionId) (result DeleteVnetConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_deletevnetconnectionslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_deletevnetconnectionslot_autorest.go deleted file mode 100644 index b65e0acf2e1..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_deletevnetconnectionslot_autorest.go +++ /dev/null @@ -1,66 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeleteVnetConnectionSlotOperationResponse struct { - HttpResponse *http.Response -} - -// DeleteVnetConnectionSlot ... -func (c WebAppsClient) DeleteVnetConnectionSlot(ctx context.Context, id SlotVirtualNetworkConnectionId) (result DeleteVnetConnectionSlotOperationResponse, err error) { - req, err := c.preparerForDeleteVnetConnectionSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteVnetConnectionSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteVnetConnectionSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeleteVnetConnectionSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeleteVnetConnectionSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeleteVnetConnectionSlot prepares the DeleteVnetConnectionSlot request. -func (c WebAppsClient) preparerForDeleteVnetConnectionSlot(ctx context.Context, id SlotVirtualNetworkConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeleteVnetConnectionSlot handles the response to the DeleteVnetConnectionSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForDeleteVnetConnectionSlot(resp *http.Response) (result DeleteVnetConnectionSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_deployworkflowartifacts.go b/resource-manager/web/2022-09-01/webapps/method_deployworkflowartifacts.go new file mode 100644 index 00000000000..377f36fbc17 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_deployworkflowartifacts.go @@ -0,0 +1,51 @@ +package webapps + +import ( + "context" + "fmt" + "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 DeployWorkflowArtifactsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeployWorkflowArtifacts ... +func (c WebAppsClient) DeployWorkflowArtifacts(ctx context.Context, id SiteId, input WorkflowArtifacts) (result DeployWorkflowArtifactsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/deployWorkflowArtifacts", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_deployworkflowartifacts_autorest.go b/resource-manager/web/2022-09-01/webapps/method_deployworkflowartifacts_autorest.go deleted file mode 100644 index 08b88fb7568..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_deployworkflowartifacts_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeployWorkflowArtifactsOperationResponse struct { - HttpResponse *http.Response -} - -// DeployWorkflowArtifacts ... -func (c WebAppsClient) DeployWorkflowArtifacts(ctx context.Context, id SiteId, input WorkflowArtifacts) (result DeployWorkflowArtifactsOperationResponse, err error) { - req, err := c.preparerForDeployWorkflowArtifacts(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeployWorkflowArtifacts", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeployWorkflowArtifacts", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeployWorkflowArtifacts(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeployWorkflowArtifacts", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeployWorkflowArtifacts prepares the DeployWorkflowArtifacts request. -func (c WebAppsClient) preparerForDeployWorkflowArtifacts(ctx context.Context, id SiteId, input WorkflowArtifacts) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/deployWorkflowArtifacts", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeployWorkflowArtifacts handles the response to the DeployWorkflowArtifacts request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForDeployWorkflowArtifacts(resp *http.Response) (result DeployWorkflowArtifactsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_deployworkflowartifactsslot.go b/resource-manager/web/2022-09-01/webapps/method_deployworkflowartifactsslot.go new file mode 100644 index 00000000000..d8b65f59e74 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_deployworkflowartifactsslot.go @@ -0,0 +1,51 @@ +package webapps + +import ( + "context" + "fmt" + "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 DeployWorkflowArtifactsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeployWorkflowArtifactsSlot ... +func (c WebAppsClient) DeployWorkflowArtifactsSlot(ctx context.Context, id SlotId, input WorkflowArtifacts) (result DeployWorkflowArtifactsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/deployWorkflowArtifacts", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_deployworkflowartifactsslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_deployworkflowartifactsslot_autorest.go deleted file mode 100644 index 816baf2b5f1..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_deployworkflowartifactsslot_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DeployWorkflowArtifactsSlotOperationResponse struct { - HttpResponse *http.Response -} - -// DeployWorkflowArtifactsSlot ... -func (c WebAppsClient) DeployWorkflowArtifactsSlot(ctx context.Context, id SlotId, input WorkflowArtifacts) (result DeployWorkflowArtifactsSlotOperationResponse, err error) { - req, err := c.preparerForDeployWorkflowArtifactsSlot(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeployWorkflowArtifactsSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeployWorkflowArtifactsSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDeployWorkflowArtifactsSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DeployWorkflowArtifactsSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDeployWorkflowArtifactsSlot prepares the DeployWorkflowArtifactsSlot request. -func (c WebAppsClient) preparerForDeployWorkflowArtifactsSlot(ctx context.Context, id SlotId, input WorkflowArtifacts) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/deployWorkflowArtifacts", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDeployWorkflowArtifactsSlot handles the response to the DeployWorkflowArtifactsSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForDeployWorkflowArtifactsSlot(resp *http.Response) (result DeployWorkflowArtifactsSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_discoverbackup.go b/resource-manager/web/2022-09-01/webapps/method_discoverbackup.go new file mode 100644 index 00000000000..81c417165e6 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_discoverbackup.go @@ -0,0 +1,56 @@ +package webapps + +import ( + "context" + "fmt" + "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 DiscoverBackupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RestoreRequest +} + +// DiscoverBackup ... +func (c WebAppsClient) DiscoverBackup(ctx context.Context, id SiteId, input RestoreRequest) (result DiscoverBackupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/discoverbackup", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_discoverbackup_autorest.go b/resource-manager/web/2022-09-01/webapps/method_discoverbackup_autorest.go deleted file mode 100644 index 2ec5617c0da..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_discoverbackup_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DiscoverBackupOperationResponse struct { - HttpResponse *http.Response - Model *RestoreRequest -} - -// DiscoverBackup ... -func (c WebAppsClient) DiscoverBackup(ctx context.Context, id SiteId, input RestoreRequest) (result DiscoverBackupOperationResponse, err error) { - req, err := c.preparerForDiscoverBackup(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DiscoverBackup", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DiscoverBackup", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDiscoverBackup(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DiscoverBackup", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDiscoverBackup prepares the DiscoverBackup request. -func (c WebAppsClient) preparerForDiscoverBackup(ctx context.Context, id SiteId, input RestoreRequest) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/discoverbackup", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDiscoverBackup handles the response to the DiscoverBackup request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForDiscoverBackup(resp *http.Response) (result DiscoverBackupOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_discoverbackupslot.go b/resource-manager/web/2022-09-01/webapps/method_discoverbackupslot.go new file mode 100644 index 00000000000..b31700dbbb9 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_discoverbackupslot.go @@ -0,0 +1,56 @@ +package webapps + +import ( + "context" + "fmt" + "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 DiscoverBackupSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RestoreRequest +} + +// DiscoverBackupSlot ... +func (c WebAppsClient) DiscoverBackupSlot(ctx context.Context, id SlotId, input RestoreRequest) (result DiscoverBackupSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/discoverbackup", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_discoverbackupslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_discoverbackupslot_autorest.go deleted file mode 100644 index 7372a9075d3..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_discoverbackupslot_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type DiscoverBackupSlotOperationResponse struct { - HttpResponse *http.Response - Model *RestoreRequest -} - -// DiscoverBackupSlot ... -func (c WebAppsClient) DiscoverBackupSlot(ctx context.Context, id SlotId, input RestoreRequest) (result DiscoverBackupSlotOperationResponse, err error) { - req, err := c.preparerForDiscoverBackupSlot(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DiscoverBackupSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DiscoverBackupSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForDiscoverBackupSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "DiscoverBackupSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForDiscoverBackupSlot prepares the DiscoverBackupSlot request. -func (c WebAppsClient) preparerForDiscoverBackupSlot(ctx context.Context, id SlotId, input RestoreRequest) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/discoverbackup", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForDiscoverBackupSlot handles the response to the DiscoverBackupSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForDiscoverBackupSlot(resp *http.Response) (result DiscoverBackupSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_generatenewsitepublishingpassword.go b/resource-manager/web/2022-09-01/webapps/method_generatenewsitepublishingpassword.go new file mode 100644 index 00000000000..4e1e3a77977 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_generatenewsitepublishingpassword.go @@ -0,0 +1,48 @@ +package webapps + +import ( + "context" + "fmt" + "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 GenerateNewSitePublishingPasswordOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GenerateNewSitePublishingPassword ... +func (c WebAppsClient) GenerateNewSitePublishingPassword(ctx context.Context, id SiteId) (result GenerateNewSitePublishingPasswordOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/newpassword", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_generatenewsitepublishingpassword_autorest.go b/resource-manager/web/2022-09-01/webapps/method_generatenewsitepublishingpassword_autorest.go deleted file mode 100644 index bb24b2c3a6a..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_generatenewsitepublishingpassword_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GenerateNewSitePublishingPasswordOperationResponse struct { - HttpResponse *http.Response -} - -// GenerateNewSitePublishingPassword ... -func (c WebAppsClient) GenerateNewSitePublishingPassword(ctx context.Context, id SiteId) (result GenerateNewSitePublishingPasswordOperationResponse, err error) { - req, err := c.preparerForGenerateNewSitePublishingPassword(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GenerateNewSitePublishingPassword", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GenerateNewSitePublishingPassword", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGenerateNewSitePublishingPassword(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GenerateNewSitePublishingPassword", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGenerateNewSitePublishingPassword prepares the GenerateNewSitePublishingPassword request. -func (c WebAppsClient) preparerForGenerateNewSitePublishingPassword(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/newpassword", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGenerateNewSitePublishingPassword handles the response to the GenerateNewSitePublishingPassword request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGenerateNewSitePublishingPassword(resp *http.Response) (result GenerateNewSitePublishingPasswordOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_generatenewsitepublishingpasswordslot.go b/resource-manager/web/2022-09-01/webapps/method_generatenewsitepublishingpasswordslot.go new file mode 100644 index 00000000000..27ad4db3a05 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_generatenewsitepublishingpasswordslot.go @@ -0,0 +1,48 @@ +package webapps + +import ( + "context" + "fmt" + "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 GenerateNewSitePublishingPasswordSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GenerateNewSitePublishingPasswordSlot ... +func (c WebAppsClient) GenerateNewSitePublishingPasswordSlot(ctx context.Context, id SlotId) (result GenerateNewSitePublishingPasswordSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/newpassword", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_generatenewsitepublishingpasswordslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_generatenewsitepublishingpasswordslot_autorest.go deleted file mode 100644 index 23069f39b3f..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_generatenewsitepublishingpasswordslot_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GenerateNewSitePublishingPasswordSlotOperationResponse struct { - HttpResponse *http.Response -} - -// GenerateNewSitePublishingPasswordSlot ... -func (c WebAppsClient) GenerateNewSitePublishingPasswordSlot(ctx context.Context, id SlotId) (result GenerateNewSitePublishingPasswordSlotOperationResponse, err error) { - req, err := c.preparerForGenerateNewSitePublishingPasswordSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GenerateNewSitePublishingPasswordSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GenerateNewSitePublishingPasswordSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGenerateNewSitePublishingPasswordSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GenerateNewSitePublishingPasswordSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGenerateNewSitePublishingPasswordSlot prepares the GenerateNewSitePublishingPasswordSlot request. -func (c WebAppsClient) preparerForGenerateNewSitePublishingPasswordSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/newpassword", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGenerateNewSitePublishingPasswordSlot handles the response to the GenerateNewSitePublishingPasswordSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGenerateNewSitePublishingPasswordSlot(resp *http.Response) (result GenerateNewSitePublishingPasswordSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_get.go b/resource-manager/web/2022-09-01/webapps/method_get.go new file mode 100644 index 00000000000..63b559bbca3 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_get.go @@ -0,0 +1,51 @@ +package webapps + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Site +} + +// Get ... +func (c WebAppsClient) Get(ctx context.Context, id SiteId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_get_autorest.go b/resource-manager/web/2022-09-01/webapps/method_get_autorest.go deleted file mode 100644 index 6f57f2e90ae..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *Site -} - -// Get ... -func (c WebAppsClient) Get(ctx context.Context, id SiteId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c WebAppsClient) preparerForGet(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getappsettingkeyvaultreference.go b/resource-manager/web/2022-09-01/webapps/method_getappsettingkeyvaultreference.go new file mode 100644 index 00000000000..261006608b6 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getappsettingkeyvaultreference.go @@ -0,0 +1,51 @@ +package webapps + +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 GetAppSettingKeyVaultReferenceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApiKVReference +} + +// GetAppSettingKeyVaultReference ... +func (c WebAppsClient) GetAppSettingKeyVaultReference(ctx context.Context, id AppSettingId) (result GetAppSettingKeyVaultReferenceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getappsettingkeyvaultreference_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getappsettingkeyvaultreference_autorest.go deleted file mode 100644 index 781af78ced9..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getappsettingkeyvaultreference_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetAppSettingKeyVaultReferenceOperationResponse struct { - HttpResponse *http.Response - Model *ApiKVReference -} - -// GetAppSettingKeyVaultReference ... -func (c WebAppsClient) GetAppSettingKeyVaultReference(ctx context.Context, id AppSettingId) (result GetAppSettingKeyVaultReferenceOperationResponse, err error) { - req, err := c.preparerForGetAppSettingKeyVaultReference(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetAppSettingKeyVaultReference", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetAppSettingKeyVaultReference", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetAppSettingKeyVaultReference(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetAppSettingKeyVaultReference", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetAppSettingKeyVaultReference prepares the GetAppSettingKeyVaultReference request. -func (c WebAppsClient) preparerForGetAppSettingKeyVaultReference(ctx context.Context, id AppSettingId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetAppSettingKeyVaultReference handles the response to the GetAppSettingKeyVaultReference request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetAppSettingKeyVaultReference(resp *http.Response) (result GetAppSettingKeyVaultReferenceOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getappsettingkeyvaultreferenceslot.go b/resource-manager/web/2022-09-01/webapps/method_getappsettingkeyvaultreferenceslot.go new file mode 100644 index 00000000000..5cc87ee8f3c --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getappsettingkeyvaultreferenceslot.go @@ -0,0 +1,51 @@ +package webapps + +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 GetAppSettingKeyVaultReferenceSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApiKVReference +} + +// GetAppSettingKeyVaultReferenceSlot ... +func (c WebAppsClient) GetAppSettingKeyVaultReferenceSlot(ctx context.Context, id ConfigReferenceAppSettingId) (result GetAppSettingKeyVaultReferenceSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getappsettingkeyvaultreferenceslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getappsettingkeyvaultreferenceslot_autorest.go deleted file mode 100644 index a1a6f01eb09..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getappsettingkeyvaultreferenceslot_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetAppSettingKeyVaultReferenceSlotOperationResponse struct { - HttpResponse *http.Response - Model *ApiKVReference -} - -// GetAppSettingKeyVaultReferenceSlot ... -func (c WebAppsClient) GetAppSettingKeyVaultReferenceSlot(ctx context.Context, id ConfigReferenceAppSettingId) (result GetAppSettingKeyVaultReferenceSlotOperationResponse, err error) { - req, err := c.preparerForGetAppSettingKeyVaultReferenceSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetAppSettingKeyVaultReferenceSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetAppSettingKeyVaultReferenceSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetAppSettingKeyVaultReferenceSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetAppSettingKeyVaultReferenceSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetAppSettingKeyVaultReferenceSlot prepares the GetAppSettingKeyVaultReferenceSlot request. -func (c WebAppsClient) preparerForGetAppSettingKeyVaultReferenceSlot(ctx context.Context, id ConfigReferenceAppSettingId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetAppSettingKeyVaultReferenceSlot handles the response to the GetAppSettingKeyVaultReferenceSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetAppSettingKeyVaultReferenceSlot(resp *http.Response) (result GetAppSettingKeyVaultReferenceSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getappsettingskeyvaultreferences.go b/resource-manager/web/2022-09-01/webapps/method_getappsettingskeyvaultreferences.go new file mode 100644 index 00000000000..e5b5f81c4f7 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getappsettingskeyvaultreferences.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetAppSettingsKeyVaultReferencesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ApiKVReference +} + +type GetAppSettingsKeyVaultReferencesCompleteResult struct { + Items []ApiKVReference +} + +// GetAppSettingsKeyVaultReferences ... +func (c WebAppsClient) GetAppSettingsKeyVaultReferences(ctx context.Context, id SiteId) (result GetAppSettingsKeyVaultReferencesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/config/configReferences/appSettings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ApiKVReference `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetAppSettingsKeyVaultReferencesComplete retrieves all the results into a single object +func (c WebAppsClient) GetAppSettingsKeyVaultReferencesComplete(ctx context.Context, id SiteId) (GetAppSettingsKeyVaultReferencesCompleteResult, error) { + return c.GetAppSettingsKeyVaultReferencesCompleteMatchingPredicate(ctx, id, ApiKVReferenceOperationPredicate{}) +} + +// GetAppSettingsKeyVaultReferencesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) GetAppSettingsKeyVaultReferencesCompleteMatchingPredicate(ctx context.Context, id SiteId, predicate ApiKVReferenceOperationPredicate) (result GetAppSettingsKeyVaultReferencesCompleteResult, err error) { + items := make([]ApiKVReference, 0) + + resp, err := c.GetAppSettingsKeyVaultReferences(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetAppSettingsKeyVaultReferencesCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getappsettingskeyvaultreferences_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getappsettingskeyvaultreferences_autorest.go deleted file mode 100644 index 2b25dfd1ede..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getappsettingskeyvaultreferences_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetAppSettingsKeyVaultReferencesOperationResponse struct { - HttpResponse *http.Response - Model *[]ApiKVReference - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (GetAppSettingsKeyVaultReferencesOperationResponse, error) -} - -type GetAppSettingsKeyVaultReferencesCompleteResult struct { - Items []ApiKVReference -} - -func (r GetAppSettingsKeyVaultReferencesOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r GetAppSettingsKeyVaultReferencesOperationResponse) LoadMore(ctx context.Context) (resp GetAppSettingsKeyVaultReferencesOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// GetAppSettingsKeyVaultReferences ... -func (c WebAppsClient) GetAppSettingsKeyVaultReferences(ctx context.Context, id SiteId) (resp GetAppSettingsKeyVaultReferencesOperationResponse, err error) { - req, err := c.preparerForGetAppSettingsKeyVaultReferences(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetAppSettingsKeyVaultReferences", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetAppSettingsKeyVaultReferences", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForGetAppSettingsKeyVaultReferences(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetAppSettingsKeyVaultReferences", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForGetAppSettingsKeyVaultReferences prepares the GetAppSettingsKeyVaultReferences request. -func (c WebAppsClient) preparerForGetAppSettingsKeyVaultReferences(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/configReferences/appSettings", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForGetAppSettingsKeyVaultReferencesWithNextLink prepares the GetAppSettingsKeyVaultReferences request with the given nextLink token. -func (c WebAppsClient) preparerForGetAppSettingsKeyVaultReferencesWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetAppSettingsKeyVaultReferences handles the response to the GetAppSettingsKeyVaultReferences request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetAppSettingsKeyVaultReferences(resp *http.Response) (result GetAppSettingsKeyVaultReferencesOperationResponse, err error) { - type page struct { - Values []ApiKVReference `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result GetAppSettingsKeyVaultReferencesOperationResponse, err error) { - req, err := c.preparerForGetAppSettingsKeyVaultReferencesWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetAppSettingsKeyVaultReferences", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetAppSettingsKeyVaultReferences", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetAppSettingsKeyVaultReferences(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetAppSettingsKeyVaultReferences", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// GetAppSettingsKeyVaultReferencesComplete retrieves all of the results into a single object -func (c WebAppsClient) GetAppSettingsKeyVaultReferencesComplete(ctx context.Context, id SiteId) (GetAppSettingsKeyVaultReferencesCompleteResult, error) { - return c.GetAppSettingsKeyVaultReferencesCompleteMatchingPredicate(ctx, id, ApiKVReferenceOperationPredicate{}) -} - -// GetAppSettingsKeyVaultReferencesCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) GetAppSettingsKeyVaultReferencesCompleteMatchingPredicate(ctx context.Context, id SiteId, predicate ApiKVReferenceOperationPredicate) (resp GetAppSettingsKeyVaultReferencesCompleteResult, err error) { - items := make([]ApiKVReference, 0) - - page, err := c.GetAppSettingsKeyVaultReferences(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := GetAppSettingsKeyVaultReferencesCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getappsettingskeyvaultreferencesslot.go b/resource-manager/web/2022-09-01/webapps/method_getappsettingskeyvaultreferencesslot.go new file mode 100644 index 00000000000..fd2fec1e333 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getappsettingskeyvaultreferencesslot.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetAppSettingsKeyVaultReferencesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ApiKVReference +} + +type GetAppSettingsKeyVaultReferencesSlotCompleteResult struct { + Items []ApiKVReference +} + +// GetAppSettingsKeyVaultReferencesSlot ... +func (c WebAppsClient) GetAppSettingsKeyVaultReferencesSlot(ctx context.Context, id SlotId) (result GetAppSettingsKeyVaultReferencesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/config/configReferences/appSettings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ApiKVReference `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetAppSettingsKeyVaultReferencesSlotComplete retrieves all the results into a single object +func (c WebAppsClient) GetAppSettingsKeyVaultReferencesSlotComplete(ctx context.Context, id SlotId) (GetAppSettingsKeyVaultReferencesSlotCompleteResult, error) { + return c.GetAppSettingsKeyVaultReferencesSlotCompleteMatchingPredicate(ctx, id, ApiKVReferenceOperationPredicate{}) +} + +// GetAppSettingsKeyVaultReferencesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) GetAppSettingsKeyVaultReferencesSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate ApiKVReferenceOperationPredicate) (result GetAppSettingsKeyVaultReferencesSlotCompleteResult, err error) { + items := make([]ApiKVReference, 0) + + resp, err := c.GetAppSettingsKeyVaultReferencesSlot(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetAppSettingsKeyVaultReferencesSlotCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getappsettingskeyvaultreferencesslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getappsettingskeyvaultreferencesslot_autorest.go deleted file mode 100644 index c28b380d99f..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getappsettingskeyvaultreferencesslot_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetAppSettingsKeyVaultReferencesSlotOperationResponse struct { - HttpResponse *http.Response - Model *[]ApiKVReference - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (GetAppSettingsKeyVaultReferencesSlotOperationResponse, error) -} - -type GetAppSettingsKeyVaultReferencesSlotCompleteResult struct { - Items []ApiKVReference -} - -func (r GetAppSettingsKeyVaultReferencesSlotOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r GetAppSettingsKeyVaultReferencesSlotOperationResponse) LoadMore(ctx context.Context) (resp GetAppSettingsKeyVaultReferencesSlotOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// GetAppSettingsKeyVaultReferencesSlot ... -func (c WebAppsClient) GetAppSettingsKeyVaultReferencesSlot(ctx context.Context, id SlotId) (resp GetAppSettingsKeyVaultReferencesSlotOperationResponse, err error) { - req, err := c.preparerForGetAppSettingsKeyVaultReferencesSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetAppSettingsKeyVaultReferencesSlot", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetAppSettingsKeyVaultReferencesSlot", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForGetAppSettingsKeyVaultReferencesSlot(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetAppSettingsKeyVaultReferencesSlot", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForGetAppSettingsKeyVaultReferencesSlot prepares the GetAppSettingsKeyVaultReferencesSlot request. -func (c WebAppsClient) preparerForGetAppSettingsKeyVaultReferencesSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/configReferences/appSettings", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForGetAppSettingsKeyVaultReferencesSlotWithNextLink prepares the GetAppSettingsKeyVaultReferencesSlot request with the given nextLink token. -func (c WebAppsClient) preparerForGetAppSettingsKeyVaultReferencesSlotWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetAppSettingsKeyVaultReferencesSlot handles the response to the GetAppSettingsKeyVaultReferencesSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetAppSettingsKeyVaultReferencesSlot(resp *http.Response) (result GetAppSettingsKeyVaultReferencesSlotOperationResponse, err error) { - type page struct { - Values []ApiKVReference `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result GetAppSettingsKeyVaultReferencesSlotOperationResponse, err error) { - req, err := c.preparerForGetAppSettingsKeyVaultReferencesSlotWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetAppSettingsKeyVaultReferencesSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetAppSettingsKeyVaultReferencesSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetAppSettingsKeyVaultReferencesSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetAppSettingsKeyVaultReferencesSlot", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// GetAppSettingsKeyVaultReferencesSlotComplete retrieves all of the results into a single object -func (c WebAppsClient) GetAppSettingsKeyVaultReferencesSlotComplete(ctx context.Context, id SlotId) (GetAppSettingsKeyVaultReferencesSlotCompleteResult, error) { - return c.GetAppSettingsKeyVaultReferencesSlotCompleteMatchingPredicate(ctx, id, ApiKVReferenceOperationPredicate{}) -} - -// GetAppSettingsKeyVaultReferencesSlotCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) GetAppSettingsKeyVaultReferencesSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate ApiKVReferenceOperationPredicate) (resp GetAppSettingsKeyVaultReferencesSlotCompleteResult, err error) { - items := make([]ApiKVReference, 0) - - page, err := c.GetAppSettingsKeyVaultReferencesSlot(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := GetAppSettingsKeyVaultReferencesSlotCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getauthsettings.go b/resource-manager/web/2022-09-01/webapps/method_getauthsettings.go new file mode 100644 index 00000000000..a87e8930bf8 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getauthsettings.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetAuthSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteAuthSettings +} + +// GetAuthSettings ... +func (c WebAppsClient) GetAuthSettings(ctx context.Context, id SiteId) (result GetAuthSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/authsettings/list", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getauthsettings_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getauthsettings_autorest.go deleted file mode 100644 index d2bda6497dc..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getauthsettings_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetAuthSettingsOperationResponse struct { - HttpResponse *http.Response - Model *SiteAuthSettings -} - -// GetAuthSettings ... -func (c WebAppsClient) GetAuthSettings(ctx context.Context, id SiteId) (result GetAuthSettingsOperationResponse, err error) { - req, err := c.preparerForGetAuthSettings(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetAuthSettings", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetAuthSettings", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetAuthSettings(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetAuthSettings", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetAuthSettings prepares the GetAuthSettings request. -func (c WebAppsClient) preparerForGetAuthSettings(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/authsettings/list", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetAuthSettings handles the response to the GetAuthSettings request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetAuthSettings(resp *http.Response) (result GetAuthSettingsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getauthsettingsslot.go b/resource-manager/web/2022-09-01/webapps/method_getauthsettingsslot.go new file mode 100644 index 00000000000..0f26385cc89 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getauthsettingsslot.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetAuthSettingsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteAuthSettings +} + +// GetAuthSettingsSlot ... +func (c WebAppsClient) GetAuthSettingsSlot(ctx context.Context, id SlotId) (result GetAuthSettingsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/authsettings/list", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getauthsettingsslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getauthsettingsslot_autorest.go deleted file mode 100644 index 883042568b3..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getauthsettingsslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetAuthSettingsSlotOperationResponse struct { - HttpResponse *http.Response - Model *SiteAuthSettings -} - -// GetAuthSettingsSlot ... -func (c WebAppsClient) GetAuthSettingsSlot(ctx context.Context, id SlotId) (result GetAuthSettingsSlotOperationResponse, err error) { - req, err := c.preparerForGetAuthSettingsSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetAuthSettingsSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetAuthSettingsSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetAuthSettingsSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetAuthSettingsSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetAuthSettingsSlot prepares the GetAuthSettingsSlot request. -func (c WebAppsClient) preparerForGetAuthSettingsSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/authsettings/list", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetAuthSettingsSlot handles the response to the GetAuthSettingsSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetAuthSettingsSlot(resp *http.Response) (result GetAuthSettingsSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getauthsettingsv2.go b/resource-manager/web/2022-09-01/webapps/method_getauthsettingsv2.go new file mode 100644 index 00000000000..ea27f5fd431 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getauthsettingsv2.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetAuthSettingsV2OperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteAuthSettingsV2 +} + +// GetAuthSettingsV2 ... +func (c WebAppsClient) GetAuthSettingsV2(ctx context.Context, id SiteId) (result GetAuthSettingsV2OperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/config/authsettingsV2/list", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getauthsettingsv2_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getauthsettingsv2_autorest.go deleted file mode 100644 index 31c6efdccfd..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getauthsettingsv2_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetAuthSettingsV2OperationResponse struct { - HttpResponse *http.Response - Model *SiteAuthSettingsV2 -} - -// GetAuthSettingsV2 ... -func (c WebAppsClient) GetAuthSettingsV2(ctx context.Context, id SiteId) (result GetAuthSettingsV2OperationResponse, err error) { - req, err := c.preparerForGetAuthSettingsV2(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetAuthSettingsV2", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetAuthSettingsV2", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetAuthSettingsV2(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetAuthSettingsV2", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetAuthSettingsV2 prepares the GetAuthSettingsV2 request. -func (c WebAppsClient) preparerForGetAuthSettingsV2(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/authsettingsV2/list", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetAuthSettingsV2 handles the response to the GetAuthSettingsV2 request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetAuthSettingsV2(resp *http.Response) (result GetAuthSettingsV2OperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getauthsettingsv2slot.go b/resource-manager/web/2022-09-01/webapps/method_getauthsettingsv2slot.go new file mode 100644 index 00000000000..ee2a24e1f83 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getauthsettingsv2slot.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetAuthSettingsV2SlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteAuthSettingsV2 +} + +// GetAuthSettingsV2Slot ... +func (c WebAppsClient) GetAuthSettingsV2Slot(ctx context.Context, id SlotId) (result GetAuthSettingsV2SlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/config/authsettingsV2/list", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getauthsettingsv2slot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getauthsettingsv2slot_autorest.go deleted file mode 100644 index 0e7ae249e31..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getauthsettingsv2slot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetAuthSettingsV2SlotOperationResponse struct { - HttpResponse *http.Response - Model *SiteAuthSettingsV2 -} - -// GetAuthSettingsV2Slot ... -func (c WebAppsClient) GetAuthSettingsV2Slot(ctx context.Context, id SlotId) (result GetAuthSettingsV2SlotOperationResponse, err error) { - req, err := c.preparerForGetAuthSettingsV2Slot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetAuthSettingsV2Slot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetAuthSettingsV2Slot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetAuthSettingsV2Slot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetAuthSettingsV2Slot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetAuthSettingsV2Slot prepares the GetAuthSettingsV2Slot request. -func (c WebAppsClient) preparerForGetAuthSettingsV2Slot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/authsettingsV2/list", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetAuthSettingsV2Slot handles the response to the GetAuthSettingsV2Slot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetAuthSettingsV2Slot(resp *http.Response) (result GetAuthSettingsV2SlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getauthsettingsv2withoutsecrets.go b/resource-manager/web/2022-09-01/webapps/method_getauthsettingsv2withoutsecrets.go new file mode 100644 index 00000000000..e421d2ddf80 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getauthsettingsv2withoutsecrets.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetAuthSettingsV2WithoutSecretsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteAuthSettingsV2 +} + +// GetAuthSettingsV2WithoutSecrets ... +func (c WebAppsClient) GetAuthSettingsV2WithoutSecrets(ctx context.Context, id SiteId) (result GetAuthSettingsV2WithoutSecretsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/config/authsettingsV2", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getauthsettingsv2withoutsecrets_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getauthsettingsv2withoutsecrets_autorest.go deleted file mode 100644 index 1101e5de073..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getauthsettingsv2withoutsecrets_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetAuthSettingsV2WithoutSecretsOperationResponse struct { - HttpResponse *http.Response - Model *SiteAuthSettingsV2 -} - -// GetAuthSettingsV2WithoutSecrets ... -func (c WebAppsClient) GetAuthSettingsV2WithoutSecrets(ctx context.Context, id SiteId) (result GetAuthSettingsV2WithoutSecretsOperationResponse, err error) { - req, err := c.preparerForGetAuthSettingsV2WithoutSecrets(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetAuthSettingsV2WithoutSecrets", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetAuthSettingsV2WithoutSecrets", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetAuthSettingsV2WithoutSecrets(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetAuthSettingsV2WithoutSecrets", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetAuthSettingsV2WithoutSecrets prepares the GetAuthSettingsV2WithoutSecrets request. -func (c WebAppsClient) preparerForGetAuthSettingsV2WithoutSecrets(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/authsettingsV2", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetAuthSettingsV2WithoutSecrets handles the response to the GetAuthSettingsV2WithoutSecrets request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetAuthSettingsV2WithoutSecrets(resp *http.Response) (result GetAuthSettingsV2WithoutSecretsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getauthsettingsv2withoutsecretsslot.go b/resource-manager/web/2022-09-01/webapps/method_getauthsettingsv2withoutsecretsslot.go new file mode 100644 index 00000000000..85d151b03b4 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getauthsettingsv2withoutsecretsslot.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetAuthSettingsV2WithoutSecretsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteAuthSettingsV2 +} + +// GetAuthSettingsV2WithoutSecretsSlot ... +func (c WebAppsClient) GetAuthSettingsV2WithoutSecretsSlot(ctx context.Context, id SlotId) (result GetAuthSettingsV2WithoutSecretsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/config/authsettingsV2", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getauthsettingsv2withoutsecretsslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getauthsettingsv2withoutsecretsslot_autorest.go deleted file mode 100644 index 3044603ea0c..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getauthsettingsv2withoutsecretsslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetAuthSettingsV2WithoutSecretsSlotOperationResponse struct { - HttpResponse *http.Response - Model *SiteAuthSettingsV2 -} - -// GetAuthSettingsV2WithoutSecretsSlot ... -func (c WebAppsClient) GetAuthSettingsV2WithoutSecretsSlot(ctx context.Context, id SlotId) (result GetAuthSettingsV2WithoutSecretsSlotOperationResponse, err error) { - req, err := c.preparerForGetAuthSettingsV2WithoutSecretsSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetAuthSettingsV2WithoutSecretsSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetAuthSettingsV2WithoutSecretsSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetAuthSettingsV2WithoutSecretsSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetAuthSettingsV2WithoutSecretsSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetAuthSettingsV2WithoutSecretsSlot prepares the GetAuthSettingsV2WithoutSecretsSlot request. -func (c WebAppsClient) preparerForGetAuthSettingsV2WithoutSecretsSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/authsettingsV2", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetAuthSettingsV2WithoutSecretsSlot handles the response to the GetAuthSettingsV2WithoutSecretsSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetAuthSettingsV2WithoutSecretsSlot(resp *http.Response) (result GetAuthSettingsV2WithoutSecretsSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getbackupconfiguration.go b/resource-manager/web/2022-09-01/webapps/method_getbackupconfiguration.go new file mode 100644 index 00000000000..4958f239f96 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getbackupconfiguration.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetBackupConfigurationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BackupRequest +} + +// GetBackupConfiguration ... +func (c WebAppsClient) GetBackupConfiguration(ctx context.Context, id SiteId) (result GetBackupConfigurationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/backup/list", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getbackupconfiguration_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getbackupconfiguration_autorest.go deleted file mode 100644 index acf4b64d2f8..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getbackupconfiguration_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetBackupConfigurationOperationResponse struct { - HttpResponse *http.Response - Model *BackupRequest -} - -// GetBackupConfiguration ... -func (c WebAppsClient) GetBackupConfiguration(ctx context.Context, id SiteId) (result GetBackupConfigurationOperationResponse, err error) { - req, err := c.preparerForGetBackupConfiguration(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetBackupConfiguration", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetBackupConfiguration", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetBackupConfiguration(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetBackupConfiguration", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetBackupConfiguration prepares the GetBackupConfiguration request. -func (c WebAppsClient) preparerForGetBackupConfiguration(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/backup/list", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetBackupConfiguration handles the response to the GetBackupConfiguration request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetBackupConfiguration(resp *http.Response) (result GetBackupConfigurationOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getbackupconfigurationslot.go b/resource-manager/web/2022-09-01/webapps/method_getbackupconfigurationslot.go new file mode 100644 index 00000000000..a77e2396967 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getbackupconfigurationslot.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetBackupConfigurationSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BackupRequest +} + +// GetBackupConfigurationSlot ... +func (c WebAppsClient) GetBackupConfigurationSlot(ctx context.Context, id SlotId) (result GetBackupConfigurationSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/backup/list", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getbackupconfigurationslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getbackupconfigurationslot_autorest.go deleted file mode 100644 index 72c0845e422..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getbackupconfigurationslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetBackupConfigurationSlotOperationResponse struct { - HttpResponse *http.Response - Model *BackupRequest -} - -// GetBackupConfigurationSlot ... -func (c WebAppsClient) GetBackupConfigurationSlot(ctx context.Context, id SlotId) (result GetBackupConfigurationSlotOperationResponse, err error) { - req, err := c.preparerForGetBackupConfigurationSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetBackupConfigurationSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetBackupConfigurationSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetBackupConfigurationSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetBackupConfigurationSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetBackupConfigurationSlot prepares the GetBackupConfigurationSlot request. -func (c WebAppsClient) preparerForGetBackupConfigurationSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/backup/list", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetBackupConfigurationSlot handles the response to the GetBackupConfigurationSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetBackupConfigurationSlot(resp *http.Response) (result GetBackupConfigurationSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getbackupstatus.go b/resource-manager/web/2022-09-01/webapps/method_getbackupstatus.go new file mode 100644 index 00000000000..1002243f072 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getbackupstatus.go @@ -0,0 +1,51 @@ +package webapps + +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 GetBackupStatusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BackupItem +} + +// GetBackupStatus ... +func (c WebAppsClient) GetBackupStatus(ctx context.Context, id BackupId) (result GetBackupStatusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getbackupstatus_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getbackupstatus_autorest.go deleted file mode 100644 index 90ed69e40b6..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getbackupstatus_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetBackupStatusOperationResponse struct { - HttpResponse *http.Response - Model *BackupItem -} - -// GetBackupStatus ... -func (c WebAppsClient) GetBackupStatus(ctx context.Context, id BackupId) (result GetBackupStatusOperationResponse, err error) { - req, err := c.preparerForGetBackupStatus(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetBackupStatus", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetBackupStatus", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetBackupStatus(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetBackupStatus", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetBackupStatus prepares the GetBackupStatus request. -func (c WebAppsClient) preparerForGetBackupStatus(ctx context.Context, id BackupId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetBackupStatus handles the response to the GetBackupStatus request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetBackupStatus(resp *http.Response) (result GetBackupStatusOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getbackupstatusslot.go b/resource-manager/web/2022-09-01/webapps/method_getbackupstatusslot.go new file mode 100644 index 00000000000..4b44a81f445 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getbackupstatusslot.go @@ -0,0 +1,51 @@ +package webapps + +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 GetBackupStatusSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BackupItem +} + +// GetBackupStatusSlot ... +func (c WebAppsClient) GetBackupStatusSlot(ctx context.Context, id SlotBackupId) (result GetBackupStatusSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getbackupstatusslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getbackupstatusslot_autorest.go deleted file mode 100644 index 5841f73e866..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getbackupstatusslot_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetBackupStatusSlotOperationResponse struct { - HttpResponse *http.Response - Model *BackupItem -} - -// GetBackupStatusSlot ... -func (c WebAppsClient) GetBackupStatusSlot(ctx context.Context, id SlotBackupId) (result GetBackupStatusSlotOperationResponse, err error) { - req, err := c.preparerForGetBackupStatusSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetBackupStatusSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetBackupStatusSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetBackupStatusSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetBackupStatusSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetBackupStatusSlot prepares the GetBackupStatusSlot request. -func (c WebAppsClient) preparerForGetBackupStatusSlot(ctx context.Context, id SlotBackupId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetBackupStatusSlot handles the response to the GetBackupStatusSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetBackupStatusSlot(resp *http.Response) (result GetBackupStatusSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getconfiguration.go b/resource-manager/web/2022-09-01/webapps/method_getconfiguration.go new file mode 100644 index 00000000000..dff039733eb --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getconfiguration.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetConfigurationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteConfigResource +} + +// GetConfiguration ... +func (c WebAppsClient) GetConfiguration(ctx context.Context, id SiteId) (result GetConfigurationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/config/web", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getconfiguration_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getconfiguration_autorest.go deleted file mode 100644 index 400afc4c4c7..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getconfiguration_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetConfigurationOperationResponse struct { - HttpResponse *http.Response - Model *SiteConfigResource -} - -// GetConfiguration ... -func (c WebAppsClient) GetConfiguration(ctx context.Context, id SiteId) (result GetConfigurationOperationResponse, err error) { - req, err := c.preparerForGetConfiguration(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetConfiguration", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetConfiguration", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetConfiguration(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetConfiguration", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetConfiguration prepares the GetConfiguration request. -func (c WebAppsClient) preparerForGetConfiguration(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/web", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetConfiguration handles the response to the GetConfiguration request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetConfiguration(resp *http.Response) (result GetConfigurationOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getconfigurationslot.go b/resource-manager/web/2022-09-01/webapps/method_getconfigurationslot.go new file mode 100644 index 00000000000..cac67259846 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getconfigurationslot.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetConfigurationSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteConfigResource +} + +// GetConfigurationSlot ... +func (c WebAppsClient) GetConfigurationSlot(ctx context.Context, id SlotId) (result GetConfigurationSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/config/web", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getconfigurationslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getconfigurationslot_autorest.go deleted file mode 100644 index 1fcd4db8f9c..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getconfigurationslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetConfigurationSlotOperationResponse struct { - HttpResponse *http.Response - Model *SiteConfigResource -} - -// GetConfigurationSlot ... -func (c WebAppsClient) GetConfigurationSlot(ctx context.Context, id SlotId) (result GetConfigurationSlotOperationResponse, err error) { - req, err := c.preparerForGetConfigurationSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetConfigurationSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetConfigurationSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetConfigurationSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetConfigurationSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetConfigurationSlot prepares the GetConfigurationSlot request. -func (c WebAppsClient) preparerForGetConfigurationSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/web", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetConfigurationSlot handles the response to the GetConfigurationSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetConfigurationSlot(resp *http.Response) (result GetConfigurationSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getconfigurationsnapshot.go b/resource-manager/web/2022-09-01/webapps/method_getconfigurationsnapshot.go new file mode 100644 index 00000000000..4fde794f9e3 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getconfigurationsnapshot.go @@ -0,0 +1,51 @@ +package webapps + +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 GetConfigurationSnapshotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteConfigResource +} + +// GetConfigurationSnapshot ... +func (c WebAppsClient) GetConfigurationSnapshot(ctx context.Context, id SnapshotId) (result GetConfigurationSnapshotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getconfigurationsnapshot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getconfigurationsnapshot_autorest.go deleted file mode 100644 index 9a3bedc3a7e..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getconfigurationsnapshot_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetConfigurationSnapshotOperationResponse struct { - HttpResponse *http.Response - Model *SiteConfigResource -} - -// GetConfigurationSnapshot ... -func (c WebAppsClient) GetConfigurationSnapshot(ctx context.Context, id SnapshotId) (result GetConfigurationSnapshotOperationResponse, err error) { - req, err := c.preparerForGetConfigurationSnapshot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetConfigurationSnapshot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetConfigurationSnapshot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetConfigurationSnapshot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetConfigurationSnapshot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetConfigurationSnapshot prepares the GetConfigurationSnapshot request. -func (c WebAppsClient) preparerForGetConfigurationSnapshot(ctx context.Context, id SnapshotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetConfigurationSnapshot handles the response to the GetConfigurationSnapshot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetConfigurationSnapshot(resp *http.Response) (result GetConfigurationSnapshotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getconfigurationsnapshotslot.go b/resource-manager/web/2022-09-01/webapps/method_getconfigurationsnapshotslot.go new file mode 100644 index 00000000000..3499a5e3cb6 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getconfigurationsnapshotslot.go @@ -0,0 +1,51 @@ +package webapps + +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 GetConfigurationSnapshotSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteConfigResource +} + +// GetConfigurationSnapshotSlot ... +func (c WebAppsClient) GetConfigurationSnapshotSlot(ctx context.Context, id WebSnapshotId) (result GetConfigurationSnapshotSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getconfigurationsnapshotslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getconfigurationsnapshotslot_autorest.go deleted file mode 100644 index 059579c9932..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getconfigurationsnapshotslot_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetConfigurationSnapshotSlotOperationResponse struct { - HttpResponse *http.Response - Model *SiteConfigResource -} - -// GetConfigurationSnapshotSlot ... -func (c WebAppsClient) GetConfigurationSnapshotSlot(ctx context.Context, id WebSnapshotId) (result GetConfigurationSnapshotSlotOperationResponse, err error) { - req, err := c.preparerForGetConfigurationSnapshotSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetConfigurationSnapshotSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetConfigurationSnapshotSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetConfigurationSnapshotSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetConfigurationSnapshotSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetConfigurationSnapshotSlot prepares the GetConfigurationSnapshotSlot request. -func (c WebAppsClient) preparerForGetConfigurationSnapshotSlot(ctx context.Context, id WebSnapshotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetConfigurationSnapshotSlot handles the response to the GetConfigurationSnapshotSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetConfigurationSnapshotSlot(resp *http.Response) (result GetConfigurationSnapshotSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getcontainerlogszip.go b/resource-manager/web/2022-09-01/webapps/method_getcontainerlogszip.go new file mode 100644 index 00000000000..0cafd2c9cba --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getcontainerlogszip.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetContainerLogsZipOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]byte +} + +// GetContainerLogsZip ... +func (c WebAppsClient) GetContainerLogsZip(ctx context.Context, id SiteId) (result GetContainerLogsZipOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/containerlogs/zip/download", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getcontainerlogszip_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getcontainerlogszip_autorest.go deleted file mode 100644 index 1041325aecc..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getcontainerlogszip_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetContainerLogsZipOperationResponse struct { - HttpResponse *http.Response - Model *[]byte -} - -// GetContainerLogsZip ... -func (c WebAppsClient) GetContainerLogsZip(ctx context.Context, id SiteId) (result GetContainerLogsZipOperationResponse, err error) { - req, err := c.preparerForGetContainerLogsZip(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetContainerLogsZip", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetContainerLogsZip", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetContainerLogsZip(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetContainerLogsZip", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetContainerLogsZip prepares the GetContainerLogsZip request. -func (c WebAppsClient) preparerForGetContainerLogsZip(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/containerlogs/zip/download", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetContainerLogsZip handles the response to the GetContainerLogsZip request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetContainerLogsZip(resp *http.Response) (result GetContainerLogsZipOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getcontainerlogszipslot.go b/resource-manager/web/2022-09-01/webapps/method_getcontainerlogszipslot.go new file mode 100644 index 00000000000..22da3f4d7e7 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getcontainerlogszipslot.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetContainerLogsZipSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]byte +} + +// GetContainerLogsZipSlot ... +func (c WebAppsClient) GetContainerLogsZipSlot(ctx context.Context, id SlotId) (result GetContainerLogsZipSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/containerlogs/zip/download", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getcontainerlogszipslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getcontainerlogszipslot_autorest.go deleted file mode 100644 index 08e6bc36480..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getcontainerlogszipslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetContainerLogsZipSlotOperationResponse struct { - HttpResponse *http.Response - Model *[]byte -} - -// GetContainerLogsZipSlot ... -func (c WebAppsClient) GetContainerLogsZipSlot(ctx context.Context, id SlotId) (result GetContainerLogsZipSlotOperationResponse, err error) { - req, err := c.preparerForGetContainerLogsZipSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetContainerLogsZipSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetContainerLogsZipSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetContainerLogsZipSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetContainerLogsZipSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetContainerLogsZipSlot prepares the GetContainerLogsZipSlot request. -func (c WebAppsClient) preparerForGetContainerLogsZipSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/containerlogs/zip/download", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetContainerLogsZipSlot handles the response to the GetContainerLogsZipSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetContainerLogsZipSlot(resp *http.Response) (result GetContainerLogsZipSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getcontinuouswebjob.go b/resource-manager/web/2022-09-01/webapps/method_getcontinuouswebjob.go new file mode 100644 index 00000000000..33a636b26cf --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getcontinuouswebjob.go @@ -0,0 +1,51 @@ +package webapps + +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 GetContinuousWebJobOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ContinuousWebJob +} + +// GetContinuousWebJob ... +func (c WebAppsClient) GetContinuousWebJob(ctx context.Context, id ContinuousWebJobId) (result GetContinuousWebJobOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getcontinuouswebjob_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getcontinuouswebjob_autorest.go deleted file mode 100644 index 72b5c0597e6..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getcontinuouswebjob_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetContinuousWebJobOperationResponse struct { - HttpResponse *http.Response - Model *ContinuousWebJob -} - -// GetContinuousWebJob ... -func (c WebAppsClient) GetContinuousWebJob(ctx context.Context, id ContinuousWebJobId) (result GetContinuousWebJobOperationResponse, err error) { - req, err := c.preparerForGetContinuousWebJob(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetContinuousWebJob", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetContinuousWebJob", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetContinuousWebJob(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetContinuousWebJob", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetContinuousWebJob prepares the GetContinuousWebJob request. -func (c WebAppsClient) preparerForGetContinuousWebJob(ctx context.Context, id ContinuousWebJobId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetContinuousWebJob handles the response to the GetContinuousWebJob request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetContinuousWebJob(resp *http.Response) (result GetContinuousWebJobOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getcontinuouswebjobslot.go b/resource-manager/web/2022-09-01/webapps/method_getcontinuouswebjobslot.go new file mode 100644 index 00000000000..704927b0846 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getcontinuouswebjobslot.go @@ -0,0 +1,51 @@ +package webapps + +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 GetContinuousWebJobSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ContinuousWebJob +} + +// GetContinuousWebJobSlot ... +func (c WebAppsClient) GetContinuousWebJobSlot(ctx context.Context, id SlotContinuousWebJobId) (result GetContinuousWebJobSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getcontinuouswebjobslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getcontinuouswebjobslot_autorest.go deleted file mode 100644 index 1ab7cb80604..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getcontinuouswebjobslot_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetContinuousWebJobSlotOperationResponse struct { - HttpResponse *http.Response - Model *ContinuousWebJob -} - -// GetContinuousWebJobSlot ... -func (c WebAppsClient) GetContinuousWebJobSlot(ctx context.Context, id SlotContinuousWebJobId) (result GetContinuousWebJobSlotOperationResponse, err error) { - req, err := c.preparerForGetContinuousWebJobSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetContinuousWebJobSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetContinuousWebJobSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetContinuousWebJobSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetContinuousWebJobSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetContinuousWebJobSlot prepares the GetContinuousWebJobSlot request. -func (c WebAppsClient) preparerForGetContinuousWebJobSlot(ctx context.Context, id SlotContinuousWebJobId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetContinuousWebJobSlot handles the response to the GetContinuousWebJobSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetContinuousWebJobSlot(resp *http.Response) (result GetContinuousWebJobSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getdeployment.go b/resource-manager/web/2022-09-01/webapps/method_getdeployment.go new file mode 100644 index 00000000000..d66789f408a --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getdeployment.go @@ -0,0 +1,51 @@ +package webapps + +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 GetDeploymentOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Deployment +} + +// GetDeployment ... +func (c WebAppsClient) GetDeployment(ctx context.Context, id DeploymentId) (result GetDeploymentOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getdeployment_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getdeployment_autorest.go deleted file mode 100644 index 96c9937bca3..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getdeployment_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetDeploymentOperationResponse struct { - HttpResponse *http.Response - Model *Deployment -} - -// GetDeployment ... -func (c WebAppsClient) GetDeployment(ctx context.Context, id DeploymentId) (result GetDeploymentOperationResponse, err error) { - req, err := c.preparerForGetDeployment(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetDeployment", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetDeployment", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetDeployment(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetDeployment", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetDeployment prepares the GetDeployment request. -func (c WebAppsClient) preparerForGetDeployment(ctx context.Context, id DeploymentId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetDeployment handles the response to the GetDeployment request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetDeployment(resp *http.Response) (result GetDeploymentOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getdeploymentslot.go b/resource-manager/web/2022-09-01/webapps/method_getdeploymentslot.go new file mode 100644 index 00000000000..e253efdfa08 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getdeploymentslot.go @@ -0,0 +1,51 @@ +package webapps + +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 GetDeploymentSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Deployment +} + +// GetDeploymentSlot ... +func (c WebAppsClient) GetDeploymentSlot(ctx context.Context, id SlotDeploymentId) (result GetDeploymentSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getdeploymentslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getdeploymentslot_autorest.go deleted file mode 100644 index 527e95ef01d..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getdeploymentslot_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetDeploymentSlotOperationResponse struct { - HttpResponse *http.Response - Model *Deployment -} - -// GetDeploymentSlot ... -func (c WebAppsClient) GetDeploymentSlot(ctx context.Context, id SlotDeploymentId) (result GetDeploymentSlotOperationResponse, err error) { - req, err := c.preparerForGetDeploymentSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetDeploymentSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetDeploymentSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetDeploymentSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetDeploymentSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetDeploymentSlot prepares the GetDeploymentSlot request. -func (c WebAppsClient) preparerForGetDeploymentSlot(ctx context.Context, id SlotDeploymentId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetDeploymentSlot handles the response to the GetDeploymentSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetDeploymentSlot(resp *http.Response) (result GetDeploymentSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getdiagnosticlogsconfiguration.go b/resource-manager/web/2022-09-01/webapps/method_getdiagnosticlogsconfiguration.go new file mode 100644 index 00000000000..51f13bc5a3c --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getdiagnosticlogsconfiguration.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetDiagnosticLogsConfigurationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteLogsConfig +} + +// GetDiagnosticLogsConfiguration ... +func (c WebAppsClient) GetDiagnosticLogsConfiguration(ctx context.Context, id SiteId) (result GetDiagnosticLogsConfigurationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/config/logs", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getdiagnosticlogsconfiguration_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getdiagnosticlogsconfiguration_autorest.go deleted file mode 100644 index 97b773a1f3d..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getdiagnosticlogsconfiguration_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetDiagnosticLogsConfigurationOperationResponse struct { - HttpResponse *http.Response - Model *SiteLogsConfig -} - -// GetDiagnosticLogsConfiguration ... -func (c WebAppsClient) GetDiagnosticLogsConfiguration(ctx context.Context, id SiteId) (result GetDiagnosticLogsConfigurationOperationResponse, err error) { - req, err := c.preparerForGetDiagnosticLogsConfiguration(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetDiagnosticLogsConfiguration", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetDiagnosticLogsConfiguration", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetDiagnosticLogsConfiguration(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetDiagnosticLogsConfiguration", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetDiagnosticLogsConfiguration prepares the GetDiagnosticLogsConfiguration request. -func (c WebAppsClient) preparerForGetDiagnosticLogsConfiguration(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/logs", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetDiagnosticLogsConfiguration handles the response to the GetDiagnosticLogsConfiguration request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetDiagnosticLogsConfiguration(resp *http.Response) (result GetDiagnosticLogsConfigurationOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getdiagnosticlogsconfigurationslot.go b/resource-manager/web/2022-09-01/webapps/method_getdiagnosticlogsconfigurationslot.go new file mode 100644 index 00000000000..7295f41c725 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getdiagnosticlogsconfigurationslot.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetDiagnosticLogsConfigurationSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteLogsConfig +} + +// GetDiagnosticLogsConfigurationSlot ... +func (c WebAppsClient) GetDiagnosticLogsConfigurationSlot(ctx context.Context, id SlotId) (result GetDiagnosticLogsConfigurationSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/config/logs", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getdiagnosticlogsconfigurationslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getdiagnosticlogsconfigurationslot_autorest.go deleted file mode 100644 index 36e9dabca9b..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getdiagnosticlogsconfigurationslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetDiagnosticLogsConfigurationSlotOperationResponse struct { - HttpResponse *http.Response - Model *SiteLogsConfig -} - -// GetDiagnosticLogsConfigurationSlot ... -func (c WebAppsClient) GetDiagnosticLogsConfigurationSlot(ctx context.Context, id SlotId) (result GetDiagnosticLogsConfigurationSlotOperationResponse, err error) { - req, err := c.preparerForGetDiagnosticLogsConfigurationSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetDiagnosticLogsConfigurationSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetDiagnosticLogsConfigurationSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetDiagnosticLogsConfigurationSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetDiagnosticLogsConfigurationSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetDiagnosticLogsConfigurationSlot prepares the GetDiagnosticLogsConfigurationSlot request. -func (c WebAppsClient) preparerForGetDiagnosticLogsConfigurationSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/logs", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetDiagnosticLogsConfigurationSlot handles the response to the GetDiagnosticLogsConfigurationSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetDiagnosticLogsConfigurationSlot(resp *http.Response) (result GetDiagnosticLogsConfigurationSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getdomainownershipidentifier.go b/resource-manager/web/2022-09-01/webapps/method_getdomainownershipidentifier.go new file mode 100644 index 00000000000..bf1604c6585 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getdomainownershipidentifier.go @@ -0,0 +1,51 @@ +package webapps + +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 GetDomainOwnershipIdentifierOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Identifier +} + +// GetDomainOwnershipIdentifier ... +func (c WebAppsClient) GetDomainOwnershipIdentifier(ctx context.Context, id DomainOwnershipIdentifierId) (result GetDomainOwnershipIdentifierOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getdomainownershipidentifier_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getdomainownershipidentifier_autorest.go deleted file mode 100644 index 3d5d0385ce8..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getdomainownershipidentifier_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetDomainOwnershipIdentifierOperationResponse struct { - HttpResponse *http.Response - Model *Identifier -} - -// GetDomainOwnershipIdentifier ... -func (c WebAppsClient) GetDomainOwnershipIdentifier(ctx context.Context, id DomainOwnershipIdentifierId) (result GetDomainOwnershipIdentifierOperationResponse, err error) { - req, err := c.preparerForGetDomainOwnershipIdentifier(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetDomainOwnershipIdentifier", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetDomainOwnershipIdentifier", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetDomainOwnershipIdentifier(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetDomainOwnershipIdentifier", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetDomainOwnershipIdentifier prepares the GetDomainOwnershipIdentifier request. -func (c WebAppsClient) preparerForGetDomainOwnershipIdentifier(ctx context.Context, id DomainOwnershipIdentifierId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetDomainOwnershipIdentifier handles the response to the GetDomainOwnershipIdentifier request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetDomainOwnershipIdentifier(resp *http.Response) (result GetDomainOwnershipIdentifierOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getdomainownershipidentifierslot.go b/resource-manager/web/2022-09-01/webapps/method_getdomainownershipidentifierslot.go new file mode 100644 index 00000000000..deee0165c15 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getdomainownershipidentifierslot.go @@ -0,0 +1,51 @@ +package webapps + +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 GetDomainOwnershipIdentifierSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Identifier +} + +// GetDomainOwnershipIdentifierSlot ... +func (c WebAppsClient) GetDomainOwnershipIdentifierSlot(ctx context.Context, id SlotDomainOwnershipIdentifierId) (result GetDomainOwnershipIdentifierSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getdomainownershipidentifierslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getdomainownershipidentifierslot_autorest.go deleted file mode 100644 index 81b635912ea..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getdomainownershipidentifierslot_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetDomainOwnershipIdentifierSlotOperationResponse struct { - HttpResponse *http.Response - Model *Identifier -} - -// GetDomainOwnershipIdentifierSlot ... -func (c WebAppsClient) GetDomainOwnershipIdentifierSlot(ctx context.Context, id SlotDomainOwnershipIdentifierId) (result GetDomainOwnershipIdentifierSlotOperationResponse, err error) { - req, err := c.preparerForGetDomainOwnershipIdentifierSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetDomainOwnershipIdentifierSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetDomainOwnershipIdentifierSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetDomainOwnershipIdentifierSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetDomainOwnershipIdentifierSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetDomainOwnershipIdentifierSlot prepares the GetDomainOwnershipIdentifierSlot request. -func (c WebAppsClient) preparerForGetDomainOwnershipIdentifierSlot(ctx context.Context, id SlotDomainOwnershipIdentifierId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetDomainOwnershipIdentifierSlot handles the response to the GetDomainOwnershipIdentifierSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetDomainOwnershipIdentifierSlot(resp *http.Response) (result GetDomainOwnershipIdentifierSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getftpallowed.go b/resource-manager/web/2022-09-01/webapps/method_getftpallowed.go new file mode 100644 index 00000000000..1093ae7c362 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getftpallowed.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetFtpAllowedOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CsmPublishingCredentialsPoliciesEntity +} + +// GetFtpAllowed ... +func (c WebAppsClient) GetFtpAllowed(ctx context.Context, id SiteId) (result GetFtpAllowedOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/basicPublishingCredentialsPolicies/ftp", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getftpallowed_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getftpallowed_autorest.go deleted file mode 100644 index c9bd96fd1c7..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getftpallowed_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetFtpAllowedOperationResponse struct { - HttpResponse *http.Response - Model *CsmPublishingCredentialsPoliciesEntity -} - -// GetFtpAllowed ... -func (c WebAppsClient) GetFtpAllowed(ctx context.Context, id SiteId) (result GetFtpAllowedOperationResponse, err error) { - req, err := c.preparerForGetFtpAllowed(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetFtpAllowed", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetFtpAllowed", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetFtpAllowed(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetFtpAllowed", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetFtpAllowed prepares the GetFtpAllowed request. -func (c WebAppsClient) preparerForGetFtpAllowed(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/basicPublishingCredentialsPolicies/ftp", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetFtpAllowed handles the response to the GetFtpAllowed request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetFtpAllowed(resp *http.Response) (result GetFtpAllowedOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getftpallowedslot.go b/resource-manager/web/2022-09-01/webapps/method_getftpallowedslot.go new file mode 100644 index 00000000000..668b6a03e38 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getftpallowedslot.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetFtpAllowedSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CsmPublishingCredentialsPoliciesEntity +} + +// GetFtpAllowedSlot ... +func (c WebAppsClient) GetFtpAllowedSlot(ctx context.Context, id SlotId) (result GetFtpAllowedSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/basicPublishingCredentialsPolicies/ftp", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getftpallowedslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getftpallowedslot_autorest.go deleted file mode 100644 index b80107d037c..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getftpallowedslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetFtpAllowedSlotOperationResponse struct { - HttpResponse *http.Response - Model *CsmPublishingCredentialsPoliciesEntity -} - -// GetFtpAllowedSlot ... -func (c WebAppsClient) GetFtpAllowedSlot(ctx context.Context, id SlotId) (result GetFtpAllowedSlotOperationResponse, err error) { - req, err := c.preparerForGetFtpAllowedSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetFtpAllowedSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetFtpAllowedSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetFtpAllowedSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetFtpAllowedSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetFtpAllowedSlot prepares the GetFtpAllowedSlot request. -func (c WebAppsClient) preparerForGetFtpAllowedSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/basicPublishingCredentialsPolicies/ftp", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetFtpAllowedSlot handles the response to the GetFtpAllowedSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetFtpAllowedSlot(resp *http.Response) (result GetFtpAllowedSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getfunction.go b/resource-manager/web/2022-09-01/webapps/method_getfunction.go new file mode 100644 index 00000000000..ef0a5e8ccaa --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getfunction.go @@ -0,0 +1,51 @@ +package webapps + +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 GetFunctionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *FunctionEnvelope +} + +// GetFunction ... +func (c WebAppsClient) GetFunction(ctx context.Context, id FunctionId) (result GetFunctionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getfunction_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getfunction_autorest.go deleted file mode 100644 index 4747c8a315e..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getfunction_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetFunctionOperationResponse struct { - HttpResponse *http.Response - Model *FunctionEnvelope -} - -// GetFunction ... -func (c WebAppsClient) GetFunction(ctx context.Context, id FunctionId) (result GetFunctionOperationResponse, err error) { - req, err := c.preparerForGetFunction(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetFunction", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetFunction", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetFunction(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetFunction", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetFunction prepares the GetFunction request. -func (c WebAppsClient) preparerForGetFunction(ctx context.Context, id FunctionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetFunction handles the response to the GetFunction request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetFunction(resp *http.Response) (result GetFunctionOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getfunctionsadmintoken.go b/resource-manager/web/2022-09-01/webapps/method_getfunctionsadmintoken.go new file mode 100644 index 00000000000..aa283050e02 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getfunctionsadmintoken.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetFunctionsAdminTokenOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *string +} + +// GetFunctionsAdminToken ... +func (c WebAppsClient) GetFunctionsAdminToken(ctx context.Context, id SiteId) (result GetFunctionsAdminTokenOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/functions/admin/token", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getfunctionsadmintoken_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getfunctionsadmintoken_autorest.go deleted file mode 100644 index d6fdcfb1518..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getfunctionsadmintoken_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetFunctionsAdminTokenOperationResponse struct { - HttpResponse *http.Response - Model *string -} - -// GetFunctionsAdminToken ... -func (c WebAppsClient) GetFunctionsAdminToken(ctx context.Context, id SiteId) (result GetFunctionsAdminTokenOperationResponse, err error) { - req, err := c.preparerForGetFunctionsAdminToken(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetFunctionsAdminToken", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetFunctionsAdminToken", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetFunctionsAdminToken(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetFunctionsAdminToken", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetFunctionsAdminToken prepares the GetFunctionsAdminToken request. -func (c WebAppsClient) preparerForGetFunctionsAdminToken(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/functions/admin/token", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetFunctionsAdminToken handles the response to the GetFunctionsAdminToken request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetFunctionsAdminToken(resp *http.Response) (result GetFunctionsAdminTokenOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getfunctionsadmintokenslot.go b/resource-manager/web/2022-09-01/webapps/method_getfunctionsadmintokenslot.go new file mode 100644 index 00000000000..88d5188e470 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getfunctionsadmintokenslot.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetFunctionsAdminTokenSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *string +} + +// GetFunctionsAdminTokenSlot ... +func (c WebAppsClient) GetFunctionsAdminTokenSlot(ctx context.Context, id SlotId) (result GetFunctionsAdminTokenSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/functions/admin/token", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getfunctionsadmintokenslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getfunctionsadmintokenslot_autorest.go deleted file mode 100644 index b56d2b33c1e..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getfunctionsadmintokenslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetFunctionsAdminTokenSlotOperationResponse struct { - HttpResponse *http.Response - Model *string -} - -// GetFunctionsAdminTokenSlot ... -func (c WebAppsClient) GetFunctionsAdminTokenSlot(ctx context.Context, id SlotId) (result GetFunctionsAdminTokenSlotOperationResponse, err error) { - req, err := c.preparerForGetFunctionsAdminTokenSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetFunctionsAdminTokenSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetFunctionsAdminTokenSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetFunctionsAdminTokenSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetFunctionsAdminTokenSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetFunctionsAdminTokenSlot prepares the GetFunctionsAdminTokenSlot request. -func (c WebAppsClient) preparerForGetFunctionsAdminTokenSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/functions/admin/token", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetFunctionsAdminTokenSlot handles the response to the GetFunctionsAdminTokenSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetFunctionsAdminTokenSlot(resp *http.Response) (result GetFunctionsAdminTokenSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_gethostnamebinding.go b/resource-manager/web/2022-09-01/webapps/method_gethostnamebinding.go new file mode 100644 index 00000000000..306f27eef93 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_gethostnamebinding.go @@ -0,0 +1,51 @@ +package webapps + +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 GetHostNameBindingOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HostNameBinding +} + +// GetHostNameBinding ... +func (c WebAppsClient) GetHostNameBinding(ctx context.Context, id HostNameBindingId) (result GetHostNameBindingOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_gethostnamebinding_autorest.go b/resource-manager/web/2022-09-01/webapps/method_gethostnamebinding_autorest.go deleted file mode 100644 index 663eaf4622b..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_gethostnamebinding_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetHostNameBindingOperationResponse struct { - HttpResponse *http.Response - Model *HostNameBinding -} - -// GetHostNameBinding ... -func (c WebAppsClient) GetHostNameBinding(ctx context.Context, id HostNameBindingId) (result GetHostNameBindingOperationResponse, err error) { - req, err := c.preparerForGetHostNameBinding(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetHostNameBinding", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetHostNameBinding", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetHostNameBinding(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetHostNameBinding", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetHostNameBinding prepares the GetHostNameBinding request. -func (c WebAppsClient) preparerForGetHostNameBinding(ctx context.Context, id HostNameBindingId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetHostNameBinding handles the response to the GetHostNameBinding request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetHostNameBinding(resp *http.Response) (result GetHostNameBindingOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_gethostnamebindingslot.go b/resource-manager/web/2022-09-01/webapps/method_gethostnamebindingslot.go new file mode 100644 index 00000000000..a596b5a0982 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_gethostnamebindingslot.go @@ -0,0 +1,51 @@ +package webapps + +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 GetHostNameBindingSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HostNameBinding +} + +// GetHostNameBindingSlot ... +func (c WebAppsClient) GetHostNameBindingSlot(ctx context.Context, id SlotHostNameBindingId) (result GetHostNameBindingSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_gethostnamebindingslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_gethostnamebindingslot_autorest.go deleted file mode 100644 index 8704bc86a01..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_gethostnamebindingslot_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetHostNameBindingSlotOperationResponse struct { - HttpResponse *http.Response - Model *HostNameBinding -} - -// GetHostNameBindingSlot ... -func (c WebAppsClient) GetHostNameBindingSlot(ctx context.Context, id SlotHostNameBindingId) (result GetHostNameBindingSlotOperationResponse, err error) { - req, err := c.preparerForGetHostNameBindingSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetHostNameBindingSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetHostNameBindingSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetHostNameBindingSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetHostNameBindingSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetHostNameBindingSlot prepares the GetHostNameBindingSlot request. -func (c WebAppsClient) preparerForGetHostNameBindingSlot(ctx context.Context, id SlotHostNameBindingId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetHostNameBindingSlot handles the response to the GetHostNameBindingSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetHostNameBindingSlot(resp *http.Response) (result GetHostNameBindingSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_gethybridconnection.go b/resource-manager/web/2022-09-01/webapps/method_gethybridconnection.go new file mode 100644 index 00000000000..a46620028ba --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_gethybridconnection.go @@ -0,0 +1,51 @@ +package webapps + +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 GetHybridConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HybridConnection +} + +// GetHybridConnection ... +func (c WebAppsClient) GetHybridConnection(ctx context.Context, id RelayId) (result GetHybridConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_gethybridconnection_autorest.go b/resource-manager/web/2022-09-01/webapps/method_gethybridconnection_autorest.go deleted file mode 100644 index e51795c847b..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_gethybridconnection_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetHybridConnectionOperationResponse struct { - HttpResponse *http.Response - Model *HybridConnection -} - -// GetHybridConnection ... -func (c WebAppsClient) GetHybridConnection(ctx context.Context, id RelayId) (result GetHybridConnectionOperationResponse, err error) { - req, err := c.preparerForGetHybridConnection(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetHybridConnection", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetHybridConnection", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetHybridConnection(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetHybridConnection", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetHybridConnection prepares the GetHybridConnection request. -func (c WebAppsClient) preparerForGetHybridConnection(ctx context.Context, id RelayId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetHybridConnection handles the response to the GetHybridConnection request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetHybridConnection(resp *http.Response) (result GetHybridConnectionOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_gethybridconnectionslot.go b/resource-manager/web/2022-09-01/webapps/method_gethybridconnectionslot.go new file mode 100644 index 00000000000..6e900bb74b0 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_gethybridconnectionslot.go @@ -0,0 +1,51 @@ +package webapps + +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 GetHybridConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HybridConnection +} + +// GetHybridConnectionSlot ... +func (c WebAppsClient) GetHybridConnectionSlot(ctx context.Context, id SlotHybridConnectionNamespaceRelayId) (result GetHybridConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_gethybridconnectionslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_gethybridconnectionslot_autorest.go deleted file mode 100644 index d3246c4069d..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_gethybridconnectionslot_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetHybridConnectionSlotOperationResponse struct { - HttpResponse *http.Response - Model *HybridConnection -} - -// GetHybridConnectionSlot ... -func (c WebAppsClient) GetHybridConnectionSlot(ctx context.Context, id SlotHybridConnectionNamespaceRelayId) (result GetHybridConnectionSlotOperationResponse, err error) { - req, err := c.preparerForGetHybridConnectionSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetHybridConnectionSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetHybridConnectionSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetHybridConnectionSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetHybridConnectionSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetHybridConnectionSlot prepares the GetHybridConnectionSlot request. -func (c WebAppsClient) preparerForGetHybridConnectionSlot(ctx context.Context, id SlotHybridConnectionNamespaceRelayId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetHybridConnectionSlot handles the response to the GetHybridConnectionSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetHybridConnectionSlot(resp *http.Response) (result GetHybridConnectionSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getinstancefunctionslot.go b/resource-manager/web/2022-09-01/webapps/method_getinstancefunctionslot.go new file mode 100644 index 00000000000..7dd3a8e44ae --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getinstancefunctionslot.go @@ -0,0 +1,51 @@ +package webapps + +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 GetInstanceFunctionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *FunctionEnvelope +} + +// GetInstanceFunctionSlot ... +func (c WebAppsClient) GetInstanceFunctionSlot(ctx context.Context, id SlotFunctionId) (result GetInstanceFunctionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getinstancefunctionslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getinstancefunctionslot_autorest.go deleted file mode 100644 index 666f28323cf..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getinstancefunctionslot_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetInstanceFunctionSlotOperationResponse struct { - HttpResponse *http.Response - Model *FunctionEnvelope -} - -// GetInstanceFunctionSlot ... -func (c WebAppsClient) GetInstanceFunctionSlot(ctx context.Context, id SlotFunctionId) (result GetInstanceFunctionSlotOperationResponse, err error) { - req, err := c.preparerForGetInstanceFunctionSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetInstanceFunctionSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetInstanceFunctionSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetInstanceFunctionSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetInstanceFunctionSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetInstanceFunctionSlot prepares the GetInstanceFunctionSlot request. -func (c WebAppsClient) preparerForGetInstanceFunctionSlot(ctx context.Context, id SlotFunctionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetInstanceFunctionSlot handles the response to the GetInstanceFunctionSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetInstanceFunctionSlot(resp *http.Response) (result GetInstanceFunctionSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getinstanceinfo.go b/resource-manager/web/2022-09-01/webapps/method_getinstanceinfo.go new file mode 100644 index 00000000000..966a3436038 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getinstanceinfo.go @@ -0,0 +1,51 @@ +package webapps + +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 GetInstanceInfoOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WebSiteInstanceStatus +} + +// GetInstanceInfo ... +func (c WebAppsClient) GetInstanceInfo(ctx context.Context, id InstanceId) (result GetInstanceInfoOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getinstanceinfo_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getinstanceinfo_autorest.go deleted file mode 100644 index 0aaf61e61e2..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getinstanceinfo_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetInstanceInfoOperationResponse struct { - HttpResponse *http.Response - Model *WebSiteInstanceStatus -} - -// GetInstanceInfo ... -func (c WebAppsClient) GetInstanceInfo(ctx context.Context, id InstanceId) (result GetInstanceInfoOperationResponse, err error) { - req, err := c.preparerForGetInstanceInfo(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetInstanceInfo", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetInstanceInfo", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetInstanceInfo(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetInstanceInfo", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetInstanceInfo prepares the GetInstanceInfo request. -func (c WebAppsClient) preparerForGetInstanceInfo(ctx context.Context, id InstanceId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetInstanceInfo handles the response to the GetInstanceInfo request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetInstanceInfo(resp *http.Response) (result GetInstanceInfoOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getinstanceinfoslot.go b/resource-manager/web/2022-09-01/webapps/method_getinstanceinfoslot.go new file mode 100644 index 00000000000..d9ff8f9ffc3 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getinstanceinfoslot.go @@ -0,0 +1,51 @@ +package webapps + +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 GetInstanceInfoSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WebSiteInstanceStatus +} + +// GetInstanceInfoSlot ... +func (c WebAppsClient) GetInstanceInfoSlot(ctx context.Context, id SlotInstanceId) (result GetInstanceInfoSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getinstanceinfoslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getinstanceinfoslot_autorest.go deleted file mode 100644 index a5b0e7337f8..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getinstanceinfoslot_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetInstanceInfoSlotOperationResponse struct { - HttpResponse *http.Response - Model *WebSiteInstanceStatus -} - -// GetInstanceInfoSlot ... -func (c WebAppsClient) GetInstanceInfoSlot(ctx context.Context, id SlotInstanceId) (result GetInstanceInfoSlotOperationResponse, err error) { - req, err := c.preparerForGetInstanceInfoSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetInstanceInfoSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetInstanceInfoSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetInstanceInfoSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetInstanceInfoSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetInstanceInfoSlot prepares the GetInstanceInfoSlot request. -func (c WebAppsClient) preparerForGetInstanceInfoSlot(ctx context.Context, id SlotInstanceId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetInstanceInfoSlot handles the response to the GetInstanceInfoSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetInstanceInfoSlot(resp *http.Response) (result GetInstanceInfoSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getinstancemsdeploylog.go b/resource-manager/web/2022-09-01/webapps/method_getinstancemsdeploylog.go new file mode 100644 index 00000000000..ba2bd7b8691 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getinstancemsdeploylog.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetInstanceMSDeployLogOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MSDeployLog +} + +// GetInstanceMSDeployLog ... +func (c WebAppsClient) GetInstanceMSDeployLog(ctx context.Context, id InstanceId) (result GetInstanceMSDeployLogOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/extensions/mSDeploy/log", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getinstancemsdeploylog_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getinstancemsdeploylog_autorest.go deleted file mode 100644 index 714785cef3c..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getinstancemsdeploylog_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetInstanceMSDeployLogOperationResponse struct { - HttpResponse *http.Response - Model *MSDeployLog -} - -// GetInstanceMSDeployLog ... -func (c WebAppsClient) GetInstanceMSDeployLog(ctx context.Context, id InstanceId) (result GetInstanceMSDeployLogOperationResponse, err error) { - req, err := c.preparerForGetInstanceMSDeployLog(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetInstanceMSDeployLog", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetInstanceMSDeployLog", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetInstanceMSDeployLog(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetInstanceMSDeployLog", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetInstanceMSDeployLog prepares the GetInstanceMSDeployLog request. -func (c WebAppsClient) preparerForGetInstanceMSDeployLog(ctx context.Context, id InstanceId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/extensions/mSDeploy/log", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetInstanceMSDeployLog handles the response to the GetInstanceMSDeployLog request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetInstanceMSDeployLog(resp *http.Response) (result GetInstanceMSDeployLogOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getinstancemsdeploylogslot.go b/resource-manager/web/2022-09-01/webapps/method_getinstancemsdeploylogslot.go new file mode 100644 index 00000000000..4ec270bf582 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getinstancemsdeploylogslot.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetInstanceMSDeployLogSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MSDeployLog +} + +// GetInstanceMSDeployLogSlot ... +func (c WebAppsClient) GetInstanceMSDeployLogSlot(ctx context.Context, id SlotInstanceId) (result GetInstanceMSDeployLogSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/extensions/mSDeploy/log", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getinstancemsdeploylogslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getinstancemsdeploylogslot_autorest.go deleted file mode 100644 index c504c000f82..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getinstancemsdeploylogslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetInstanceMSDeployLogSlotOperationResponse struct { - HttpResponse *http.Response - Model *MSDeployLog -} - -// GetInstanceMSDeployLogSlot ... -func (c WebAppsClient) GetInstanceMSDeployLogSlot(ctx context.Context, id SlotInstanceId) (result GetInstanceMSDeployLogSlotOperationResponse, err error) { - req, err := c.preparerForGetInstanceMSDeployLogSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetInstanceMSDeployLogSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetInstanceMSDeployLogSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetInstanceMSDeployLogSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetInstanceMSDeployLogSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetInstanceMSDeployLogSlot prepares the GetInstanceMSDeployLogSlot request. -func (c WebAppsClient) preparerForGetInstanceMSDeployLogSlot(ctx context.Context, id SlotInstanceId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/extensions/mSDeploy/log", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetInstanceMSDeployLogSlot handles the response to the GetInstanceMSDeployLogSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetInstanceMSDeployLogSlot(resp *http.Response) (result GetInstanceMSDeployLogSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getinstancemsdeploystatus.go b/resource-manager/web/2022-09-01/webapps/method_getinstancemsdeploystatus.go new file mode 100644 index 00000000000..55ead9fb17e --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getinstancemsdeploystatus.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetInstanceMsDeployStatusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MSDeployStatus +} + +// GetInstanceMsDeployStatus ... +func (c WebAppsClient) GetInstanceMsDeployStatus(ctx context.Context, id InstanceId) (result GetInstanceMsDeployStatusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/extensions/mSDeploy", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getinstancemsdeploystatus_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getinstancemsdeploystatus_autorest.go deleted file mode 100644 index ecae21ca2c7..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getinstancemsdeploystatus_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetInstanceMsDeployStatusOperationResponse struct { - HttpResponse *http.Response - Model *MSDeployStatus -} - -// GetInstanceMsDeployStatus ... -func (c WebAppsClient) GetInstanceMsDeployStatus(ctx context.Context, id InstanceId) (result GetInstanceMsDeployStatusOperationResponse, err error) { - req, err := c.preparerForGetInstanceMsDeployStatus(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetInstanceMsDeployStatus", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetInstanceMsDeployStatus", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetInstanceMsDeployStatus(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetInstanceMsDeployStatus", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetInstanceMsDeployStatus prepares the GetInstanceMsDeployStatus request. -func (c WebAppsClient) preparerForGetInstanceMsDeployStatus(ctx context.Context, id InstanceId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/extensions/mSDeploy", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetInstanceMsDeployStatus handles the response to the GetInstanceMsDeployStatus request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetInstanceMsDeployStatus(resp *http.Response) (result GetInstanceMsDeployStatusOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getinstancemsdeploystatusslot.go b/resource-manager/web/2022-09-01/webapps/method_getinstancemsdeploystatusslot.go new file mode 100644 index 00000000000..b0cebb93d7a --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getinstancemsdeploystatusslot.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetInstanceMsDeployStatusSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MSDeployStatus +} + +// GetInstanceMsDeployStatusSlot ... +func (c WebAppsClient) GetInstanceMsDeployStatusSlot(ctx context.Context, id SlotInstanceId) (result GetInstanceMsDeployStatusSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/extensions/mSDeploy", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getinstancemsdeploystatusslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getinstancemsdeploystatusslot_autorest.go deleted file mode 100644 index 16e04cd3959..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getinstancemsdeploystatusslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetInstanceMsDeployStatusSlotOperationResponse struct { - HttpResponse *http.Response - Model *MSDeployStatus -} - -// GetInstanceMsDeployStatusSlot ... -func (c WebAppsClient) GetInstanceMsDeployStatusSlot(ctx context.Context, id SlotInstanceId) (result GetInstanceMsDeployStatusSlotOperationResponse, err error) { - req, err := c.preparerForGetInstanceMsDeployStatusSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetInstanceMsDeployStatusSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetInstanceMsDeployStatusSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetInstanceMsDeployStatusSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetInstanceMsDeployStatusSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetInstanceMsDeployStatusSlot prepares the GetInstanceMsDeployStatusSlot request. -func (c WebAppsClient) preparerForGetInstanceMsDeployStatusSlot(ctx context.Context, id SlotInstanceId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/extensions/mSDeploy", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetInstanceMsDeployStatusSlot handles the response to the GetInstanceMsDeployStatusSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetInstanceMsDeployStatusSlot(resp *http.Response) (result GetInstanceMsDeployStatusSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getinstanceprocess.go b/resource-manager/web/2022-09-01/webapps/method_getinstanceprocess.go new file mode 100644 index 00000000000..f490bb11cb4 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getinstanceprocess.go @@ -0,0 +1,51 @@ +package webapps + +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 GetInstanceProcessOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ProcessInfo +} + +// GetInstanceProcess ... +func (c WebAppsClient) GetInstanceProcess(ctx context.Context, id InstanceProcessId) (result GetInstanceProcessOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getinstanceprocess_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getinstanceprocess_autorest.go deleted file mode 100644 index 0c8d68e42da..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getinstanceprocess_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetInstanceProcessOperationResponse struct { - HttpResponse *http.Response - Model *ProcessInfo -} - -// GetInstanceProcess ... -func (c WebAppsClient) GetInstanceProcess(ctx context.Context, id InstanceProcessId) (result GetInstanceProcessOperationResponse, err error) { - req, err := c.preparerForGetInstanceProcess(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetInstanceProcess", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetInstanceProcess", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetInstanceProcess(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetInstanceProcess", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetInstanceProcess prepares the GetInstanceProcess request. -func (c WebAppsClient) preparerForGetInstanceProcess(ctx context.Context, id InstanceProcessId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetInstanceProcess handles the response to the GetInstanceProcess request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetInstanceProcess(resp *http.Response) (result GetInstanceProcessOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getinstanceprocessdump.go b/resource-manager/web/2022-09-01/webapps/method_getinstanceprocessdump.go new file mode 100644 index 00000000000..19b050d7504 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getinstanceprocessdump.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetInstanceProcessDumpOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]byte +} + +// GetInstanceProcessDump ... +func (c WebAppsClient) GetInstanceProcessDump(ctx context.Context, id InstanceProcessId) (result GetInstanceProcessDumpOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/dump", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getinstanceprocessdump_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getinstanceprocessdump_autorest.go deleted file mode 100644 index d08c9080132..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getinstanceprocessdump_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetInstanceProcessDumpOperationResponse struct { - HttpResponse *http.Response - Model *[]byte -} - -// GetInstanceProcessDump ... -func (c WebAppsClient) GetInstanceProcessDump(ctx context.Context, id InstanceProcessId) (result GetInstanceProcessDumpOperationResponse, err error) { - req, err := c.preparerForGetInstanceProcessDump(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetInstanceProcessDump", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetInstanceProcessDump", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetInstanceProcessDump(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetInstanceProcessDump", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetInstanceProcessDump prepares the GetInstanceProcessDump request. -func (c WebAppsClient) preparerForGetInstanceProcessDump(ctx context.Context, id InstanceProcessId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/dump", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetInstanceProcessDump handles the response to the GetInstanceProcessDump request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetInstanceProcessDump(resp *http.Response) (result GetInstanceProcessDumpOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getinstanceprocessdumpslot.go b/resource-manager/web/2022-09-01/webapps/method_getinstanceprocessdumpslot.go new file mode 100644 index 00000000000..f31255142a8 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getinstanceprocessdumpslot.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetInstanceProcessDumpSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]byte +} + +// GetInstanceProcessDumpSlot ... +func (c WebAppsClient) GetInstanceProcessDumpSlot(ctx context.Context, id SlotInstanceProcessId) (result GetInstanceProcessDumpSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/dump", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getinstanceprocessdumpslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getinstanceprocessdumpslot_autorest.go deleted file mode 100644 index 459cbbf54de..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getinstanceprocessdumpslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetInstanceProcessDumpSlotOperationResponse struct { - HttpResponse *http.Response - Model *[]byte -} - -// GetInstanceProcessDumpSlot ... -func (c WebAppsClient) GetInstanceProcessDumpSlot(ctx context.Context, id SlotInstanceProcessId) (result GetInstanceProcessDumpSlotOperationResponse, err error) { - req, err := c.preparerForGetInstanceProcessDumpSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetInstanceProcessDumpSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetInstanceProcessDumpSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetInstanceProcessDumpSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetInstanceProcessDumpSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetInstanceProcessDumpSlot prepares the GetInstanceProcessDumpSlot request. -func (c WebAppsClient) preparerForGetInstanceProcessDumpSlot(ctx context.Context, id SlotInstanceProcessId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/dump", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetInstanceProcessDumpSlot handles the response to the GetInstanceProcessDumpSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetInstanceProcessDumpSlot(resp *http.Response) (result GetInstanceProcessDumpSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getinstanceprocessmodule.go b/resource-manager/web/2022-09-01/webapps/method_getinstanceprocessmodule.go new file mode 100644 index 00000000000..efa5336d74f --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getinstanceprocessmodule.go @@ -0,0 +1,51 @@ +package webapps + +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 GetInstanceProcessModuleOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ProcessModuleInfo +} + +// GetInstanceProcessModule ... +func (c WebAppsClient) GetInstanceProcessModule(ctx context.Context, id InstanceProcessModuleId) (result GetInstanceProcessModuleOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getinstanceprocessmodule_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getinstanceprocessmodule_autorest.go deleted file mode 100644 index 8c2655ee147..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getinstanceprocessmodule_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetInstanceProcessModuleOperationResponse struct { - HttpResponse *http.Response - Model *ProcessModuleInfo -} - -// GetInstanceProcessModule ... -func (c WebAppsClient) GetInstanceProcessModule(ctx context.Context, id InstanceProcessModuleId) (result GetInstanceProcessModuleOperationResponse, err error) { - req, err := c.preparerForGetInstanceProcessModule(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetInstanceProcessModule", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetInstanceProcessModule", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetInstanceProcessModule(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetInstanceProcessModule", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetInstanceProcessModule prepares the GetInstanceProcessModule request. -func (c WebAppsClient) preparerForGetInstanceProcessModule(ctx context.Context, id InstanceProcessModuleId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetInstanceProcessModule handles the response to the GetInstanceProcessModule request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetInstanceProcessModule(resp *http.Response) (result GetInstanceProcessModuleOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getinstanceprocessmoduleslot.go b/resource-manager/web/2022-09-01/webapps/method_getinstanceprocessmoduleslot.go new file mode 100644 index 00000000000..49726fee91f --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getinstanceprocessmoduleslot.go @@ -0,0 +1,51 @@ +package webapps + +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 GetInstanceProcessModuleSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ProcessModuleInfo +} + +// GetInstanceProcessModuleSlot ... +func (c WebAppsClient) GetInstanceProcessModuleSlot(ctx context.Context, id SlotInstanceProcessModuleId) (result GetInstanceProcessModuleSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getinstanceprocessmoduleslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getinstanceprocessmoduleslot_autorest.go deleted file mode 100644 index 99483c3b7f4..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getinstanceprocessmoduleslot_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetInstanceProcessModuleSlotOperationResponse struct { - HttpResponse *http.Response - Model *ProcessModuleInfo -} - -// GetInstanceProcessModuleSlot ... -func (c WebAppsClient) GetInstanceProcessModuleSlot(ctx context.Context, id SlotInstanceProcessModuleId) (result GetInstanceProcessModuleSlotOperationResponse, err error) { - req, err := c.preparerForGetInstanceProcessModuleSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetInstanceProcessModuleSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetInstanceProcessModuleSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetInstanceProcessModuleSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetInstanceProcessModuleSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetInstanceProcessModuleSlot prepares the GetInstanceProcessModuleSlot request. -func (c WebAppsClient) preparerForGetInstanceProcessModuleSlot(ctx context.Context, id SlotInstanceProcessModuleId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetInstanceProcessModuleSlot handles the response to the GetInstanceProcessModuleSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetInstanceProcessModuleSlot(resp *http.Response) (result GetInstanceProcessModuleSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getinstanceprocessslot.go b/resource-manager/web/2022-09-01/webapps/method_getinstanceprocessslot.go new file mode 100644 index 00000000000..5330b4b07a7 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getinstanceprocessslot.go @@ -0,0 +1,51 @@ +package webapps + +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 GetInstanceProcessSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ProcessInfo +} + +// GetInstanceProcessSlot ... +func (c WebAppsClient) GetInstanceProcessSlot(ctx context.Context, id SlotInstanceProcessId) (result GetInstanceProcessSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getinstanceprocessslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getinstanceprocessslot_autorest.go deleted file mode 100644 index 45a3f389c01..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getinstanceprocessslot_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetInstanceProcessSlotOperationResponse struct { - HttpResponse *http.Response - Model *ProcessInfo -} - -// GetInstanceProcessSlot ... -func (c WebAppsClient) GetInstanceProcessSlot(ctx context.Context, id SlotInstanceProcessId) (result GetInstanceProcessSlotOperationResponse, err error) { - req, err := c.preparerForGetInstanceProcessSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetInstanceProcessSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetInstanceProcessSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetInstanceProcessSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetInstanceProcessSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetInstanceProcessSlot prepares the GetInstanceProcessSlot request. -func (c WebAppsClient) preparerForGetInstanceProcessSlot(ctx context.Context, id SlotInstanceProcessId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetInstanceProcessSlot handles the response to the GetInstanceProcessSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetInstanceProcessSlot(resp *http.Response) (result GetInstanceProcessSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getinstanceworkflowslot.go b/resource-manager/web/2022-09-01/webapps/method_getinstanceworkflowslot.go new file mode 100644 index 00000000000..0c54f10cad7 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getinstanceworkflowslot.go @@ -0,0 +1,51 @@ +package webapps + +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 GetInstanceWorkflowSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkflowEnvelope +} + +// GetInstanceWorkflowSlot ... +func (c WebAppsClient) GetInstanceWorkflowSlot(ctx context.Context, id SlotWorkflowId) (result GetInstanceWorkflowSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getinstanceworkflowslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getinstanceworkflowslot_autorest.go deleted file mode 100644 index 2f60864e038..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getinstanceworkflowslot_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetInstanceWorkflowSlotOperationResponse struct { - HttpResponse *http.Response - Model *WorkflowEnvelope -} - -// GetInstanceWorkflowSlot ... -func (c WebAppsClient) GetInstanceWorkflowSlot(ctx context.Context, id SlotWorkflowId) (result GetInstanceWorkflowSlotOperationResponse, err error) { - req, err := c.preparerForGetInstanceWorkflowSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetInstanceWorkflowSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetInstanceWorkflowSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetInstanceWorkflowSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetInstanceWorkflowSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetInstanceWorkflowSlot prepares the GetInstanceWorkflowSlot request. -func (c WebAppsClient) preparerForGetInstanceWorkflowSlot(ctx context.Context, id SlotWorkflowId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetInstanceWorkflowSlot handles the response to the GetInstanceWorkflowSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetInstanceWorkflowSlot(resp *http.Response) (result GetInstanceWorkflowSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getmigratemysqlstatus.go b/resource-manager/web/2022-09-01/webapps/method_getmigratemysqlstatus.go new file mode 100644 index 00000000000..937496a7811 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getmigratemysqlstatus.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetMigrateMySqlStatusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MigrateMySqlStatus +} + +// GetMigrateMySqlStatus ... +func (c WebAppsClient) GetMigrateMySqlStatus(ctx context.Context, id SiteId) (result GetMigrateMySqlStatusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/migrateMySql/status", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getmigratemysqlstatus_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getmigratemysqlstatus_autorest.go deleted file mode 100644 index 95059ed3002..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getmigratemysqlstatus_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetMigrateMySqlStatusOperationResponse struct { - HttpResponse *http.Response - Model *MigrateMySqlStatus -} - -// GetMigrateMySqlStatus ... -func (c WebAppsClient) GetMigrateMySqlStatus(ctx context.Context, id SiteId) (result GetMigrateMySqlStatusOperationResponse, err error) { - req, err := c.preparerForGetMigrateMySqlStatus(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetMigrateMySqlStatus", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetMigrateMySqlStatus", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetMigrateMySqlStatus(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetMigrateMySqlStatus", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetMigrateMySqlStatus prepares the GetMigrateMySqlStatus request. -func (c WebAppsClient) preparerForGetMigrateMySqlStatus(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/migrateMySql/status", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetMigrateMySqlStatus handles the response to the GetMigrateMySqlStatus request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetMigrateMySqlStatus(resp *http.Response) (result GetMigrateMySqlStatusOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getmigratemysqlstatusslot.go b/resource-manager/web/2022-09-01/webapps/method_getmigratemysqlstatusslot.go new file mode 100644 index 00000000000..6ce9397b86d --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getmigratemysqlstatusslot.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetMigrateMySqlStatusSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MigrateMySqlStatus +} + +// GetMigrateMySqlStatusSlot ... +func (c WebAppsClient) GetMigrateMySqlStatusSlot(ctx context.Context, id SlotId) (result GetMigrateMySqlStatusSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/migrateMySql/status", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getmigratemysqlstatusslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getmigratemysqlstatusslot_autorest.go deleted file mode 100644 index 2b52c486f47..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getmigratemysqlstatusslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetMigrateMySqlStatusSlotOperationResponse struct { - HttpResponse *http.Response - Model *MigrateMySqlStatus -} - -// GetMigrateMySqlStatusSlot ... -func (c WebAppsClient) GetMigrateMySqlStatusSlot(ctx context.Context, id SlotId) (result GetMigrateMySqlStatusSlotOperationResponse, err error) { - req, err := c.preparerForGetMigrateMySqlStatusSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetMigrateMySqlStatusSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetMigrateMySqlStatusSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetMigrateMySqlStatusSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetMigrateMySqlStatusSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetMigrateMySqlStatusSlot prepares the GetMigrateMySqlStatusSlot request. -func (c WebAppsClient) preparerForGetMigrateMySqlStatusSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/migrateMySql/status", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetMigrateMySqlStatusSlot handles the response to the GetMigrateMySqlStatusSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetMigrateMySqlStatusSlot(resp *http.Response) (result GetMigrateMySqlStatusSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getmsdeploylog.go b/resource-manager/web/2022-09-01/webapps/method_getmsdeploylog.go new file mode 100644 index 00000000000..c0d6ed6d420 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getmsdeploylog.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetMSDeployLogOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MSDeployLog +} + +// GetMSDeployLog ... +func (c WebAppsClient) GetMSDeployLog(ctx context.Context, id SiteId) (result GetMSDeployLogOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/extensions/mSDeploy/log", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getmsdeploylog_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getmsdeploylog_autorest.go deleted file mode 100644 index f7ad0f744b7..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getmsdeploylog_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetMSDeployLogOperationResponse struct { - HttpResponse *http.Response - Model *MSDeployLog -} - -// GetMSDeployLog ... -func (c WebAppsClient) GetMSDeployLog(ctx context.Context, id SiteId) (result GetMSDeployLogOperationResponse, err error) { - req, err := c.preparerForGetMSDeployLog(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetMSDeployLog", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetMSDeployLog", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetMSDeployLog(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetMSDeployLog", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetMSDeployLog prepares the GetMSDeployLog request. -func (c WebAppsClient) preparerForGetMSDeployLog(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/extensions/mSDeploy/log", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetMSDeployLog handles the response to the GetMSDeployLog request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetMSDeployLog(resp *http.Response) (result GetMSDeployLogOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getmsdeploylogslot.go b/resource-manager/web/2022-09-01/webapps/method_getmsdeploylogslot.go new file mode 100644 index 00000000000..3b6edd029cb --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getmsdeploylogslot.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetMSDeployLogSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MSDeployLog +} + +// GetMSDeployLogSlot ... +func (c WebAppsClient) GetMSDeployLogSlot(ctx context.Context, id SlotId) (result GetMSDeployLogSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/extensions/mSDeploy/log", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getmsdeploylogslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getmsdeploylogslot_autorest.go deleted file mode 100644 index 6db091b233f..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getmsdeploylogslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetMSDeployLogSlotOperationResponse struct { - HttpResponse *http.Response - Model *MSDeployLog -} - -// GetMSDeployLogSlot ... -func (c WebAppsClient) GetMSDeployLogSlot(ctx context.Context, id SlotId) (result GetMSDeployLogSlotOperationResponse, err error) { - req, err := c.preparerForGetMSDeployLogSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetMSDeployLogSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetMSDeployLogSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetMSDeployLogSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetMSDeployLogSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetMSDeployLogSlot prepares the GetMSDeployLogSlot request. -func (c WebAppsClient) preparerForGetMSDeployLogSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/extensions/mSDeploy/log", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetMSDeployLogSlot handles the response to the GetMSDeployLogSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetMSDeployLogSlot(resp *http.Response) (result GetMSDeployLogSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getmsdeploystatus.go b/resource-manager/web/2022-09-01/webapps/method_getmsdeploystatus.go new file mode 100644 index 00000000000..b8780da1693 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getmsdeploystatus.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetMSDeployStatusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MSDeployStatus +} + +// GetMSDeployStatus ... +func (c WebAppsClient) GetMSDeployStatus(ctx context.Context, id SiteId) (result GetMSDeployStatusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/extensions/mSDeploy", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getmsdeploystatus_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getmsdeploystatus_autorest.go deleted file mode 100644 index 943554106af..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getmsdeploystatus_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetMSDeployStatusOperationResponse struct { - HttpResponse *http.Response - Model *MSDeployStatus -} - -// GetMSDeployStatus ... -func (c WebAppsClient) GetMSDeployStatus(ctx context.Context, id SiteId) (result GetMSDeployStatusOperationResponse, err error) { - req, err := c.preparerForGetMSDeployStatus(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetMSDeployStatus", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetMSDeployStatus", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetMSDeployStatus(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetMSDeployStatus", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetMSDeployStatus prepares the GetMSDeployStatus request. -func (c WebAppsClient) preparerForGetMSDeployStatus(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/extensions/mSDeploy", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetMSDeployStatus handles the response to the GetMSDeployStatus request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetMSDeployStatus(resp *http.Response) (result GetMSDeployStatusOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getmsdeploystatusslot.go b/resource-manager/web/2022-09-01/webapps/method_getmsdeploystatusslot.go new file mode 100644 index 00000000000..369a7ed15e1 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getmsdeploystatusslot.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetMSDeployStatusSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MSDeployStatus +} + +// GetMSDeployStatusSlot ... +func (c WebAppsClient) GetMSDeployStatusSlot(ctx context.Context, id SlotId) (result GetMSDeployStatusSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/extensions/mSDeploy", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getmsdeploystatusslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getmsdeploystatusslot_autorest.go deleted file mode 100644 index 870858b17d4..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getmsdeploystatusslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetMSDeployStatusSlotOperationResponse struct { - HttpResponse *http.Response - Model *MSDeployStatus -} - -// GetMSDeployStatusSlot ... -func (c WebAppsClient) GetMSDeployStatusSlot(ctx context.Context, id SlotId) (result GetMSDeployStatusSlotOperationResponse, err error) { - req, err := c.preparerForGetMSDeployStatusSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetMSDeployStatusSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetMSDeployStatusSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetMSDeployStatusSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetMSDeployStatusSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetMSDeployStatusSlot prepares the GetMSDeployStatusSlot request. -func (c WebAppsClient) preparerForGetMSDeployStatusSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/extensions/mSDeploy", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetMSDeployStatusSlot handles the response to the GetMSDeployStatusSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetMSDeployStatusSlot(resp *http.Response) (result GetMSDeployStatusSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getnetworktraces.go b/resource-manager/web/2022-09-01/webapps/method_getnetworktraces.go new file mode 100644 index 00000000000..952c3898199 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getnetworktraces.go @@ -0,0 +1,51 @@ +package webapps + +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 GetNetworkTracesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkTrace +} + +// GetNetworkTraces ... +func (c WebAppsClient) GetNetworkTraces(ctx context.Context, id NetworkTraceId) (result GetNetworkTracesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getnetworktraces_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getnetworktraces_autorest.go deleted file mode 100644 index 5beacb98cbc..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getnetworktraces_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetNetworkTracesOperationResponse struct { - HttpResponse *http.Response - Model *[]NetworkTrace -} - -// GetNetworkTraces ... -func (c WebAppsClient) GetNetworkTraces(ctx context.Context, id NetworkTraceId) (result GetNetworkTracesOperationResponse, err error) { - req, err := c.preparerForGetNetworkTraces(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetNetworkTraces", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetNetworkTraces", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetNetworkTraces(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetNetworkTraces", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetNetworkTraces prepares the GetNetworkTraces request. -func (c WebAppsClient) preparerForGetNetworkTraces(ctx context.Context, id NetworkTraceId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetNetworkTraces handles the response to the GetNetworkTraces request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetNetworkTraces(resp *http.Response) (result GetNetworkTracesOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getnetworktracesslot.go b/resource-manager/web/2022-09-01/webapps/method_getnetworktracesslot.go new file mode 100644 index 00000000000..ad96c58824b --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getnetworktracesslot.go @@ -0,0 +1,51 @@ +package webapps + +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 GetNetworkTracesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkTrace +} + +// GetNetworkTracesSlot ... +func (c WebAppsClient) GetNetworkTracesSlot(ctx context.Context, id SlotNetworkTraceId) (result GetNetworkTracesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getnetworktracesslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getnetworktracesslot_autorest.go deleted file mode 100644 index 7e05b0a6e58..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getnetworktracesslot_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetNetworkTracesSlotOperationResponse struct { - HttpResponse *http.Response - Model *[]NetworkTrace -} - -// GetNetworkTracesSlot ... -func (c WebAppsClient) GetNetworkTracesSlot(ctx context.Context, id SlotNetworkTraceId) (result GetNetworkTracesSlotOperationResponse, err error) { - req, err := c.preparerForGetNetworkTracesSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetNetworkTracesSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetNetworkTracesSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetNetworkTracesSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetNetworkTracesSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetNetworkTracesSlot prepares the GetNetworkTracesSlot request. -func (c WebAppsClient) preparerForGetNetworkTracesSlot(ctx context.Context, id SlotNetworkTraceId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetNetworkTracesSlot handles the response to the GetNetworkTracesSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetNetworkTracesSlot(resp *http.Response) (result GetNetworkTracesSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getnetworktracesslotv2.go b/resource-manager/web/2022-09-01/webapps/method_getnetworktracesslotv2.go new file mode 100644 index 00000000000..21e9b35a3d0 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getnetworktracesslotv2.go @@ -0,0 +1,51 @@ +package webapps + +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 GetNetworkTracesSlotV2OperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkTrace +} + +// GetNetworkTracesSlotV2 ... +func (c WebAppsClient) GetNetworkTracesSlotV2(ctx context.Context, id SiteSlotNetworkTraceId) (result GetNetworkTracesSlotV2OperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getnetworktracesslotv2_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getnetworktracesslotv2_autorest.go deleted file mode 100644 index 8fc3e97c607..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getnetworktracesslotv2_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetNetworkTracesSlotV2OperationResponse struct { - HttpResponse *http.Response - Model *[]NetworkTrace -} - -// GetNetworkTracesSlotV2 ... -func (c WebAppsClient) GetNetworkTracesSlotV2(ctx context.Context, id SiteSlotNetworkTraceId) (result GetNetworkTracesSlotV2OperationResponse, err error) { - req, err := c.preparerForGetNetworkTracesSlotV2(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetNetworkTracesSlotV2", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetNetworkTracesSlotV2", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetNetworkTracesSlotV2(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetNetworkTracesSlotV2", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetNetworkTracesSlotV2 prepares the GetNetworkTracesSlotV2 request. -func (c WebAppsClient) preparerForGetNetworkTracesSlotV2(ctx context.Context, id SiteSlotNetworkTraceId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetNetworkTracesSlotV2 handles the response to the GetNetworkTracesSlotV2 request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetNetworkTracesSlotV2(resp *http.Response) (result GetNetworkTracesSlotV2OperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getnetworktracesv2.go b/resource-manager/web/2022-09-01/webapps/method_getnetworktracesv2.go new file mode 100644 index 00000000000..8cce4e8d0aa --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getnetworktracesv2.go @@ -0,0 +1,51 @@ +package webapps + +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 GetNetworkTracesV2OperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkTrace +} + +// GetNetworkTracesV2 ... +func (c WebAppsClient) GetNetworkTracesV2(ctx context.Context, id SiteNetworkTraceId) (result GetNetworkTracesV2OperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getnetworktracesv2_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getnetworktracesv2_autorest.go deleted file mode 100644 index 9290c7dd70e..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getnetworktracesv2_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetNetworkTracesV2OperationResponse struct { - HttpResponse *http.Response - Model *[]NetworkTrace -} - -// GetNetworkTracesV2 ... -func (c WebAppsClient) GetNetworkTracesV2(ctx context.Context, id SiteNetworkTraceId) (result GetNetworkTracesV2OperationResponse, err error) { - req, err := c.preparerForGetNetworkTracesV2(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetNetworkTracesV2", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetNetworkTracesV2", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetNetworkTracesV2(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetNetworkTracesV2", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetNetworkTracesV2 prepares the GetNetworkTracesV2 request. -func (c WebAppsClient) preparerForGetNetworkTracesV2(ctx context.Context, id SiteNetworkTraceId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetNetworkTracesV2 handles the response to the GetNetworkTracesV2 request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetNetworkTracesV2(resp *http.Response) (result GetNetworkTracesV2OperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getonedeploystatus.go b/resource-manager/web/2022-09-01/webapps/method_getonedeploystatus.go new file mode 100644 index 00000000000..df9bc54f2f8 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getonedeploystatus.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetOneDeployStatusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *interface{} +} + +// GetOneDeployStatus ... +func (c WebAppsClient) GetOneDeployStatus(ctx context.Context, id SiteId) (result GetOneDeployStatusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/extensions/onedeploy", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getonedeploystatus_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getonedeploystatus_autorest.go deleted file mode 100644 index 3f19deb2c2c..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getonedeploystatus_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOneDeployStatusOperationResponse struct { - HttpResponse *http.Response - Model *interface{} -} - -// GetOneDeployStatus ... -func (c WebAppsClient) GetOneDeployStatus(ctx context.Context, id SiteId) (result GetOneDeployStatusOperationResponse, err error) { - req, err := c.preparerForGetOneDeployStatus(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetOneDeployStatus", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetOneDeployStatus", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetOneDeployStatus(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetOneDeployStatus", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetOneDeployStatus prepares the GetOneDeployStatus request. -func (c WebAppsClient) preparerForGetOneDeployStatus(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/extensions/onedeploy", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetOneDeployStatus handles the response to the GetOneDeployStatus request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetOneDeployStatus(resp *http.Response) (result GetOneDeployStatusOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getpremieraddon.go b/resource-manager/web/2022-09-01/webapps/method_getpremieraddon.go new file mode 100644 index 00000000000..da2e1380337 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getpremieraddon.go @@ -0,0 +1,51 @@ +package webapps + +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 GetPremierAddOnOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PremierAddOn +} + +// GetPremierAddOn ... +func (c WebAppsClient) GetPremierAddOn(ctx context.Context, id PremierAddonId) (result GetPremierAddOnOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getpremieraddon_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getpremieraddon_autorest.go deleted file mode 100644 index 946b8c52971..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getpremieraddon_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetPremierAddOnOperationResponse struct { - HttpResponse *http.Response - Model *PremierAddOn -} - -// GetPremierAddOn ... -func (c WebAppsClient) GetPremierAddOn(ctx context.Context, id PremierAddonId) (result GetPremierAddOnOperationResponse, err error) { - req, err := c.preparerForGetPremierAddOn(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetPremierAddOn", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetPremierAddOn", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetPremierAddOn(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetPremierAddOn", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetPremierAddOn prepares the GetPremierAddOn request. -func (c WebAppsClient) preparerForGetPremierAddOn(ctx context.Context, id PremierAddonId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetPremierAddOn handles the response to the GetPremierAddOn request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetPremierAddOn(resp *http.Response) (result GetPremierAddOnOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getpremieraddonslot.go b/resource-manager/web/2022-09-01/webapps/method_getpremieraddonslot.go new file mode 100644 index 00000000000..b53a6a5e128 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getpremieraddonslot.go @@ -0,0 +1,51 @@ +package webapps + +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 GetPremierAddOnSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PremierAddOn +} + +// GetPremierAddOnSlot ... +func (c WebAppsClient) GetPremierAddOnSlot(ctx context.Context, id SlotPremierAddonId) (result GetPremierAddOnSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getpremieraddonslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getpremieraddonslot_autorest.go deleted file mode 100644 index 5859f073072..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getpremieraddonslot_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetPremierAddOnSlotOperationResponse struct { - HttpResponse *http.Response - Model *PremierAddOn -} - -// GetPremierAddOnSlot ... -func (c WebAppsClient) GetPremierAddOnSlot(ctx context.Context, id SlotPremierAddonId) (result GetPremierAddOnSlotOperationResponse, err error) { - req, err := c.preparerForGetPremierAddOnSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetPremierAddOnSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetPremierAddOnSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetPremierAddOnSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetPremierAddOnSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetPremierAddOnSlot prepares the GetPremierAddOnSlot request. -func (c WebAppsClient) preparerForGetPremierAddOnSlot(ctx context.Context, id SlotPremierAddonId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetPremierAddOnSlot handles the response to the GetPremierAddOnSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetPremierAddOnSlot(resp *http.Response) (result GetPremierAddOnSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getprivateaccess.go b/resource-manager/web/2022-09-01/webapps/method_getprivateaccess.go new file mode 100644 index 00000000000..7769a83101a --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getprivateaccess.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetPrivateAccessOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateAccess +} + +// GetPrivateAccess ... +func (c WebAppsClient) GetPrivateAccess(ctx context.Context, id SiteId) (result GetPrivateAccessOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateAccess/virtualNetworks", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getprivateaccess_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getprivateaccess_autorest.go deleted file mode 100644 index 2d9aa3af2a0..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getprivateaccess_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetPrivateAccessOperationResponse struct { - HttpResponse *http.Response - Model *PrivateAccess -} - -// GetPrivateAccess ... -func (c WebAppsClient) GetPrivateAccess(ctx context.Context, id SiteId) (result GetPrivateAccessOperationResponse, err error) { - req, err := c.preparerForGetPrivateAccess(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetPrivateAccess", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetPrivateAccess", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetPrivateAccess(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetPrivateAccess", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetPrivateAccess prepares the GetPrivateAccess request. -func (c WebAppsClient) preparerForGetPrivateAccess(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/privateAccess/virtualNetworks", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetPrivateAccess handles the response to the GetPrivateAccess request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetPrivateAccess(resp *http.Response) (result GetPrivateAccessOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getprivateaccessslot.go b/resource-manager/web/2022-09-01/webapps/method_getprivateaccessslot.go new file mode 100644 index 00000000000..b9ae736edc4 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getprivateaccessslot.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetPrivateAccessSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateAccess +} + +// GetPrivateAccessSlot ... +func (c WebAppsClient) GetPrivateAccessSlot(ctx context.Context, id SlotId) (result GetPrivateAccessSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateAccess/virtualNetworks", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getprivateaccessslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getprivateaccessslot_autorest.go deleted file mode 100644 index 2f6aad9d6f0..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getprivateaccessslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetPrivateAccessSlotOperationResponse struct { - HttpResponse *http.Response - Model *PrivateAccess -} - -// GetPrivateAccessSlot ... -func (c WebAppsClient) GetPrivateAccessSlot(ctx context.Context, id SlotId) (result GetPrivateAccessSlotOperationResponse, err error) { - req, err := c.preparerForGetPrivateAccessSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetPrivateAccessSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetPrivateAccessSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetPrivateAccessSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetPrivateAccessSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetPrivateAccessSlot prepares the GetPrivateAccessSlot request. -func (c WebAppsClient) preparerForGetPrivateAccessSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/privateAccess/virtualNetworks", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetPrivateAccessSlot handles the response to the GetPrivateAccessSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetPrivateAccessSlot(resp *http.Response) (result GetPrivateAccessSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getprivateendpointconnection.go b/resource-manager/web/2022-09-01/webapps/method_getprivateendpointconnection.go new file mode 100644 index 00000000000..646db656df7 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getprivateendpointconnection.go @@ -0,0 +1,51 @@ +package webapps + +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 GetPrivateEndpointConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RemotePrivateEndpointConnectionARMResource +} + +// GetPrivateEndpointConnection ... +func (c WebAppsClient) GetPrivateEndpointConnection(ctx context.Context, id PrivateEndpointConnectionId) (result GetPrivateEndpointConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getprivateendpointconnection_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getprivateendpointconnection_autorest.go deleted file mode 100644 index 8674ce63672..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getprivateendpointconnection_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetPrivateEndpointConnectionOperationResponse struct { - HttpResponse *http.Response - Model *RemotePrivateEndpointConnectionARMResource -} - -// GetPrivateEndpointConnection ... -func (c WebAppsClient) GetPrivateEndpointConnection(ctx context.Context, id PrivateEndpointConnectionId) (result GetPrivateEndpointConnectionOperationResponse, err error) { - req, err := c.preparerForGetPrivateEndpointConnection(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetPrivateEndpointConnection", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetPrivateEndpointConnection", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetPrivateEndpointConnection(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetPrivateEndpointConnection", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetPrivateEndpointConnection prepares the GetPrivateEndpointConnection request. -func (c WebAppsClient) preparerForGetPrivateEndpointConnection(ctx context.Context, id PrivateEndpointConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetPrivateEndpointConnection handles the response to the GetPrivateEndpointConnection request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetPrivateEndpointConnection(resp *http.Response) (result GetPrivateEndpointConnectionOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getprivateendpointconnectionlist.go b/resource-manager/web/2022-09-01/webapps/method_getprivateendpointconnectionlist.go new file mode 100644 index 00000000000..9f9ec750637 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getprivateendpointconnectionlist.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetPrivateEndpointConnectionListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RemotePrivateEndpointConnectionARMResource +} + +type GetPrivateEndpointConnectionListCompleteResult struct { + Items []RemotePrivateEndpointConnectionARMResource +} + +// GetPrivateEndpointConnectionList ... +func (c WebAppsClient) GetPrivateEndpointConnectionList(ctx context.Context, id SiteId) (result GetPrivateEndpointConnectionListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateEndpointConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]RemotePrivateEndpointConnectionARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetPrivateEndpointConnectionListComplete retrieves all the results into a single object +func (c WebAppsClient) GetPrivateEndpointConnectionListComplete(ctx context.Context, id SiteId) (GetPrivateEndpointConnectionListCompleteResult, error) { + return c.GetPrivateEndpointConnectionListCompleteMatchingPredicate(ctx, id, RemotePrivateEndpointConnectionARMResourceOperationPredicate{}) +} + +// GetPrivateEndpointConnectionListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) GetPrivateEndpointConnectionListCompleteMatchingPredicate(ctx context.Context, id SiteId, predicate RemotePrivateEndpointConnectionARMResourceOperationPredicate) (result GetPrivateEndpointConnectionListCompleteResult, err error) { + items := make([]RemotePrivateEndpointConnectionARMResource, 0) + + resp, err := c.GetPrivateEndpointConnectionList(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetPrivateEndpointConnectionListCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getprivateendpointconnectionlist_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getprivateendpointconnectionlist_autorest.go deleted file mode 100644 index ae44ade4fbf..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getprivateendpointconnectionlist_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetPrivateEndpointConnectionListOperationResponse struct { - HttpResponse *http.Response - Model *[]RemotePrivateEndpointConnectionARMResource - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (GetPrivateEndpointConnectionListOperationResponse, error) -} - -type GetPrivateEndpointConnectionListCompleteResult struct { - Items []RemotePrivateEndpointConnectionARMResource -} - -func (r GetPrivateEndpointConnectionListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r GetPrivateEndpointConnectionListOperationResponse) LoadMore(ctx context.Context) (resp GetPrivateEndpointConnectionListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// GetPrivateEndpointConnectionList ... -func (c WebAppsClient) GetPrivateEndpointConnectionList(ctx context.Context, id SiteId) (resp GetPrivateEndpointConnectionListOperationResponse, err error) { - req, err := c.preparerForGetPrivateEndpointConnectionList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetPrivateEndpointConnectionList", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetPrivateEndpointConnectionList", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForGetPrivateEndpointConnectionList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetPrivateEndpointConnectionList", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForGetPrivateEndpointConnectionList prepares the GetPrivateEndpointConnectionList request. -func (c WebAppsClient) preparerForGetPrivateEndpointConnectionList(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/privateEndpointConnections", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForGetPrivateEndpointConnectionListWithNextLink prepares the GetPrivateEndpointConnectionList request with the given nextLink token. -func (c WebAppsClient) preparerForGetPrivateEndpointConnectionListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetPrivateEndpointConnectionList handles the response to the GetPrivateEndpointConnectionList request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetPrivateEndpointConnectionList(resp *http.Response) (result GetPrivateEndpointConnectionListOperationResponse, err error) { - type page struct { - Values []RemotePrivateEndpointConnectionARMResource `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result GetPrivateEndpointConnectionListOperationResponse, err error) { - req, err := c.preparerForGetPrivateEndpointConnectionListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetPrivateEndpointConnectionList", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetPrivateEndpointConnectionList", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetPrivateEndpointConnectionList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetPrivateEndpointConnectionList", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// GetPrivateEndpointConnectionListComplete retrieves all of the results into a single object -func (c WebAppsClient) GetPrivateEndpointConnectionListComplete(ctx context.Context, id SiteId) (GetPrivateEndpointConnectionListCompleteResult, error) { - return c.GetPrivateEndpointConnectionListCompleteMatchingPredicate(ctx, id, RemotePrivateEndpointConnectionARMResourceOperationPredicate{}) -} - -// GetPrivateEndpointConnectionListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) GetPrivateEndpointConnectionListCompleteMatchingPredicate(ctx context.Context, id SiteId, predicate RemotePrivateEndpointConnectionARMResourceOperationPredicate) (resp GetPrivateEndpointConnectionListCompleteResult, err error) { - items := make([]RemotePrivateEndpointConnectionARMResource, 0) - - page, err := c.GetPrivateEndpointConnectionList(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := GetPrivateEndpointConnectionListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getprivateendpointconnectionlistslot.go b/resource-manager/web/2022-09-01/webapps/method_getprivateendpointconnectionlistslot.go new file mode 100644 index 00000000000..ce9a1148472 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getprivateendpointconnectionlistslot.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetPrivateEndpointConnectionListSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RemotePrivateEndpointConnectionARMResource +} + +type GetPrivateEndpointConnectionListSlotCompleteResult struct { + Items []RemotePrivateEndpointConnectionARMResource +} + +// GetPrivateEndpointConnectionListSlot ... +func (c WebAppsClient) GetPrivateEndpointConnectionListSlot(ctx context.Context, id SlotId) (result GetPrivateEndpointConnectionListSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateEndpointConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]RemotePrivateEndpointConnectionARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetPrivateEndpointConnectionListSlotComplete retrieves all the results into a single object +func (c WebAppsClient) GetPrivateEndpointConnectionListSlotComplete(ctx context.Context, id SlotId) (GetPrivateEndpointConnectionListSlotCompleteResult, error) { + return c.GetPrivateEndpointConnectionListSlotCompleteMatchingPredicate(ctx, id, RemotePrivateEndpointConnectionARMResourceOperationPredicate{}) +} + +// GetPrivateEndpointConnectionListSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) GetPrivateEndpointConnectionListSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate RemotePrivateEndpointConnectionARMResourceOperationPredicate) (result GetPrivateEndpointConnectionListSlotCompleteResult, err error) { + items := make([]RemotePrivateEndpointConnectionARMResource, 0) + + resp, err := c.GetPrivateEndpointConnectionListSlot(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetPrivateEndpointConnectionListSlotCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getprivateendpointconnectionlistslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getprivateendpointconnectionlistslot_autorest.go deleted file mode 100644 index a12bd1810d3..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getprivateendpointconnectionlistslot_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetPrivateEndpointConnectionListSlotOperationResponse struct { - HttpResponse *http.Response - Model *[]RemotePrivateEndpointConnectionARMResource - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (GetPrivateEndpointConnectionListSlotOperationResponse, error) -} - -type GetPrivateEndpointConnectionListSlotCompleteResult struct { - Items []RemotePrivateEndpointConnectionARMResource -} - -func (r GetPrivateEndpointConnectionListSlotOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r GetPrivateEndpointConnectionListSlotOperationResponse) LoadMore(ctx context.Context) (resp GetPrivateEndpointConnectionListSlotOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// GetPrivateEndpointConnectionListSlot ... -func (c WebAppsClient) GetPrivateEndpointConnectionListSlot(ctx context.Context, id SlotId) (resp GetPrivateEndpointConnectionListSlotOperationResponse, err error) { - req, err := c.preparerForGetPrivateEndpointConnectionListSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetPrivateEndpointConnectionListSlot", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetPrivateEndpointConnectionListSlot", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForGetPrivateEndpointConnectionListSlot(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetPrivateEndpointConnectionListSlot", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForGetPrivateEndpointConnectionListSlot prepares the GetPrivateEndpointConnectionListSlot request. -func (c WebAppsClient) preparerForGetPrivateEndpointConnectionListSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/privateEndpointConnections", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForGetPrivateEndpointConnectionListSlotWithNextLink prepares the GetPrivateEndpointConnectionListSlot request with the given nextLink token. -func (c WebAppsClient) preparerForGetPrivateEndpointConnectionListSlotWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetPrivateEndpointConnectionListSlot handles the response to the GetPrivateEndpointConnectionListSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetPrivateEndpointConnectionListSlot(resp *http.Response) (result GetPrivateEndpointConnectionListSlotOperationResponse, err error) { - type page struct { - Values []RemotePrivateEndpointConnectionARMResource `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result GetPrivateEndpointConnectionListSlotOperationResponse, err error) { - req, err := c.preparerForGetPrivateEndpointConnectionListSlotWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetPrivateEndpointConnectionListSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetPrivateEndpointConnectionListSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetPrivateEndpointConnectionListSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetPrivateEndpointConnectionListSlot", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// GetPrivateEndpointConnectionListSlotComplete retrieves all of the results into a single object -func (c WebAppsClient) GetPrivateEndpointConnectionListSlotComplete(ctx context.Context, id SlotId) (GetPrivateEndpointConnectionListSlotCompleteResult, error) { - return c.GetPrivateEndpointConnectionListSlotCompleteMatchingPredicate(ctx, id, RemotePrivateEndpointConnectionARMResourceOperationPredicate{}) -} - -// GetPrivateEndpointConnectionListSlotCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) GetPrivateEndpointConnectionListSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate RemotePrivateEndpointConnectionARMResourceOperationPredicate) (resp GetPrivateEndpointConnectionListSlotCompleteResult, err error) { - items := make([]RemotePrivateEndpointConnectionARMResource, 0) - - page, err := c.GetPrivateEndpointConnectionListSlot(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := GetPrivateEndpointConnectionListSlotCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getprivateendpointconnectionslot.go b/resource-manager/web/2022-09-01/webapps/method_getprivateendpointconnectionslot.go new file mode 100644 index 00000000000..72e0bfb6b4c --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getprivateendpointconnectionslot.go @@ -0,0 +1,51 @@ +package webapps + +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 GetPrivateEndpointConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RemotePrivateEndpointConnectionARMResource +} + +// GetPrivateEndpointConnectionSlot ... +func (c WebAppsClient) GetPrivateEndpointConnectionSlot(ctx context.Context, id SlotPrivateEndpointConnectionId) (result GetPrivateEndpointConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getprivateendpointconnectionslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getprivateendpointconnectionslot_autorest.go deleted file mode 100644 index b69b1f72092..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getprivateendpointconnectionslot_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetPrivateEndpointConnectionSlotOperationResponse struct { - HttpResponse *http.Response - Model *RemotePrivateEndpointConnectionARMResource -} - -// GetPrivateEndpointConnectionSlot ... -func (c WebAppsClient) GetPrivateEndpointConnectionSlot(ctx context.Context, id SlotPrivateEndpointConnectionId) (result GetPrivateEndpointConnectionSlotOperationResponse, err error) { - req, err := c.preparerForGetPrivateEndpointConnectionSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetPrivateEndpointConnectionSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetPrivateEndpointConnectionSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetPrivateEndpointConnectionSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetPrivateEndpointConnectionSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetPrivateEndpointConnectionSlot prepares the GetPrivateEndpointConnectionSlot request. -func (c WebAppsClient) preparerForGetPrivateEndpointConnectionSlot(ctx context.Context, id SlotPrivateEndpointConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetPrivateEndpointConnectionSlot handles the response to the GetPrivateEndpointConnectionSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetPrivateEndpointConnectionSlot(resp *http.Response) (result GetPrivateEndpointConnectionSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getprivatelinkresources.go b/resource-manager/web/2022-09-01/webapps/method_getprivatelinkresources.go new file mode 100644 index 00000000000..9233ea29cc8 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getprivatelinkresources.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetPrivateLinkResourcesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateLinkResourcesWrapper +} + +// GetPrivateLinkResources ... +func (c WebAppsClient) GetPrivateLinkResources(ctx context.Context, id SiteId) (result GetPrivateLinkResourcesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateLinkResources", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getprivatelinkresources_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getprivatelinkresources_autorest.go deleted file mode 100644 index 0cb3898dafc..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getprivatelinkresources_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetPrivateLinkResourcesOperationResponse struct { - HttpResponse *http.Response - Model *PrivateLinkResourcesWrapper -} - -// GetPrivateLinkResources ... -func (c WebAppsClient) GetPrivateLinkResources(ctx context.Context, id SiteId) (result GetPrivateLinkResourcesOperationResponse, err error) { - req, err := c.preparerForGetPrivateLinkResources(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetPrivateLinkResources", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetPrivateLinkResources", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetPrivateLinkResources(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetPrivateLinkResources", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetPrivateLinkResources prepares the GetPrivateLinkResources request. -func (c WebAppsClient) preparerForGetPrivateLinkResources(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/privateLinkResources", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetPrivateLinkResources handles the response to the GetPrivateLinkResources request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetPrivateLinkResources(resp *http.Response) (result GetPrivateLinkResourcesOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getprivatelinkresourcesslot.go b/resource-manager/web/2022-09-01/webapps/method_getprivatelinkresourcesslot.go new file mode 100644 index 00000000000..561108319ef --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getprivatelinkresourcesslot.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetPrivateLinkResourcesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateLinkResourcesWrapper +} + +// GetPrivateLinkResourcesSlot ... +func (c WebAppsClient) GetPrivateLinkResourcesSlot(ctx context.Context, id SlotId) (result GetPrivateLinkResourcesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateLinkResources", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getprivatelinkresourcesslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getprivatelinkresourcesslot_autorest.go deleted file mode 100644 index 8330fcf2189..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getprivatelinkresourcesslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetPrivateLinkResourcesSlotOperationResponse struct { - HttpResponse *http.Response - Model *PrivateLinkResourcesWrapper -} - -// GetPrivateLinkResourcesSlot ... -func (c WebAppsClient) GetPrivateLinkResourcesSlot(ctx context.Context, id SlotId) (result GetPrivateLinkResourcesSlotOperationResponse, err error) { - req, err := c.preparerForGetPrivateLinkResourcesSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetPrivateLinkResourcesSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetPrivateLinkResourcesSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetPrivateLinkResourcesSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetPrivateLinkResourcesSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetPrivateLinkResourcesSlot prepares the GetPrivateLinkResourcesSlot request. -func (c WebAppsClient) preparerForGetPrivateLinkResourcesSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/privateLinkResources", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetPrivateLinkResourcesSlot handles the response to the GetPrivateLinkResourcesSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetPrivateLinkResourcesSlot(resp *http.Response) (result GetPrivateLinkResourcesSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getprocess.go b/resource-manager/web/2022-09-01/webapps/method_getprocess.go new file mode 100644 index 00000000000..40b45ef9172 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getprocess.go @@ -0,0 +1,51 @@ +package webapps + +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 GetProcessOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ProcessInfo +} + +// GetProcess ... +func (c WebAppsClient) GetProcess(ctx context.Context, id ProcessId) (result GetProcessOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getprocess_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getprocess_autorest.go deleted file mode 100644 index bd9ffcd8a9a..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getprocess_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetProcessOperationResponse struct { - HttpResponse *http.Response - Model *ProcessInfo -} - -// GetProcess ... -func (c WebAppsClient) GetProcess(ctx context.Context, id ProcessId) (result GetProcessOperationResponse, err error) { - req, err := c.preparerForGetProcess(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetProcess", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetProcess", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetProcess(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetProcess", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetProcess prepares the GetProcess request. -func (c WebAppsClient) preparerForGetProcess(ctx context.Context, id ProcessId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetProcess handles the response to the GetProcess request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetProcess(resp *http.Response) (result GetProcessOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getprocessdump.go b/resource-manager/web/2022-09-01/webapps/method_getprocessdump.go new file mode 100644 index 00000000000..836ba70fd74 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getprocessdump.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetProcessDumpOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]byte +} + +// GetProcessDump ... +func (c WebAppsClient) GetProcessDump(ctx context.Context, id ProcessId) (result GetProcessDumpOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/dump", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getprocessdump_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getprocessdump_autorest.go deleted file mode 100644 index 778affc005f..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getprocessdump_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetProcessDumpOperationResponse struct { - HttpResponse *http.Response - Model *[]byte -} - -// GetProcessDump ... -func (c WebAppsClient) GetProcessDump(ctx context.Context, id ProcessId) (result GetProcessDumpOperationResponse, err error) { - req, err := c.preparerForGetProcessDump(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetProcessDump", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetProcessDump", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetProcessDump(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetProcessDump", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetProcessDump prepares the GetProcessDump request. -func (c WebAppsClient) preparerForGetProcessDump(ctx context.Context, id ProcessId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/dump", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetProcessDump handles the response to the GetProcessDump request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetProcessDump(resp *http.Response) (result GetProcessDumpOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getprocessdumpslot.go b/resource-manager/web/2022-09-01/webapps/method_getprocessdumpslot.go new file mode 100644 index 00000000000..cf31b47b66e --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getprocessdumpslot.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetProcessDumpSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]byte +} + +// GetProcessDumpSlot ... +func (c WebAppsClient) GetProcessDumpSlot(ctx context.Context, id SlotProcessId) (result GetProcessDumpSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/dump", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getprocessdumpslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getprocessdumpslot_autorest.go deleted file mode 100644 index 13d2b2b9eab..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getprocessdumpslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetProcessDumpSlotOperationResponse struct { - HttpResponse *http.Response - Model *[]byte -} - -// GetProcessDumpSlot ... -func (c WebAppsClient) GetProcessDumpSlot(ctx context.Context, id SlotProcessId) (result GetProcessDumpSlotOperationResponse, err error) { - req, err := c.preparerForGetProcessDumpSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetProcessDumpSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetProcessDumpSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetProcessDumpSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetProcessDumpSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetProcessDumpSlot prepares the GetProcessDumpSlot request. -func (c WebAppsClient) preparerForGetProcessDumpSlot(ctx context.Context, id SlotProcessId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/dump", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetProcessDumpSlot handles the response to the GetProcessDumpSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetProcessDumpSlot(resp *http.Response) (result GetProcessDumpSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getprocessmodule.go b/resource-manager/web/2022-09-01/webapps/method_getprocessmodule.go new file mode 100644 index 00000000000..9cbf6493061 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getprocessmodule.go @@ -0,0 +1,51 @@ +package webapps + +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 GetProcessModuleOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ProcessModuleInfo +} + +// GetProcessModule ... +func (c WebAppsClient) GetProcessModule(ctx context.Context, id ModuleId) (result GetProcessModuleOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getprocessmodule_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getprocessmodule_autorest.go deleted file mode 100644 index e7dc4adeff1..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getprocessmodule_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetProcessModuleOperationResponse struct { - HttpResponse *http.Response - Model *ProcessModuleInfo -} - -// GetProcessModule ... -func (c WebAppsClient) GetProcessModule(ctx context.Context, id ModuleId) (result GetProcessModuleOperationResponse, err error) { - req, err := c.preparerForGetProcessModule(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetProcessModule", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetProcessModule", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetProcessModule(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetProcessModule", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetProcessModule prepares the GetProcessModule request. -func (c WebAppsClient) preparerForGetProcessModule(ctx context.Context, id ModuleId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetProcessModule handles the response to the GetProcessModule request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetProcessModule(resp *http.Response) (result GetProcessModuleOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getprocessmoduleslot.go b/resource-manager/web/2022-09-01/webapps/method_getprocessmoduleslot.go new file mode 100644 index 00000000000..2efd489b096 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getprocessmoduleslot.go @@ -0,0 +1,51 @@ +package webapps + +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 GetProcessModuleSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ProcessModuleInfo +} + +// GetProcessModuleSlot ... +func (c WebAppsClient) GetProcessModuleSlot(ctx context.Context, id ProcessModuleId) (result GetProcessModuleSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getprocessmoduleslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getprocessmoduleslot_autorest.go deleted file mode 100644 index 02ad1a22d2b..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getprocessmoduleslot_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetProcessModuleSlotOperationResponse struct { - HttpResponse *http.Response - Model *ProcessModuleInfo -} - -// GetProcessModuleSlot ... -func (c WebAppsClient) GetProcessModuleSlot(ctx context.Context, id ProcessModuleId) (result GetProcessModuleSlotOperationResponse, err error) { - req, err := c.preparerForGetProcessModuleSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetProcessModuleSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetProcessModuleSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetProcessModuleSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetProcessModuleSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetProcessModuleSlot prepares the GetProcessModuleSlot request. -func (c WebAppsClient) preparerForGetProcessModuleSlot(ctx context.Context, id ProcessModuleId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetProcessModuleSlot handles the response to the GetProcessModuleSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetProcessModuleSlot(resp *http.Response) (result GetProcessModuleSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getprocessslot.go b/resource-manager/web/2022-09-01/webapps/method_getprocessslot.go new file mode 100644 index 00000000000..831a20dc551 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getprocessslot.go @@ -0,0 +1,51 @@ +package webapps + +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 GetProcessSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ProcessInfo +} + +// GetProcessSlot ... +func (c WebAppsClient) GetProcessSlot(ctx context.Context, id SlotProcessId) (result GetProcessSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getprocessslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getprocessslot_autorest.go deleted file mode 100644 index d34dd8cd405..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getprocessslot_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetProcessSlotOperationResponse struct { - HttpResponse *http.Response - Model *ProcessInfo -} - -// GetProcessSlot ... -func (c WebAppsClient) GetProcessSlot(ctx context.Context, id SlotProcessId) (result GetProcessSlotOperationResponse, err error) { - req, err := c.preparerForGetProcessSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetProcessSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetProcessSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetProcessSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetProcessSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetProcessSlot prepares the GetProcessSlot request. -func (c WebAppsClient) preparerForGetProcessSlot(ctx context.Context, id SlotProcessId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetProcessSlot handles the response to the GetProcessSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetProcessSlot(resp *http.Response) (result GetProcessSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getpubliccertificate.go b/resource-manager/web/2022-09-01/webapps/method_getpubliccertificate.go new file mode 100644 index 00000000000..ee537a44dfd --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getpubliccertificate.go @@ -0,0 +1,51 @@ +package webapps + +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 GetPublicCertificateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PublicCertificate +} + +// GetPublicCertificate ... +func (c WebAppsClient) GetPublicCertificate(ctx context.Context, id PublicCertificateId) (result GetPublicCertificateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getpubliccertificate_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getpubliccertificate_autorest.go deleted file mode 100644 index a34e9795a89..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getpubliccertificate_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetPublicCertificateOperationResponse struct { - HttpResponse *http.Response - Model *PublicCertificate -} - -// GetPublicCertificate ... -func (c WebAppsClient) GetPublicCertificate(ctx context.Context, id PublicCertificateId) (result GetPublicCertificateOperationResponse, err error) { - req, err := c.preparerForGetPublicCertificate(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetPublicCertificate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetPublicCertificate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetPublicCertificate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetPublicCertificate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetPublicCertificate prepares the GetPublicCertificate request. -func (c WebAppsClient) preparerForGetPublicCertificate(ctx context.Context, id PublicCertificateId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetPublicCertificate handles the response to the GetPublicCertificate request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetPublicCertificate(resp *http.Response) (result GetPublicCertificateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getpubliccertificateslot.go b/resource-manager/web/2022-09-01/webapps/method_getpubliccertificateslot.go new file mode 100644 index 00000000000..edc078b976f --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getpubliccertificateslot.go @@ -0,0 +1,51 @@ +package webapps + +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 GetPublicCertificateSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PublicCertificate +} + +// GetPublicCertificateSlot ... +func (c WebAppsClient) GetPublicCertificateSlot(ctx context.Context, id SlotPublicCertificateId) (result GetPublicCertificateSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getpubliccertificateslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getpubliccertificateslot_autorest.go deleted file mode 100644 index c40029c25e0..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getpubliccertificateslot_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetPublicCertificateSlotOperationResponse struct { - HttpResponse *http.Response - Model *PublicCertificate -} - -// GetPublicCertificateSlot ... -func (c WebAppsClient) GetPublicCertificateSlot(ctx context.Context, id SlotPublicCertificateId) (result GetPublicCertificateSlotOperationResponse, err error) { - req, err := c.preparerForGetPublicCertificateSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetPublicCertificateSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetPublicCertificateSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetPublicCertificateSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetPublicCertificateSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetPublicCertificateSlot prepares the GetPublicCertificateSlot request. -func (c WebAppsClient) preparerForGetPublicCertificateSlot(ctx context.Context, id SlotPublicCertificateId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetPublicCertificateSlot handles the response to the GetPublicCertificateSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetPublicCertificateSlot(resp *http.Response) (result GetPublicCertificateSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getrelayserviceconnection.go b/resource-manager/web/2022-09-01/webapps/method_getrelayserviceconnection.go new file mode 100644 index 00000000000..373f2fe6700 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getrelayserviceconnection.go @@ -0,0 +1,51 @@ +package webapps + +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 GetRelayServiceConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RelayServiceConnectionEntity +} + +// GetRelayServiceConnection ... +func (c WebAppsClient) GetRelayServiceConnection(ctx context.Context, id HybridConnectionId) (result GetRelayServiceConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getrelayserviceconnection_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getrelayserviceconnection_autorest.go deleted file mode 100644 index eda7498dc60..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getrelayserviceconnection_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetRelayServiceConnectionOperationResponse struct { - HttpResponse *http.Response - Model *RelayServiceConnectionEntity -} - -// GetRelayServiceConnection ... -func (c WebAppsClient) GetRelayServiceConnection(ctx context.Context, id HybridConnectionId) (result GetRelayServiceConnectionOperationResponse, err error) { - req, err := c.preparerForGetRelayServiceConnection(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetRelayServiceConnection", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetRelayServiceConnection", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetRelayServiceConnection(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetRelayServiceConnection", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetRelayServiceConnection prepares the GetRelayServiceConnection request. -func (c WebAppsClient) preparerForGetRelayServiceConnection(ctx context.Context, id HybridConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetRelayServiceConnection handles the response to the GetRelayServiceConnection request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetRelayServiceConnection(resp *http.Response) (result GetRelayServiceConnectionOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getrelayserviceconnectionslot.go b/resource-manager/web/2022-09-01/webapps/method_getrelayserviceconnectionslot.go new file mode 100644 index 00000000000..db1f0e95c60 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getrelayserviceconnectionslot.go @@ -0,0 +1,51 @@ +package webapps + +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 GetRelayServiceConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RelayServiceConnectionEntity +} + +// GetRelayServiceConnectionSlot ... +func (c WebAppsClient) GetRelayServiceConnectionSlot(ctx context.Context, id SlotHybridConnectionId) (result GetRelayServiceConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getrelayserviceconnectionslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getrelayserviceconnectionslot_autorest.go deleted file mode 100644 index 45db73571ae..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getrelayserviceconnectionslot_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetRelayServiceConnectionSlotOperationResponse struct { - HttpResponse *http.Response - Model *RelayServiceConnectionEntity -} - -// GetRelayServiceConnectionSlot ... -func (c WebAppsClient) GetRelayServiceConnectionSlot(ctx context.Context, id SlotHybridConnectionId) (result GetRelayServiceConnectionSlotOperationResponse, err error) { - req, err := c.preparerForGetRelayServiceConnectionSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetRelayServiceConnectionSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetRelayServiceConnectionSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetRelayServiceConnectionSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetRelayServiceConnectionSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetRelayServiceConnectionSlot prepares the GetRelayServiceConnectionSlot request. -func (c WebAppsClient) preparerForGetRelayServiceConnectionSlot(ctx context.Context, id SlotHybridConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetRelayServiceConnectionSlot handles the response to the GetRelayServiceConnectionSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetRelayServiceConnectionSlot(resp *http.Response) (result GetRelayServiceConnectionSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getscmallowed.go b/resource-manager/web/2022-09-01/webapps/method_getscmallowed.go new file mode 100644 index 00000000000..4c9e80e1650 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getscmallowed.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetScmAllowedOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CsmPublishingCredentialsPoliciesEntity +} + +// GetScmAllowed ... +func (c WebAppsClient) GetScmAllowed(ctx context.Context, id SiteId) (result GetScmAllowedOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/basicPublishingCredentialsPolicies/scm", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getscmallowed_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getscmallowed_autorest.go deleted file mode 100644 index 8dae6ef7ca7..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getscmallowed_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetScmAllowedOperationResponse struct { - HttpResponse *http.Response - Model *CsmPublishingCredentialsPoliciesEntity -} - -// GetScmAllowed ... -func (c WebAppsClient) GetScmAllowed(ctx context.Context, id SiteId) (result GetScmAllowedOperationResponse, err error) { - req, err := c.preparerForGetScmAllowed(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetScmAllowed", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetScmAllowed", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetScmAllowed(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetScmAllowed", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetScmAllowed prepares the GetScmAllowed request. -func (c WebAppsClient) preparerForGetScmAllowed(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/basicPublishingCredentialsPolicies/scm", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetScmAllowed handles the response to the GetScmAllowed request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetScmAllowed(resp *http.Response) (result GetScmAllowedOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getscmallowedslot.go b/resource-manager/web/2022-09-01/webapps/method_getscmallowedslot.go new file mode 100644 index 00000000000..5181659db7e --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getscmallowedslot.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetScmAllowedSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CsmPublishingCredentialsPoliciesEntity +} + +// GetScmAllowedSlot ... +func (c WebAppsClient) GetScmAllowedSlot(ctx context.Context, id SlotId) (result GetScmAllowedSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/basicPublishingCredentialsPolicies/scm", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getscmallowedslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getscmallowedslot_autorest.go deleted file mode 100644 index 586f4ac98e3..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getscmallowedslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetScmAllowedSlotOperationResponse struct { - HttpResponse *http.Response - Model *CsmPublishingCredentialsPoliciesEntity -} - -// GetScmAllowedSlot ... -func (c WebAppsClient) GetScmAllowedSlot(ctx context.Context, id SlotId) (result GetScmAllowedSlotOperationResponse, err error) { - req, err := c.preparerForGetScmAllowedSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetScmAllowedSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetScmAllowedSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetScmAllowedSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetScmAllowedSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetScmAllowedSlot prepares the GetScmAllowedSlot request. -func (c WebAppsClient) preparerForGetScmAllowedSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/basicPublishingCredentialsPolicies/scm", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetScmAllowedSlot handles the response to the GetScmAllowedSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetScmAllowedSlot(resp *http.Response) (result GetScmAllowedSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getsiteconnectionstringkeyvaultreference.go b/resource-manager/web/2022-09-01/webapps/method_getsiteconnectionstringkeyvaultreference.go new file mode 100644 index 00000000000..4e8959c6a9f --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getsiteconnectionstringkeyvaultreference.go @@ -0,0 +1,51 @@ +package webapps + +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 GetSiteConnectionStringKeyVaultReferenceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApiKVReference +} + +// GetSiteConnectionStringKeyVaultReference ... +func (c WebAppsClient) GetSiteConnectionStringKeyVaultReference(ctx context.Context, id ConnectionStringId) (result GetSiteConnectionStringKeyVaultReferenceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getsiteconnectionstringkeyvaultreference_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getsiteconnectionstringkeyvaultreference_autorest.go deleted file mode 100644 index d01619b5cf8..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getsiteconnectionstringkeyvaultreference_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetSiteConnectionStringKeyVaultReferenceOperationResponse struct { - HttpResponse *http.Response - Model *ApiKVReference -} - -// GetSiteConnectionStringKeyVaultReference ... -func (c WebAppsClient) GetSiteConnectionStringKeyVaultReference(ctx context.Context, id ConnectionStringId) (result GetSiteConnectionStringKeyVaultReferenceOperationResponse, err error) { - req, err := c.preparerForGetSiteConnectionStringKeyVaultReference(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetSiteConnectionStringKeyVaultReference", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetSiteConnectionStringKeyVaultReference", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetSiteConnectionStringKeyVaultReference(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetSiteConnectionStringKeyVaultReference", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetSiteConnectionStringKeyVaultReference prepares the GetSiteConnectionStringKeyVaultReference request. -func (c WebAppsClient) preparerForGetSiteConnectionStringKeyVaultReference(ctx context.Context, id ConnectionStringId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetSiteConnectionStringKeyVaultReference handles the response to the GetSiteConnectionStringKeyVaultReference request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetSiteConnectionStringKeyVaultReference(resp *http.Response) (result GetSiteConnectionStringKeyVaultReferenceOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getsiteconnectionstringkeyvaultreferences.go b/resource-manager/web/2022-09-01/webapps/method_getsiteconnectionstringkeyvaultreferences.go new file mode 100644 index 00000000000..9af86be3bc8 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getsiteconnectionstringkeyvaultreferences.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetSiteConnectionStringKeyVaultReferencesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ApiKVReference +} + +type GetSiteConnectionStringKeyVaultReferencesCompleteResult struct { + Items []ApiKVReference +} + +// GetSiteConnectionStringKeyVaultReferences ... +func (c WebAppsClient) GetSiteConnectionStringKeyVaultReferences(ctx context.Context, id SiteId) (result GetSiteConnectionStringKeyVaultReferencesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/config/configReferences/connectionStrings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ApiKVReference `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetSiteConnectionStringKeyVaultReferencesComplete retrieves all the results into a single object +func (c WebAppsClient) GetSiteConnectionStringKeyVaultReferencesComplete(ctx context.Context, id SiteId) (GetSiteConnectionStringKeyVaultReferencesCompleteResult, error) { + return c.GetSiteConnectionStringKeyVaultReferencesCompleteMatchingPredicate(ctx, id, ApiKVReferenceOperationPredicate{}) +} + +// GetSiteConnectionStringKeyVaultReferencesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) GetSiteConnectionStringKeyVaultReferencesCompleteMatchingPredicate(ctx context.Context, id SiteId, predicate ApiKVReferenceOperationPredicate) (result GetSiteConnectionStringKeyVaultReferencesCompleteResult, err error) { + items := make([]ApiKVReference, 0) + + resp, err := c.GetSiteConnectionStringKeyVaultReferences(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetSiteConnectionStringKeyVaultReferencesCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getsiteconnectionstringkeyvaultreferences_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getsiteconnectionstringkeyvaultreferences_autorest.go deleted file mode 100644 index 8981a767984..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getsiteconnectionstringkeyvaultreferences_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetSiteConnectionStringKeyVaultReferencesOperationResponse struct { - HttpResponse *http.Response - Model *[]ApiKVReference - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (GetSiteConnectionStringKeyVaultReferencesOperationResponse, error) -} - -type GetSiteConnectionStringKeyVaultReferencesCompleteResult struct { - Items []ApiKVReference -} - -func (r GetSiteConnectionStringKeyVaultReferencesOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r GetSiteConnectionStringKeyVaultReferencesOperationResponse) LoadMore(ctx context.Context) (resp GetSiteConnectionStringKeyVaultReferencesOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// GetSiteConnectionStringKeyVaultReferences ... -func (c WebAppsClient) GetSiteConnectionStringKeyVaultReferences(ctx context.Context, id SiteId) (resp GetSiteConnectionStringKeyVaultReferencesOperationResponse, err error) { - req, err := c.preparerForGetSiteConnectionStringKeyVaultReferences(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetSiteConnectionStringKeyVaultReferences", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetSiteConnectionStringKeyVaultReferences", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForGetSiteConnectionStringKeyVaultReferences(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetSiteConnectionStringKeyVaultReferences", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForGetSiteConnectionStringKeyVaultReferences prepares the GetSiteConnectionStringKeyVaultReferences request. -func (c WebAppsClient) preparerForGetSiteConnectionStringKeyVaultReferences(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/configReferences/connectionStrings", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForGetSiteConnectionStringKeyVaultReferencesWithNextLink prepares the GetSiteConnectionStringKeyVaultReferences request with the given nextLink token. -func (c WebAppsClient) preparerForGetSiteConnectionStringKeyVaultReferencesWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetSiteConnectionStringKeyVaultReferences handles the response to the GetSiteConnectionStringKeyVaultReferences request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetSiteConnectionStringKeyVaultReferences(resp *http.Response) (result GetSiteConnectionStringKeyVaultReferencesOperationResponse, err error) { - type page struct { - Values []ApiKVReference `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result GetSiteConnectionStringKeyVaultReferencesOperationResponse, err error) { - req, err := c.preparerForGetSiteConnectionStringKeyVaultReferencesWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetSiteConnectionStringKeyVaultReferences", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetSiteConnectionStringKeyVaultReferences", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetSiteConnectionStringKeyVaultReferences(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetSiteConnectionStringKeyVaultReferences", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// GetSiteConnectionStringKeyVaultReferencesComplete retrieves all of the results into a single object -func (c WebAppsClient) GetSiteConnectionStringKeyVaultReferencesComplete(ctx context.Context, id SiteId) (GetSiteConnectionStringKeyVaultReferencesCompleteResult, error) { - return c.GetSiteConnectionStringKeyVaultReferencesCompleteMatchingPredicate(ctx, id, ApiKVReferenceOperationPredicate{}) -} - -// GetSiteConnectionStringKeyVaultReferencesCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) GetSiteConnectionStringKeyVaultReferencesCompleteMatchingPredicate(ctx context.Context, id SiteId, predicate ApiKVReferenceOperationPredicate) (resp GetSiteConnectionStringKeyVaultReferencesCompleteResult, err error) { - items := make([]ApiKVReference, 0) - - page, err := c.GetSiteConnectionStringKeyVaultReferences(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := GetSiteConnectionStringKeyVaultReferencesCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getsiteconnectionstringkeyvaultreferenceslot.go b/resource-manager/web/2022-09-01/webapps/method_getsiteconnectionstringkeyvaultreferenceslot.go new file mode 100644 index 00000000000..63a11d2ec34 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getsiteconnectionstringkeyvaultreferenceslot.go @@ -0,0 +1,51 @@ +package webapps + +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 GetSiteConnectionStringKeyVaultReferenceSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApiKVReference +} + +// GetSiteConnectionStringKeyVaultReferenceSlot ... +func (c WebAppsClient) GetSiteConnectionStringKeyVaultReferenceSlot(ctx context.Context, id ConfigReferenceConnectionStringId) (result GetSiteConnectionStringKeyVaultReferenceSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getsiteconnectionstringkeyvaultreferenceslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getsiteconnectionstringkeyvaultreferenceslot_autorest.go deleted file mode 100644 index 78334b69327..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getsiteconnectionstringkeyvaultreferenceslot_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetSiteConnectionStringKeyVaultReferenceSlotOperationResponse struct { - HttpResponse *http.Response - Model *ApiKVReference -} - -// GetSiteConnectionStringKeyVaultReferenceSlot ... -func (c WebAppsClient) GetSiteConnectionStringKeyVaultReferenceSlot(ctx context.Context, id ConfigReferenceConnectionStringId) (result GetSiteConnectionStringKeyVaultReferenceSlotOperationResponse, err error) { - req, err := c.preparerForGetSiteConnectionStringKeyVaultReferenceSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetSiteConnectionStringKeyVaultReferenceSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetSiteConnectionStringKeyVaultReferenceSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetSiteConnectionStringKeyVaultReferenceSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetSiteConnectionStringKeyVaultReferenceSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetSiteConnectionStringKeyVaultReferenceSlot prepares the GetSiteConnectionStringKeyVaultReferenceSlot request. -func (c WebAppsClient) preparerForGetSiteConnectionStringKeyVaultReferenceSlot(ctx context.Context, id ConfigReferenceConnectionStringId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetSiteConnectionStringKeyVaultReferenceSlot handles the response to the GetSiteConnectionStringKeyVaultReferenceSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetSiteConnectionStringKeyVaultReferenceSlot(resp *http.Response) (result GetSiteConnectionStringKeyVaultReferenceSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getsiteconnectionstringkeyvaultreferencesslot.go b/resource-manager/web/2022-09-01/webapps/method_getsiteconnectionstringkeyvaultreferencesslot.go new file mode 100644 index 00000000000..a0326eceb9f --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getsiteconnectionstringkeyvaultreferencesslot.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetSiteConnectionStringKeyVaultReferencesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ApiKVReference +} + +type GetSiteConnectionStringKeyVaultReferencesSlotCompleteResult struct { + Items []ApiKVReference +} + +// GetSiteConnectionStringKeyVaultReferencesSlot ... +func (c WebAppsClient) GetSiteConnectionStringKeyVaultReferencesSlot(ctx context.Context, id SlotId) (result GetSiteConnectionStringKeyVaultReferencesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/config/configReferences/connectionStrings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ApiKVReference `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetSiteConnectionStringKeyVaultReferencesSlotComplete retrieves all the results into a single object +func (c WebAppsClient) GetSiteConnectionStringKeyVaultReferencesSlotComplete(ctx context.Context, id SlotId) (GetSiteConnectionStringKeyVaultReferencesSlotCompleteResult, error) { + return c.GetSiteConnectionStringKeyVaultReferencesSlotCompleteMatchingPredicate(ctx, id, ApiKVReferenceOperationPredicate{}) +} + +// GetSiteConnectionStringKeyVaultReferencesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) GetSiteConnectionStringKeyVaultReferencesSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate ApiKVReferenceOperationPredicate) (result GetSiteConnectionStringKeyVaultReferencesSlotCompleteResult, err error) { + items := make([]ApiKVReference, 0) + + resp, err := c.GetSiteConnectionStringKeyVaultReferencesSlot(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetSiteConnectionStringKeyVaultReferencesSlotCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getsiteconnectionstringkeyvaultreferencesslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getsiteconnectionstringkeyvaultreferencesslot_autorest.go deleted file mode 100644 index 16014532b3a..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getsiteconnectionstringkeyvaultreferencesslot_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetSiteConnectionStringKeyVaultReferencesSlotOperationResponse struct { - HttpResponse *http.Response - Model *[]ApiKVReference - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (GetSiteConnectionStringKeyVaultReferencesSlotOperationResponse, error) -} - -type GetSiteConnectionStringKeyVaultReferencesSlotCompleteResult struct { - Items []ApiKVReference -} - -func (r GetSiteConnectionStringKeyVaultReferencesSlotOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r GetSiteConnectionStringKeyVaultReferencesSlotOperationResponse) LoadMore(ctx context.Context) (resp GetSiteConnectionStringKeyVaultReferencesSlotOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// GetSiteConnectionStringKeyVaultReferencesSlot ... -func (c WebAppsClient) GetSiteConnectionStringKeyVaultReferencesSlot(ctx context.Context, id SlotId) (resp GetSiteConnectionStringKeyVaultReferencesSlotOperationResponse, err error) { - req, err := c.preparerForGetSiteConnectionStringKeyVaultReferencesSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetSiteConnectionStringKeyVaultReferencesSlot", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetSiteConnectionStringKeyVaultReferencesSlot", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForGetSiteConnectionStringKeyVaultReferencesSlot(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetSiteConnectionStringKeyVaultReferencesSlot", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForGetSiteConnectionStringKeyVaultReferencesSlot prepares the GetSiteConnectionStringKeyVaultReferencesSlot request. -func (c WebAppsClient) preparerForGetSiteConnectionStringKeyVaultReferencesSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/configReferences/connectionStrings", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForGetSiteConnectionStringKeyVaultReferencesSlotWithNextLink prepares the GetSiteConnectionStringKeyVaultReferencesSlot request with the given nextLink token. -func (c WebAppsClient) preparerForGetSiteConnectionStringKeyVaultReferencesSlotWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetSiteConnectionStringKeyVaultReferencesSlot handles the response to the GetSiteConnectionStringKeyVaultReferencesSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetSiteConnectionStringKeyVaultReferencesSlot(resp *http.Response) (result GetSiteConnectionStringKeyVaultReferencesSlotOperationResponse, err error) { - type page struct { - Values []ApiKVReference `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result GetSiteConnectionStringKeyVaultReferencesSlotOperationResponse, err error) { - req, err := c.preparerForGetSiteConnectionStringKeyVaultReferencesSlotWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetSiteConnectionStringKeyVaultReferencesSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetSiteConnectionStringKeyVaultReferencesSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetSiteConnectionStringKeyVaultReferencesSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetSiteConnectionStringKeyVaultReferencesSlot", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// GetSiteConnectionStringKeyVaultReferencesSlotComplete retrieves all of the results into a single object -func (c WebAppsClient) GetSiteConnectionStringKeyVaultReferencesSlotComplete(ctx context.Context, id SlotId) (GetSiteConnectionStringKeyVaultReferencesSlotCompleteResult, error) { - return c.GetSiteConnectionStringKeyVaultReferencesSlotCompleteMatchingPredicate(ctx, id, ApiKVReferenceOperationPredicate{}) -} - -// GetSiteConnectionStringKeyVaultReferencesSlotCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) GetSiteConnectionStringKeyVaultReferencesSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate ApiKVReferenceOperationPredicate) (resp GetSiteConnectionStringKeyVaultReferencesSlotCompleteResult, err error) { - items := make([]ApiKVReference, 0) - - page, err := c.GetSiteConnectionStringKeyVaultReferencesSlot(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := GetSiteConnectionStringKeyVaultReferencesSlotCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getsiteextension.go b/resource-manager/web/2022-09-01/webapps/method_getsiteextension.go new file mode 100644 index 00000000000..a655592996f --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getsiteextension.go @@ -0,0 +1,51 @@ +package webapps + +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 GetSiteExtensionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteExtensionInfo +} + +// GetSiteExtension ... +func (c WebAppsClient) GetSiteExtension(ctx context.Context, id SiteExtensionId) (result GetSiteExtensionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getsiteextension_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getsiteextension_autorest.go deleted file mode 100644 index 5bf6fe52cb9..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getsiteextension_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetSiteExtensionOperationResponse struct { - HttpResponse *http.Response - Model *SiteExtensionInfo -} - -// GetSiteExtension ... -func (c WebAppsClient) GetSiteExtension(ctx context.Context, id SiteExtensionId) (result GetSiteExtensionOperationResponse, err error) { - req, err := c.preparerForGetSiteExtension(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetSiteExtension", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetSiteExtension", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetSiteExtension(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetSiteExtension", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetSiteExtension prepares the GetSiteExtension request. -func (c WebAppsClient) preparerForGetSiteExtension(ctx context.Context, id SiteExtensionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetSiteExtension handles the response to the GetSiteExtension request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetSiteExtension(resp *http.Response) (result GetSiteExtensionOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getsiteextensionslot.go b/resource-manager/web/2022-09-01/webapps/method_getsiteextensionslot.go new file mode 100644 index 00000000000..e3e042774f3 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getsiteextensionslot.go @@ -0,0 +1,51 @@ +package webapps + +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 GetSiteExtensionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteExtensionInfo +} + +// GetSiteExtensionSlot ... +func (c WebAppsClient) GetSiteExtensionSlot(ctx context.Context, id SlotSiteExtensionId) (result GetSiteExtensionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getsiteextensionslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getsiteextensionslot_autorest.go deleted file mode 100644 index 7fd9bb236f2..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getsiteextensionslot_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetSiteExtensionSlotOperationResponse struct { - HttpResponse *http.Response - Model *SiteExtensionInfo -} - -// GetSiteExtensionSlot ... -func (c WebAppsClient) GetSiteExtensionSlot(ctx context.Context, id SlotSiteExtensionId) (result GetSiteExtensionSlotOperationResponse, err error) { - req, err := c.preparerForGetSiteExtensionSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetSiteExtensionSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetSiteExtensionSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetSiteExtensionSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetSiteExtensionSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetSiteExtensionSlot prepares the GetSiteExtensionSlot request. -func (c WebAppsClient) preparerForGetSiteExtensionSlot(ctx context.Context, id SlotSiteExtensionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetSiteExtensionSlot handles the response to the GetSiteExtensionSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetSiteExtensionSlot(resp *http.Response) (result GetSiteExtensionSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getsitephperrorlogflag.go b/resource-manager/web/2022-09-01/webapps/method_getsitephperrorlogflag.go new file mode 100644 index 00000000000..648df27d0ed --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getsitephperrorlogflag.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetSitePhpErrorLogFlagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SitePhpErrorLogFlag +} + +// GetSitePhpErrorLogFlag ... +func (c WebAppsClient) GetSitePhpErrorLogFlag(ctx context.Context, id SiteId) (result GetSitePhpErrorLogFlagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/phplogging", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getsitephperrorlogflag_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getsitephperrorlogflag_autorest.go deleted file mode 100644 index d223da768b4..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getsitephperrorlogflag_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetSitePhpErrorLogFlagOperationResponse struct { - HttpResponse *http.Response - Model *SitePhpErrorLogFlag -} - -// GetSitePhpErrorLogFlag ... -func (c WebAppsClient) GetSitePhpErrorLogFlag(ctx context.Context, id SiteId) (result GetSitePhpErrorLogFlagOperationResponse, err error) { - req, err := c.preparerForGetSitePhpErrorLogFlag(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetSitePhpErrorLogFlag", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetSitePhpErrorLogFlag", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetSitePhpErrorLogFlag(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetSitePhpErrorLogFlag", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetSitePhpErrorLogFlag prepares the GetSitePhpErrorLogFlag request. -func (c WebAppsClient) preparerForGetSitePhpErrorLogFlag(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/phplogging", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetSitePhpErrorLogFlag handles the response to the GetSitePhpErrorLogFlag request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetSitePhpErrorLogFlag(resp *http.Response) (result GetSitePhpErrorLogFlagOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getsitephperrorlogflagslot.go b/resource-manager/web/2022-09-01/webapps/method_getsitephperrorlogflagslot.go new file mode 100644 index 00000000000..b72b334a3e1 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getsitephperrorlogflagslot.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetSitePhpErrorLogFlagSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SitePhpErrorLogFlag +} + +// GetSitePhpErrorLogFlagSlot ... +func (c WebAppsClient) GetSitePhpErrorLogFlagSlot(ctx context.Context, id SlotId) (result GetSitePhpErrorLogFlagSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/phplogging", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getsitephperrorlogflagslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getsitephperrorlogflagslot_autorest.go deleted file mode 100644 index 4c6d1db2172..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getsitephperrorlogflagslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetSitePhpErrorLogFlagSlotOperationResponse struct { - HttpResponse *http.Response - Model *SitePhpErrorLogFlag -} - -// GetSitePhpErrorLogFlagSlot ... -func (c WebAppsClient) GetSitePhpErrorLogFlagSlot(ctx context.Context, id SlotId) (result GetSitePhpErrorLogFlagSlotOperationResponse, err error) { - req, err := c.preparerForGetSitePhpErrorLogFlagSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetSitePhpErrorLogFlagSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetSitePhpErrorLogFlagSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetSitePhpErrorLogFlagSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetSitePhpErrorLogFlagSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetSitePhpErrorLogFlagSlot prepares the GetSitePhpErrorLogFlagSlot request. -func (c WebAppsClient) preparerForGetSitePhpErrorLogFlagSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/phplogging", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetSitePhpErrorLogFlagSlot handles the response to the GetSitePhpErrorLogFlagSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetSitePhpErrorLogFlagSlot(resp *http.Response) (result GetSitePhpErrorLogFlagSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getslot.go b/resource-manager/web/2022-09-01/webapps/method_getslot.go new file mode 100644 index 00000000000..81268b07a00 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getslot.go @@ -0,0 +1,51 @@ +package webapps + +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 GetSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Site +} + +// GetSlot ... +func (c WebAppsClient) GetSlot(ctx context.Context, id SlotId) (result GetSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getslot_autorest.go deleted file mode 100644 index 8eae2e8a8ec..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getslot_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetSlotOperationResponse struct { - HttpResponse *http.Response - Model *Site -} - -// GetSlot ... -func (c WebAppsClient) GetSlot(ctx context.Context, id SlotId) (result GetSlotOperationResponse, err error) { - req, err := c.preparerForGetSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetSlot prepares the GetSlot request. -func (c WebAppsClient) preparerForGetSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetSlot handles the response to the GetSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetSlot(resp *http.Response) (result GetSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getsourcecontrol.go b/resource-manager/web/2022-09-01/webapps/method_getsourcecontrol.go new file mode 100644 index 00000000000..2b520a0d073 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getsourcecontrol.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetSourceControlOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteSourceControl +} + +// GetSourceControl ... +func (c WebAppsClient) GetSourceControl(ctx context.Context, id SiteId) (result GetSourceControlOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/sourceControls/web", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getsourcecontrol_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getsourcecontrol_autorest.go deleted file mode 100644 index a9019ce6eee..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getsourcecontrol_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetSourceControlOperationResponse struct { - HttpResponse *http.Response - Model *SiteSourceControl -} - -// GetSourceControl ... -func (c WebAppsClient) GetSourceControl(ctx context.Context, id SiteId) (result GetSourceControlOperationResponse, err error) { - req, err := c.preparerForGetSourceControl(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetSourceControl", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetSourceControl", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetSourceControl(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetSourceControl", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetSourceControl prepares the GetSourceControl request. -func (c WebAppsClient) preparerForGetSourceControl(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/sourceControls/web", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetSourceControl handles the response to the GetSourceControl request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetSourceControl(resp *http.Response) (result GetSourceControlOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getsourcecontrolslot.go b/resource-manager/web/2022-09-01/webapps/method_getsourcecontrolslot.go new file mode 100644 index 00000000000..b805e723a45 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getsourcecontrolslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetSourceControlSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteSourceControl +} + +// GetSourceControlSlot ... +func (c WebAppsClient) GetSourceControlSlot(ctx context.Context, id SlotId) (result GetSourceControlSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/sourceControls/web", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getsourcecontrolslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getsourcecontrolslot_autorest.go deleted file mode 100644 index ebb6a960aba..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getsourcecontrolslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetSourceControlSlotOperationResponse struct { - HttpResponse *http.Response - Model *SiteSourceControl -} - -// GetSourceControlSlot ... -func (c WebAppsClient) GetSourceControlSlot(ctx context.Context, id SlotId) (result GetSourceControlSlotOperationResponse, err error) { - req, err := c.preparerForGetSourceControlSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetSourceControlSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetSourceControlSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetSourceControlSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetSourceControlSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetSourceControlSlot prepares the GetSourceControlSlot request. -func (c WebAppsClient) preparerForGetSourceControlSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/sourceControls/web", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetSourceControlSlot handles the response to the GetSourceControlSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetSourceControlSlot(resp *http.Response) (result GetSourceControlSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getswiftvirtualnetworkconnection.go b/resource-manager/web/2022-09-01/webapps/method_getswiftvirtualnetworkconnection.go new file mode 100644 index 00000000000..d5e2f31189b --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getswiftvirtualnetworkconnection.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetSwiftVirtualNetworkConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SwiftVirtualNetwork +} + +// GetSwiftVirtualNetworkConnection ... +func (c WebAppsClient) GetSwiftVirtualNetworkConnection(ctx context.Context, id SiteId) (result GetSwiftVirtualNetworkConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/networkConfig/virtualNetwork", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getswiftvirtualnetworkconnection_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getswiftvirtualnetworkconnection_autorest.go deleted file mode 100644 index 5d0a18b6aad..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getswiftvirtualnetworkconnection_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetSwiftVirtualNetworkConnectionOperationResponse struct { - HttpResponse *http.Response - Model *SwiftVirtualNetwork -} - -// GetSwiftVirtualNetworkConnection ... -func (c WebAppsClient) GetSwiftVirtualNetworkConnection(ctx context.Context, id SiteId) (result GetSwiftVirtualNetworkConnectionOperationResponse, err error) { - req, err := c.preparerForGetSwiftVirtualNetworkConnection(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetSwiftVirtualNetworkConnection", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetSwiftVirtualNetworkConnection", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetSwiftVirtualNetworkConnection(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetSwiftVirtualNetworkConnection", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetSwiftVirtualNetworkConnection prepares the GetSwiftVirtualNetworkConnection request. -func (c WebAppsClient) preparerForGetSwiftVirtualNetworkConnection(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/networkConfig/virtualNetwork", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetSwiftVirtualNetworkConnection handles the response to the GetSwiftVirtualNetworkConnection request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetSwiftVirtualNetworkConnection(resp *http.Response) (result GetSwiftVirtualNetworkConnectionOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getswiftvirtualnetworkconnectionslot.go b/resource-manager/web/2022-09-01/webapps/method_getswiftvirtualnetworkconnectionslot.go new file mode 100644 index 00000000000..fc0b506b3cb --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getswiftvirtualnetworkconnectionslot.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetSwiftVirtualNetworkConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SwiftVirtualNetwork +} + +// GetSwiftVirtualNetworkConnectionSlot ... +func (c WebAppsClient) GetSwiftVirtualNetworkConnectionSlot(ctx context.Context, id SlotId) (result GetSwiftVirtualNetworkConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/networkConfig/virtualNetwork", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getswiftvirtualnetworkconnectionslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getswiftvirtualnetworkconnectionslot_autorest.go deleted file mode 100644 index d201e331673..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getswiftvirtualnetworkconnectionslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetSwiftVirtualNetworkConnectionSlotOperationResponse struct { - HttpResponse *http.Response - Model *SwiftVirtualNetwork -} - -// GetSwiftVirtualNetworkConnectionSlot ... -func (c WebAppsClient) GetSwiftVirtualNetworkConnectionSlot(ctx context.Context, id SlotId) (result GetSwiftVirtualNetworkConnectionSlotOperationResponse, err error) { - req, err := c.preparerForGetSwiftVirtualNetworkConnectionSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetSwiftVirtualNetworkConnectionSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetSwiftVirtualNetworkConnectionSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetSwiftVirtualNetworkConnectionSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetSwiftVirtualNetworkConnectionSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetSwiftVirtualNetworkConnectionSlot prepares the GetSwiftVirtualNetworkConnectionSlot request. -func (c WebAppsClient) preparerForGetSwiftVirtualNetworkConnectionSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/networkConfig/virtualNetwork", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetSwiftVirtualNetworkConnectionSlot handles the response to the GetSwiftVirtualNetworkConnectionSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetSwiftVirtualNetworkConnectionSlot(resp *http.Response) (result GetSwiftVirtualNetworkConnectionSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_gettriggeredwebjob.go b/resource-manager/web/2022-09-01/webapps/method_gettriggeredwebjob.go new file mode 100644 index 00000000000..a345ce68461 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_gettriggeredwebjob.go @@ -0,0 +1,51 @@ +package webapps + +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 GetTriggeredWebJobOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *TriggeredWebJob +} + +// GetTriggeredWebJob ... +func (c WebAppsClient) GetTriggeredWebJob(ctx context.Context, id TriggeredWebJobId) (result GetTriggeredWebJobOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_gettriggeredwebjob_autorest.go b/resource-manager/web/2022-09-01/webapps/method_gettriggeredwebjob_autorest.go deleted file mode 100644 index 0ad0f78cd74..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_gettriggeredwebjob_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetTriggeredWebJobOperationResponse struct { - HttpResponse *http.Response - Model *TriggeredWebJob -} - -// GetTriggeredWebJob ... -func (c WebAppsClient) GetTriggeredWebJob(ctx context.Context, id TriggeredWebJobId) (result GetTriggeredWebJobOperationResponse, err error) { - req, err := c.preparerForGetTriggeredWebJob(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetTriggeredWebJob", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetTriggeredWebJob", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetTriggeredWebJob(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetTriggeredWebJob", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetTriggeredWebJob prepares the GetTriggeredWebJob request. -func (c WebAppsClient) preparerForGetTriggeredWebJob(ctx context.Context, id TriggeredWebJobId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetTriggeredWebJob handles the response to the GetTriggeredWebJob request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetTriggeredWebJob(resp *http.Response) (result GetTriggeredWebJobOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_gettriggeredwebjobhistory.go b/resource-manager/web/2022-09-01/webapps/method_gettriggeredwebjobhistory.go new file mode 100644 index 00000000000..7e66a8e9791 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_gettriggeredwebjobhistory.go @@ -0,0 +1,51 @@ +package webapps + +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 GetTriggeredWebJobHistoryOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *TriggeredJobHistory +} + +// GetTriggeredWebJobHistory ... +func (c WebAppsClient) GetTriggeredWebJobHistory(ctx context.Context, id HistoryId) (result GetTriggeredWebJobHistoryOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_gettriggeredwebjobhistory_autorest.go b/resource-manager/web/2022-09-01/webapps/method_gettriggeredwebjobhistory_autorest.go deleted file mode 100644 index 9a8374479e4..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_gettriggeredwebjobhistory_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetTriggeredWebJobHistoryOperationResponse struct { - HttpResponse *http.Response - Model *TriggeredJobHistory -} - -// GetTriggeredWebJobHistory ... -func (c WebAppsClient) GetTriggeredWebJobHistory(ctx context.Context, id HistoryId) (result GetTriggeredWebJobHistoryOperationResponse, err error) { - req, err := c.preparerForGetTriggeredWebJobHistory(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetTriggeredWebJobHistory", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetTriggeredWebJobHistory", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetTriggeredWebJobHistory(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetTriggeredWebJobHistory", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetTriggeredWebJobHistory prepares the GetTriggeredWebJobHistory request. -func (c WebAppsClient) preparerForGetTriggeredWebJobHistory(ctx context.Context, id HistoryId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetTriggeredWebJobHistory handles the response to the GetTriggeredWebJobHistory request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetTriggeredWebJobHistory(resp *http.Response) (result GetTriggeredWebJobHistoryOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_gettriggeredwebjobhistoryslot.go b/resource-manager/web/2022-09-01/webapps/method_gettriggeredwebjobhistoryslot.go new file mode 100644 index 00000000000..75149021edb --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_gettriggeredwebjobhistoryslot.go @@ -0,0 +1,51 @@ +package webapps + +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 GetTriggeredWebJobHistorySlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *TriggeredJobHistory +} + +// GetTriggeredWebJobHistorySlot ... +func (c WebAppsClient) GetTriggeredWebJobHistorySlot(ctx context.Context, id TriggeredWebJobHistoryId) (result GetTriggeredWebJobHistorySlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_gettriggeredwebjobhistoryslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_gettriggeredwebjobhistoryslot_autorest.go deleted file mode 100644 index 0770831c3a5..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_gettriggeredwebjobhistoryslot_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetTriggeredWebJobHistorySlotOperationResponse struct { - HttpResponse *http.Response - Model *TriggeredJobHistory -} - -// GetTriggeredWebJobHistorySlot ... -func (c WebAppsClient) GetTriggeredWebJobHistorySlot(ctx context.Context, id TriggeredWebJobHistoryId) (result GetTriggeredWebJobHistorySlotOperationResponse, err error) { - req, err := c.preparerForGetTriggeredWebJobHistorySlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetTriggeredWebJobHistorySlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetTriggeredWebJobHistorySlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetTriggeredWebJobHistorySlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetTriggeredWebJobHistorySlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetTriggeredWebJobHistorySlot prepares the GetTriggeredWebJobHistorySlot request. -func (c WebAppsClient) preparerForGetTriggeredWebJobHistorySlot(ctx context.Context, id TriggeredWebJobHistoryId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetTriggeredWebJobHistorySlot handles the response to the GetTriggeredWebJobHistorySlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetTriggeredWebJobHistorySlot(resp *http.Response) (result GetTriggeredWebJobHistorySlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_gettriggeredwebjobslot.go b/resource-manager/web/2022-09-01/webapps/method_gettriggeredwebjobslot.go new file mode 100644 index 00000000000..68a68e22e6d --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_gettriggeredwebjobslot.go @@ -0,0 +1,51 @@ +package webapps + +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 GetTriggeredWebJobSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *TriggeredWebJob +} + +// GetTriggeredWebJobSlot ... +func (c WebAppsClient) GetTriggeredWebJobSlot(ctx context.Context, id SlotTriggeredWebJobId) (result GetTriggeredWebJobSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_gettriggeredwebjobslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_gettriggeredwebjobslot_autorest.go deleted file mode 100644 index 73706b6e9e0..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_gettriggeredwebjobslot_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetTriggeredWebJobSlotOperationResponse struct { - HttpResponse *http.Response - Model *TriggeredWebJob -} - -// GetTriggeredWebJobSlot ... -func (c WebAppsClient) GetTriggeredWebJobSlot(ctx context.Context, id SlotTriggeredWebJobId) (result GetTriggeredWebJobSlotOperationResponse, err error) { - req, err := c.preparerForGetTriggeredWebJobSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetTriggeredWebJobSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetTriggeredWebJobSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetTriggeredWebJobSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetTriggeredWebJobSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetTriggeredWebJobSlot prepares the GetTriggeredWebJobSlot request. -func (c WebAppsClient) preparerForGetTriggeredWebJobSlot(ctx context.Context, id SlotTriggeredWebJobId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetTriggeredWebJobSlot handles the response to the GetTriggeredWebJobSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetTriggeredWebJobSlot(resp *http.Response) (result GetTriggeredWebJobSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getvnetconnection.go b/resource-manager/web/2022-09-01/webapps/method_getvnetconnection.go new file mode 100644 index 00000000000..2655067d8d1 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getvnetconnection.go @@ -0,0 +1,51 @@ +package webapps + +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 GetVnetConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetInfoResource +} + +// GetVnetConnection ... +func (c WebAppsClient) GetVnetConnection(ctx context.Context, id VirtualNetworkConnectionId) (result GetVnetConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getvnetconnection_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getvnetconnection_autorest.go deleted file mode 100644 index 9de3eb1b070..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getvnetconnection_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetVnetConnectionOperationResponse struct { - HttpResponse *http.Response - Model *VnetInfoResource -} - -// GetVnetConnection ... -func (c WebAppsClient) GetVnetConnection(ctx context.Context, id VirtualNetworkConnectionId) (result GetVnetConnectionOperationResponse, err error) { - req, err := c.preparerForGetVnetConnection(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetVnetConnection", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetVnetConnection", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetVnetConnection(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetVnetConnection", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetVnetConnection prepares the GetVnetConnection request. -func (c WebAppsClient) preparerForGetVnetConnection(ctx context.Context, id VirtualNetworkConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetVnetConnection handles the response to the GetVnetConnection request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetVnetConnection(resp *http.Response) (result GetVnetConnectionOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getvnetconnectiongateway.go b/resource-manager/web/2022-09-01/webapps/method_getvnetconnectiongateway.go new file mode 100644 index 00000000000..b2a46b0cb5a --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getvnetconnectiongateway.go @@ -0,0 +1,51 @@ +package webapps + +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 GetVnetConnectionGatewayOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetGateway +} + +// GetVnetConnectionGateway ... +func (c WebAppsClient) GetVnetConnectionGateway(ctx context.Context, id GatewayId) (result GetVnetConnectionGatewayOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getvnetconnectiongateway_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getvnetconnectiongateway_autorest.go deleted file mode 100644 index 9e219a4c874..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getvnetconnectiongateway_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetVnetConnectionGatewayOperationResponse struct { - HttpResponse *http.Response - Model *VnetGateway -} - -// GetVnetConnectionGateway ... -func (c WebAppsClient) GetVnetConnectionGateway(ctx context.Context, id GatewayId) (result GetVnetConnectionGatewayOperationResponse, err error) { - req, err := c.preparerForGetVnetConnectionGateway(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetVnetConnectionGateway", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetVnetConnectionGateway", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetVnetConnectionGateway(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetVnetConnectionGateway", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetVnetConnectionGateway prepares the GetVnetConnectionGateway request. -func (c WebAppsClient) preparerForGetVnetConnectionGateway(ctx context.Context, id GatewayId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetVnetConnectionGateway handles the response to the GetVnetConnectionGateway request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetVnetConnectionGateway(resp *http.Response) (result GetVnetConnectionGatewayOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getvnetconnectiongatewayslot.go b/resource-manager/web/2022-09-01/webapps/method_getvnetconnectiongatewayslot.go new file mode 100644 index 00000000000..68c517f3a70 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getvnetconnectiongatewayslot.go @@ -0,0 +1,51 @@ +package webapps + +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 GetVnetConnectionGatewaySlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetGateway +} + +// GetVnetConnectionGatewaySlot ... +func (c WebAppsClient) GetVnetConnectionGatewaySlot(ctx context.Context, id SlotVirtualNetworkConnectionGatewayId) (result GetVnetConnectionGatewaySlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getvnetconnectiongatewayslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getvnetconnectiongatewayslot_autorest.go deleted file mode 100644 index 04c52ff1c0c..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getvnetconnectiongatewayslot_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetVnetConnectionGatewaySlotOperationResponse struct { - HttpResponse *http.Response - Model *VnetGateway -} - -// GetVnetConnectionGatewaySlot ... -func (c WebAppsClient) GetVnetConnectionGatewaySlot(ctx context.Context, id SlotVirtualNetworkConnectionGatewayId) (result GetVnetConnectionGatewaySlotOperationResponse, err error) { - req, err := c.preparerForGetVnetConnectionGatewaySlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetVnetConnectionGatewaySlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetVnetConnectionGatewaySlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetVnetConnectionGatewaySlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetVnetConnectionGatewaySlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetVnetConnectionGatewaySlot prepares the GetVnetConnectionGatewaySlot request. -func (c WebAppsClient) preparerForGetVnetConnectionGatewaySlot(ctx context.Context, id SlotVirtualNetworkConnectionGatewayId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetVnetConnectionGatewaySlot handles the response to the GetVnetConnectionGatewaySlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetVnetConnectionGatewaySlot(resp *http.Response) (result GetVnetConnectionGatewaySlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getvnetconnectionslot.go b/resource-manager/web/2022-09-01/webapps/method_getvnetconnectionslot.go new file mode 100644 index 00000000000..8e7672a83ed --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getvnetconnectionslot.go @@ -0,0 +1,51 @@ +package webapps + +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 GetVnetConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetInfoResource +} + +// GetVnetConnectionSlot ... +func (c WebAppsClient) GetVnetConnectionSlot(ctx context.Context, id SlotVirtualNetworkConnectionId) (result GetVnetConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getvnetconnectionslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getvnetconnectionslot_autorest.go deleted file mode 100644 index 7f9a3015e15..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getvnetconnectionslot_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetVnetConnectionSlotOperationResponse struct { - HttpResponse *http.Response - Model *VnetInfoResource -} - -// GetVnetConnectionSlot ... -func (c WebAppsClient) GetVnetConnectionSlot(ctx context.Context, id SlotVirtualNetworkConnectionId) (result GetVnetConnectionSlotOperationResponse, err error) { - req, err := c.preparerForGetVnetConnectionSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetVnetConnectionSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetVnetConnectionSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetVnetConnectionSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetVnetConnectionSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetVnetConnectionSlot prepares the GetVnetConnectionSlot request. -func (c WebAppsClient) preparerForGetVnetConnectionSlot(ctx context.Context, id SlotVirtualNetworkConnectionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetVnetConnectionSlot handles the response to the GetVnetConnectionSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetVnetConnectionSlot(resp *http.Response) (result GetVnetConnectionSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getwebjob.go b/resource-manager/web/2022-09-01/webapps/method_getwebjob.go new file mode 100644 index 00000000000..31c2b012ae0 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getwebjob.go @@ -0,0 +1,51 @@ +package webapps + +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 GetWebJobOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WebJob +} + +// GetWebJob ... +func (c WebAppsClient) GetWebJob(ctx context.Context, id WebJobId) (result GetWebJobOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getwebjob_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getwebjob_autorest.go deleted file mode 100644 index 24f354eae1d..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getwebjob_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetWebJobOperationResponse struct { - HttpResponse *http.Response - Model *WebJob -} - -// GetWebJob ... -func (c WebAppsClient) GetWebJob(ctx context.Context, id WebJobId) (result GetWebJobOperationResponse, err error) { - req, err := c.preparerForGetWebJob(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetWebJob", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetWebJob", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetWebJob(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetWebJob", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetWebJob prepares the GetWebJob request. -func (c WebAppsClient) preparerForGetWebJob(ctx context.Context, id WebJobId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetWebJob handles the response to the GetWebJob request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetWebJob(resp *http.Response) (result GetWebJobOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getwebjobslot.go b/resource-manager/web/2022-09-01/webapps/method_getwebjobslot.go new file mode 100644 index 00000000000..3502e6db858 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getwebjobslot.go @@ -0,0 +1,51 @@ +package webapps + +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 GetWebJobSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WebJob +} + +// GetWebJobSlot ... +func (c WebAppsClient) GetWebJobSlot(ctx context.Context, id SlotWebJobId) (result GetWebJobSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getwebjobslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getwebjobslot_autorest.go deleted file mode 100644 index 8ffc7329f2c..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getwebjobslot_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetWebJobSlotOperationResponse struct { - HttpResponse *http.Response - Model *WebJob -} - -// GetWebJobSlot ... -func (c WebAppsClient) GetWebJobSlot(ctx context.Context, id SlotWebJobId) (result GetWebJobSlotOperationResponse, err error) { - req, err := c.preparerForGetWebJobSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetWebJobSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetWebJobSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetWebJobSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetWebJobSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetWebJobSlot prepares the GetWebJobSlot request. -func (c WebAppsClient) preparerForGetWebJobSlot(ctx context.Context, id SlotWebJobId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetWebJobSlot handles the response to the GetWebJobSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetWebJobSlot(resp *http.Response) (result GetWebJobSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getwebsitecontainerlogs.go b/resource-manager/web/2022-09-01/webapps/method_getwebsitecontainerlogs.go new file mode 100644 index 00000000000..e2e9c73bfff --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getwebsitecontainerlogs.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetWebSiteContainerLogsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]byte +} + +// GetWebSiteContainerLogs ... +func (c WebAppsClient) GetWebSiteContainerLogs(ctx context.Context, id SiteId) (result GetWebSiteContainerLogsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/containerlogs", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getwebsitecontainerlogs_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getwebsitecontainerlogs_autorest.go deleted file mode 100644 index 7e9a64ade71..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getwebsitecontainerlogs_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetWebSiteContainerLogsOperationResponse struct { - HttpResponse *http.Response - Model *[]byte -} - -// GetWebSiteContainerLogs ... -func (c WebAppsClient) GetWebSiteContainerLogs(ctx context.Context, id SiteId) (result GetWebSiteContainerLogsOperationResponse, err error) { - req, err := c.preparerForGetWebSiteContainerLogs(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetWebSiteContainerLogs", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetWebSiteContainerLogs", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetWebSiteContainerLogs(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetWebSiteContainerLogs", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetWebSiteContainerLogs prepares the GetWebSiteContainerLogs request. -func (c WebAppsClient) preparerForGetWebSiteContainerLogs(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/containerlogs", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetWebSiteContainerLogs handles the response to the GetWebSiteContainerLogs request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetWebSiteContainerLogs(resp *http.Response) (result GetWebSiteContainerLogsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getwebsitecontainerlogsslot.go b/resource-manager/web/2022-09-01/webapps/method_getwebsitecontainerlogsslot.go new file mode 100644 index 00000000000..7c22f1e7282 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getwebsitecontainerlogsslot.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "fmt" + "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 GetWebSiteContainerLogsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]byte +} + +// GetWebSiteContainerLogsSlot ... +func (c WebAppsClient) GetWebSiteContainerLogsSlot(ctx context.Context, id SlotId) (result GetWebSiteContainerLogsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/containerlogs", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getwebsitecontainerlogsslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getwebsitecontainerlogsslot_autorest.go deleted file mode 100644 index 2eeb778851f..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getwebsitecontainerlogsslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetWebSiteContainerLogsSlotOperationResponse struct { - HttpResponse *http.Response - Model *[]byte -} - -// GetWebSiteContainerLogsSlot ... -func (c WebAppsClient) GetWebSiteContainerLogsSlot(ctx context.Context, id SlotId) (result GetWebSiteContainerLogsSlotOperationResponse, err error) { - req, err := c.preparerForGetWebSiteContainerLogsSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetWebSiteContainerLogsSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetWebSiteContainerLogsSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetWebSiteContainerLogsSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetWebSiteContainerLogsSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetWebSiteContainerLogsSlot prepares the GetWebSiteContainerLogsSlot request. -func (c WebAppsClient) preparerForGetWebSiteContainerLogsSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/containerlogs", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetWebSiteContainerLogsSlot handles the response to the GetWebSiteContainerLogsSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetWebSiteContainerLogsSlot(resp *http.Response) (result GetWebSiteContainerLogsSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_getworkflow.go b/resource-manager/web/2022-09-01/webapps/method_getworkflow.go new file mode 100644 index 00000000000..11d349a78f4 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_getworkflow.go @@ -0,0 +1,51 @@ +package webapps + +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 GetWorkflowOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkflowEnvelope +} + +// GetWorkflow ... +func (c WebAppsClient) GetWorkflow(ctx context.Context, id WorkflowId) (result GetWorkflowOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_getworkflow_autorest.go b/resource-manager/web/2022-09-01/webapps/method_getworkflow_autorest.go deleted file mode 100644 index 2a3e228b85a..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_getworkflow_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetWorkflowOperationResponse struct { - HttpResponse *http.Response - Model *WorkflowEnvelope -} - -// GetWorkflow ... -func (c WebAppsClient) GetWorkflow(ctx context.Context, id WorkflowId) (result GetWorkflowOperationResponse, err error) { - req, err := c.preparerForGetWorkflow(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetWorkflow", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetWorkflow", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetWorkflow(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "GetWorkflow", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetWorkflow prepares the GetWorkflow request. -func (c WebAppsClient) preparerForGetWorkflow(ctx context.Context, id WorkflowId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetWorkflow handles the response to the GetWorkflow request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForGetWorkflow(resp *http.Response) (result GetWorkflowOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_installsiteextension.go b/resource-manager/web/2022-09-01/webapps/method_installsiteextension.go new file mode 100644 index 00000000000..67c525a5dc5 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_installsiteextension.go @@ -0,0 +1,70 @@ +package webapps + +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 InstallSiteExtensionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// InstallSiteExtension ... +func (c WebAppsClient) InstallSiteExtension(ctx context.Context, id SiteExtensionId) (result InstallSiteExtensionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + 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 +} + +// InstallSiteExtensionThenPoll performs InstallSiteExtension then polls until it's completed +func (c WebAppsClient) InstallSiteExtensionThenPoll(ctx context.Context, id SiteExtensionId) error { + result, err := c.InstallSiteExtension(ctx, id) + if err != nil { + return fmt.Errorf("performing InstallSiteExtension: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after InstallSiteExtension: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/webapps/method_installsiteextension_autorest.go b/resource-manager/web/2022-09-01/webapps/method_installsiteextension_autorest.go deleted file mode 100644 index 0132f47f554..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_installsiteextension_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type InstallSiteExtensionOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// InstallSiteExtension ... -func (c WebAppsClient) InstallSiteExtension(ctx context.Context, id SiteExtensionId) (result InstallSiteExtensionOperationResponse, err error) { - req, err := c.preparerForInstallSiteExtension(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "InstallSiteExtension", nil, "Failure preparing request") - return - } - - result, err = c.senderForInstallSiteExtension(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "InstallSiteExtension", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// InstallSiteExtensionThenPoll performs InstallSiteExtension then polls until it's completed -func (c WebAppsClient) InstallSiteExtensionThenPoll(ctx context.Context, id SiteExtensionId) error { - result, err := c.InstallSiteExtension(ctx, id) - if err != nil { - return fmt.Errorf("performing InstallSiteExtension: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after InstallSiteExtension: %+v", err) - } - - return nil -} - -// preparerForInstallSiteExtension prepares the InstallSiteExtension request. -func (c WebAppsClient) preparerForInstallSiteExtension(ctx context.Context, id SiteExtensionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForInstallSiteExtension sends the InstallSiteExtension request. The method will close the -// http.Response Body if it receives an error. -func (c WebAppsClient) senderForInstallSiteExtension(ctx context.Context, req *http.Request) (future InstallSiteExtensionOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_installsiteextensionslot.go b/resource-manager/web/2022-09-01/webapps/method_installsiteextensionslot.go new file mode 100644 index 00000000000..80fccf04657 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_installsiteextensionslot.go @@ -0,0 +1,70 @@ +package webapps + +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 InstallSiteExtensionSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// InstallSiteExtensionSlot ... +func (c WebAppsClient) InstallSiteExtensionSlot(ctx context.Context, id SlotSiteExtensionId) (result InstallSiteExtensionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + 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 +} + +// InstallSiteExtensionSlotThenPoll performs InstallSiteExtensionSlot then polls until it's completed +func (c WebAppsClient) InstallSiteExtensionSlotThenPoll(ctx context.Context, id SlotSiteExtensionId) error { + result, err := c.InstallSiteExtensionSlot(ctx, id) + if err != nil { + return fmt.Errorf("performing InstallSiteExtensionSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after InstallSiteExtensionSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/webapps/method_installsiteextensionslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_installsiteextensionslot_autorest.go deleted file mode 100644 index 0a7c0db8c04..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_installsiteextensionslot_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type InstallSiteExtensionSlotOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// InstallSiteExtensionSlot ... -func (c WebAppsClient) InstallSiteExtensionSlot(ctx context.Context, id SlotSiteExtensionId) (result InstallSiteExtensionSlotOperationResponse, err error) { - req, err := c.preparerForInstallSiteExtensionSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "InstallSiteExtensionSlot", nil, "Failure preparing request") - return - } - - result, err = c.senderForInstallSiteExtensionSlot(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "InstallSiteExtensionSlot", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// InstallSiteExtensionSlotThenPoll performs InstallSiteExtensionSlot then polls until it's completed -func (c WebAppsClient) InstallSiteExtensionSlotThenPoll(ctx context.Context, id SlotSiteExtensionId) error { - result, err := c.InstallSiteExtensionSlot(ctx, id) - if err != nil { - return fmt.Errorf("performing InstallSiteExtensionSlot: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after InstallSiteExtensionSlot: %+v", err) - } - - return nil -} - -// preparerForInstallSiteExtensionSlot prepares the InstallSiteExtensionSlot request. -func (c WebAppsClient) preparerForInstallSiteExtensionSlot(ctx context.Context, id SlotSiteExtensionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForInstallSiteExtensionSlot sends the InstallSiteExtensionSlot request. The method will close the -// http.Response Body if it receives an error. -func (c WebAppsClient) senderForInstallSiteExtensionSlot(ctx context.Context, req *http.Request) (future InstallSiteExtensionSlotOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_iscloneable.go b/resource-manager/web/2022-09-01/webapps/method_iscloneable.go new file mode 100644 index 00000000000..32724a828c9 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_iscloneable.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 IsCloneableOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteCloneability +} + +// IsCloneable ... +func (c WebAppsClient) IsCloneable(ctx context.Context, id SiteId) (result IsCloneableOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/iscloneable", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_iscloneable_autorest.go b/resource-manager/web/2022-09-01/webapps/method_iscloneable_autorest.go deleted file mode 100644 index 426f4cae557..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_iscloneable_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type IsCloneableOperationResponse struct { - HttpResponse *http.Response - Model *SiteCloneability -} - -// IsCloneable ... -func (c WebAppsClient) IsCloneable(ctx context.Context, id SiteId) (result IsCloneableOperationResponse, err error) { - req, err := c.preparerForIsCloneable(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "IsCloneable", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "IsCloneable", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForIsCloneable(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "IsCloneable", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForIsCloneable prepares the IsCloneable request. -func (c WebAppsClient) preparerForIsCloneable(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/iscloneable", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForIsCloneable handles the response to the IsCloneable request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForIsCloneable(resp *http.Response) (result IsCloneableOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_iscloneableslot.go b/resource-manager/web/2022-09-01/webapps/method_iscloneableslot.go new file mode 100644 index 00000000000..77529a6c13b --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_iscloneableslot.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 IsCloneableSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteCloneability +} + +// IsCloneableSlot ... +func (c WebAppsClient) IsCloneableSlot(ctx context.Context, id SlotId) (result IsCloneableSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/iscloneable", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_iscloneableslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_iscloneableslot_autorest.go deleted file mode 100644 index 8ff2e269ea0..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_iscloneableslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type IsCloneableSlotOperationResponse struct { - HttpResponse *http.Response - Model *SiteCloneability -} - -// IsCloneableSlot ... -func (c WebAppsClient) IsCloneableSlot(ctx context.Context, id SlotId) (result IsCloneableSlotOperationResponse, err error) { - req, err := c.preparerForIsCloneableSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "IsCloneableSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "IsCloneableSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForIsCloneableSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "IsCloneableSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForIsCloneableSlot prepares the IsCloneableSlot request. -func (c WebAppsClient) preparerForIsCloneableSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/iscloneable", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForIsCloneableSlot handles the response to the IsCloneableSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForIsCloneableSlot(resp *http.Response) (result IsCloneableSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_list.go b/resource-manager/web/2022-09-01/webapps/method_list.go new file mode 100644 index 00000000000..e81e9719fc6 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_list.go @@ -0,0 +1,90 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Site +} + +type ListCompleteResult struct { + Items []Site +} + +// List ... +func (c WebAppsClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/sites", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Site `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c WebAppsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, SiteOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate SiteOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Site, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_list_autorest.go b/resource-manager/web/2022-09-01/webapps/method_list_autorest.go deleted file mode 100644 index eeb8f7085ed..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_list_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListOperationResponse struct { - HttpResponse *http.Response - Model *[]Site - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []Site -} - -func (r ListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// List ... -func (c WebAppsClient) List(ctx context.Context, id commonids.SubscriptionId) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c WebAppsClient) preparerForList(ctx context.Context, id commonids.SubscriptionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Web/sites", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c WebAppsClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForList handles the response to the List request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []Site `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { - req, err := c.preparerForListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c WebAppsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, SiteOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate SiteOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]Site, 0) - - page, err := c.List(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listapplicationsettings.go b/resource-manager/web/2022-09-01/webapps/method_listapplicationsettings.go new file mode 100644 index 00000000000..c90e8cc438d --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listapplicationsettings.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListApplicationSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// ListApplicationSettings ... +func (c WebAppsClient) ListApplicationSettings(ctx context.Context, id SiteId) (result ListApplicationSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/appSettings/list", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listapplicationsettings_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listapplicationsettings_autorest.go deleted file mode 100644 index 1de0876ca51..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listapplicationsettings_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListApplicationSettingsOperationResponse struct { - HttpResponse *http.Response - Model *StringDictionary -} - -// ListApplicationSettings ... -func (c WebAppsClient) ListApplicationSettings(ctx context.Context, id SiteId) (result ListApplicationSettingsOperationResponse, err error) { - req, err := c.preparerForListApplicationSettings(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListApplicationSettings", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListApplicationSettings", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListApplicationSettings(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListApplicationSettings", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListApplicationSettings prepares the ListApplicationSettings request. -func (c WebAppsClient) preparerForListApplicationSettings(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/appSettings/list", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListApplicationSettings handles the response to the ListApplicationSettings request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListApplicationSettings(resp *http.Response) (result ListApplicationSettingsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listapplicationsettingsslot.go b/resource-manager/web/2022-09-01/webapps/method_listapplicationsettingsslot.go new file mode 100644 index 00000000000..8edf1da4c46 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listapplicationsettingsslot.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListApplicationSettingsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// ListApplicationSettingsSlot ... +func (c WebAppsClient) ListApplicationSettingsSlot(ctx context.Context, id SlotId) (result ListApplicationSettingsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/appSettings/list", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listapplicationsettingsslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listapplicationsettingsslot_autorest.go deleted file mode 100644 index 4f524305a94..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listapplicationsettingsslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListApplicationSettingsSlotOperationResponse struct { - HttpResponse *http.Response - Model *StringDictionary -} - -// ListApplicationSettingsSlot ... -func (c WebAppsClient) ListApplicationSettingsSlot(ctx context.Context, id SlotId) (result ListApplicationSettingsSlotOperationResponse, err error) { - req, err := c.preparerForListApplicationSettingsSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListApplicationSettingsSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListApplicationSettingsSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListApplicationSettingsSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListApplicationSettingsSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListApplicationSettingsSlot prepares the ListApplicationSettingsSlot request. -func (c WebAppsClient) preparerForListApplicationSettingsSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/appSettings/list", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListApplicationSettingsSlot handles the response to the ListApplicationSettingsSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListApplicationSettingsSlot(resp *http.Response) (result ListApplicationSettingsSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listazurestorageaccounts.go b/resource-manager/web/2022-09-01/webapps/method_listazurestorageaccounts.go new file mode 100644 index 00000000000..212989366eb --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listazurestorageaccounts.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListAzureStorageAccountsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AzureStoragePropertyDictionaryResource +} + +// ListAzureStorageAccounts ... +func (c WebAppsClient) ListAzureStorageAccounts(ctx context.Context, id SiteId) (result ListAzureStorageAccountsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/azurestorageaccounts/list", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listazurestorageaccounts_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listazurestorageaccounts_autorest.go deleted file mode 100644 index 67b754def78..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listazurestorageaccounts_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListAzureStorageAccountsOperationResponse struct { - HttpResponse *http.Response - Model *AzureStoragePropertyDictionaryResource -} - -// ListAzureStorageAccounts ... -func (c WebAppsClient) ListAzureStorageAccounts(ctx context.Context, id SiteId) (result ListAzureStorageAccountsOperationResponse, err error) { - req, err := c.preparerForListAzureStorageAccounts(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListAzureStorageAccounts", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListAzureStorageAccounts", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListAzureStorageAccounts(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListAzureStorageAccounts", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListAzureStorageAccounts prepares the ListAzureStorageAccounts request. -func (c WebAppsClient) preparerForListAzureStorageAccounts(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/azurestorageaccounts/list", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListAzureStorageAccounts handles the response to the ListAzureStorageAccounts request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListAzureStorageAccounts(resp *http.Response) (result ListAzureStorageAccountsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listazurestorageaccountsslot.go b/resource-manager/web/2022-09-01/webapps/method_listazurestorageaccountsslot.go new file mode 100644 index 00000000000..d303f9b84d3 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listazurestorageaccountsslot.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListAzureStorageAccountsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AzureStoragePropertyDictionaryResource +} + +// ListAzureStorageAccountsSlot ... +func (c WebAppsClient) ListAzureStorageAccountsSlot(ctx context.Context, id SlotId) (result ListAzureStorageAccountsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/azurestorageaccounts/list", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listazurestorageaccountsslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listazurestorageaccountsslot_autorest.go deleted file mode 100644 index 5c10fd40997..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listazurestorageaccountsslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListAzureStorageAccountsSlotOperationResponse struct { - HttpResponse *http.Response - Model *AzureStoragePropertyDictionaryResource -} - -// ListAzureStorageAccountsSlot ... -func (c WebAppsClient) ListAzureStorageAccountsSlot(ctx context.Context, id SlotId) (result ListAzureStorageAccountsSlotOperationResponse, err error) { - req, err := c.preparerForListAzureStorageAccountsSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListAzureStorageAccountsSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListAzureStorageAccountsSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListAzureStorageAccountsSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListAzureStorageAccountsSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListAzureStorageAccountsSlot prepares the ListAzureStorageAccountsSlot request. -func (c WebAppsClient) preparerForListAzureStorageAccountsSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/azurestorageaccounts/list", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListAzureStorageAccountsSlot handles the response to the ListAzureStorageAccountsSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListAzureStorageAccountsSlot(resp *http.Response) (result ListAzureStorageAccountsSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listbackups.go b/resource-manager/web/2022-09-01/webapps/method_listbackups.go new file mode 100644 index 00000000000..a52a0c0c999 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listbackups.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListBackupsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]BackupItem +} + +type ListBackupsCompleteResult struct { + Items []BackupItem +} + +// ListBackups ... +func (c WebAppsClient) ListBackups(ctx context.Context, id SiteId) (result ListBackupsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/backups", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]BackupItem `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBackupsComplete retrieves all the results into a single object +func (c WebAppsClient) ListBackupsComplete(ctx context.Context, id SiteId) (ListBackupsCompleteResult, error) { + return c.ListBackupsCompleteMatchingPredicate(ctx, id, BackupItemOperationPredicate{}) +} + +// ListBackupsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListBackupsCompleteMatchingPredicate(ctx context.Context, id SiteId, predicate BackupItemOperationPredicate) (result ListBackupsCompleteResult, err error) { + items := make([]BackupItem, 0) + + resp, err := c.ListBackups(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListBackupsCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listbackups_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listbackups_autorest.go deleted file mode 100644 index e1f96d37ab6..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listbackups_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListBackupsOperationResponse struct { - HttpResponse *http.Response - Model *[]BackupItem - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListBackupsOperationResponse, error) -} - -type ListBackupsCompleteResult struct { - Items []BackupItem -} - -func (r ListBackupsOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListBackupsOperationResponse) LoadMore(ctx context.Context) (resp ListBackupsOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListBackups ... -func (c WebAppsClient) ListBackups(ctx context.Context, id SiteId) (resp ListBackupsOperationResponse, err error) { - req, err := c.preparerForListBackups(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListBackups", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListBackups", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListBackups(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListBackups", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListBackups prepares the ListBackups request. -func (c WebAppsClient) preparerForListBackups(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/backups", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListBackupsWithNextLink prepares the ListBackups request with the given nextLink token. -func (c WebAppsClient) preparerForListBackupsWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListBackups handles the response to the ListBackups request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListBackups(resp *http.Response) (result ListBackupsOperationResponse, err error) { - type page struct { - Values []BackupItem `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListBackupsOperationResponse, err error) { - req, err := c.preparerForListBackupsWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListBackups", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListBackups", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListBackups(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListBackups", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListBackupsComplete retrieves all of the results into a single object -func (c WebAppsClient) ListBackupsComplete(ctx context.Context, id SiteId) (ListBackupsCompleteResult, error) { - return c.ListBackupsCompleteMatchingPredicate(ctx, id, BackupItemOperationPredicate{}) -} - -// ListBackupsCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListBackupsCompleteMatchingPredicate(ctx context.Context, id SiteId, predicate BackupItemOperationPredicate) (resp ListBackupsCompleteResult, err error) { - items := make([]BackupItem, 0) - - page, err := c.ListBackups(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListBackupsCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listbackupsslot.go b/resource-manager/web/2022-09-01/webapps/method_listbackupsslot.go new file mode 100644 index 00000000000..c41089f5bb0 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listbackupsslot.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListBackupsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]BackupItem +} + +type ListBackupsSlotCompleteResult struct { + Items []BackupItem +} + +// ListBackupsSlot ... +func (c WebAppsClient) ListBackupsSlot(ctx context.Context, id SlotId) (result ListBackupsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/backups", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]BackupItem `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBackupsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListBackupsSlotComplete(ctx context.Context, id SlotId) (ListBackupsSlotCompleteResult, error) { + return c.ListBackupsSlotCompleteMatchingPredicate(ctx, id, BackupItemOperationPredicate{}) +} + +// ListBackupsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListBackupsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate BackupItemOperationPredicate) (result ListBackupsSlotCompleteResult, err error) { + items := make([]BackupItem, 0) + + resp, err := c.ListBackupsSlot(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListBackupsSlotCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listbackupsslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listbackupsslot_autorest.go deleted file mode 100644 index ed8979282c3..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listbackupsslot_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListBackupsSlotOperationResponse struct { - HttpResponse *http.Response - Model *[]BackupItem - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListBackupsSlotOperationResponse, error) -} - -type ListBackupsSlotCompleteResult struct { - Items []BackupItem -} - -func (r ListBackupsSlotOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListBackupsSlotOperationResponse) LoadMore(ctx context.Context) (resp ListBackupsSlotOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListBackupsSlot ... -func (c WebAppsClient) ListBackupsSlot(ctx context.Context, id SlotId) (resp ListBackupsSlotOperationResponse, err error) { - req, err := c.preparerForListBackupsSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListBackupsSlot", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListBackupsSlot", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListBackupsSlot(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListBackupsSlot", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListBackupsSlot prepares the ListBackupsSlot request. -func (c WebAppsClient) preparerForListBackupsSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/backups", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListBackupsSlotWithNextLink prepares the ListBackupsSlot request with the given nextLink token. -func (c WebAppsClient) preparerForListBackupsSlotWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListBackupsSlot handles the response to the ListBackupsSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListBackupsSlot(resp *http.Response) (result ListBackupsSlotOperationResponse, err error) { - type page struct { - Values []BackupItem `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListBackupsSlotOperationResponse, err error) { - req, err := c.preparerForListBackupsSlotWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListBackupsSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListBackupsSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListBackupsSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListBackupsSlot", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListBackupsSlotComplete retrieves all of the results into a single object -func (c WebAppsClient) ListBackupsSlotComplete(ctx context.Context, id SlotId) (ListBackupsSlotCompleteResult, error) { - return c.ListBackupsSlotCompleteMatchingPredicate(ctx, id, BackupItemOperationPredicate{}) -} - -// ListBackupsSlotCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListBackupsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate BackupItemOperationPredicate) (resp ListBackupsSlotCompleteResult, err error) { - items := make([]BackupItem, 0) - - page, err := c.ListBackupsSlot(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListBackupsSlotCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listbackupstatussecrets.go b/resource-manager/web/2022-09-01/webapps/method_listbackupstatussecrets.go new file mode 100644 index 00000000000..09b7bbd7069 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listbackupstatussecrets.go @@ -0,0 +1,56 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListBackupStatusSecretsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BackupItem +} + +// ListBackupStatusSecrets ... +func (c WebAppsClient) ListBackupStatusSecrets(ctx context.Context, id BackupId, input BackupRequest) (result ListBackupStatusSecretsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/list", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listbackupstatussecrets_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listbackupstatussecrets_autorest.go deleted file mode 100644 index 20a379a22e0..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listbackupstatussecrets_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListBackupStatusSecretsOperationResponse struct { - HttpResponse *http.Response - Model *BackupItem -} - -// ListBackupStatusSecrets ... -func (c WebAppsClient) ListBackupStatusSecrets(ctx context.Context, id BackupId, input BackupRequest) (result ListBackupStatusSecretsOperationResponse, err error) { - req, err := c.preparerForListBackupStatusSecrets(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListBackupStatusSecrets", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListBackupStatusSecrets", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListBackupStatusSecrets(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListBackupStatusSecrets", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListBackupStatusSecrets prepares the ListBackupStatusSecrets request. -func (c WebAppsClient) preparerForListBackupStatusSecrets(ctx context.Context, id BackupId, input BackupRequest) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/list", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListBackupStatusSecrets handles the response to the ListBackupStatusSecrets request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListBackupStatusSecrets(resp *http.Response) (result ListBackupStatusSecretsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listbackupstatussecretsslot.go b/resource-manager/web/2022-09-01/webapps/method_listbackupstatussecretsslot.go new file mode 100644 index 00000000000..469ca380a37 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listbackupstatussecretsslot.go @@ -0,0 +1,56 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListBackupStatusSecretsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BackupItem +} + +// ListBackupStatusSecretsSlot ... +func (c WebAppsClient) ListBackupStatusSecretsSlot(ctx context.Context, id SlotBackupId, input BackupRequest) (result ListBackupStatusSecretsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/list", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listbackupstatussecretsslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listbackupstatussecretsslot_autorest.go deleted file mode 100644 index be81a92e390..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listbackupstatussecretsslot_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListBackupStatusSecretsSlotOperationResponse struct { - HttpResponse *http.Response - Model *BackupItem -} - -// ListBackupStatusSecretsSlot ... -func (c WebAppsClient) ListBackupStatusSecretsSlot(ctx context.Context, id SlotBackupId, input BackupRequest) (result ListBackupStatusSecretsSlotOperationResponse, err error) { - req, err := c.preparerForListBackupStatusSecretsSlot(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListBackupStatusSecretsSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListBackupStatusSecretsSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListBackupStatusSecretsSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListBackupStatusSecretsSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListBackupStatusSecretsSlot prepares the ListBackupStatusSecretsSlot request. -func (c WebAppsClient) preparerForListBackupStatusSecretsSlot(ctx context.Context, id SlotBackupId, input BackupRequest) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/list", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListBackupStatusSecretsSlot handles the response to the ListBackupStatusSecretsSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListBackupStatusSecretsSlot(resp *http.Response) (result ListBackupStatusSecretsSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listbasicpublishingcredentialspolicies.go b/resource-manager/web/2022-09-01/webapps/method_listbasicpublishingcredentialspolicies.go new file mode 100644 index 00000000000..cbd70f2f1db --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listbasicpublishingcredentialspolicies.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListBasicPublishingCredentialsPoliciesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CsmPublishingCredentialsPoliciesEntity +} + +type ListBasicPublishingCredentialsPoliciesCompleteResult struct { + Items []CsmPublishingCredentialsPoliciesEntity +} + +// ListBasicPublishingCredentialsPolicies ... +func (c WebAppsClient) ListBasicPublishingCredentialsPolicies(ctx context.Context, id SiteId) (result ListBasicPublishingCredentialsPoliciesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/basicPublishingCredentialsPolicies", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]CsmPublishingCredentialsPoliciesEntity `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBasicPublishingCredentialsPoliciesComplete retrieves all the results into a single object +func (c WebAppsClient) ListBasicPublishingCredentialsPoliciesComplete(ctx context.Context, id SiteId) (ListBasicPublishingCredentialsPoliciesCompleteResult, error) { + return c.ListBasicPublishingCredentialsPoliciesCompleteMatchingPredicate(ctx, id, CsmPublishingCredentialsPoliciesEntityOperationPredicate{}) +} + +// ListBasicPublishingCredentialsPoliciesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListBasicPublishingCredentialsPoliciesCompleteMatchingPredicate(ctx context.Context, id SiteId, predicate CsmPublishingCredentialsPoliciesEntityOperationPredicate) (result ListBasicPublishingCredentialsPoliciesCompleteResult, err error) { + items := make([]CsmPublishingCredentialsPoliciesEntity, 0) + + resp, err := c.ListBasicPublishingCredentialsPolicies(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListBasicPublishingCredentialsPoliciesCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listbasicpublishingcredentialspolicies_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listbasicpublishingcredentialspolicies_autorest.go deleted file mode 100644 index 51598e6d393..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listbasicpublishingcredentialspolicies_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListBasicPublishingCredentialsPoliciesOperationResponse struct { - HttpResponse *http.Response - Model *[]CsmPublishingCredentialsPoliciesEntity - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListBasicPublishingCredentialsPoliciesOperationResponse, error) -} - -type ListBasicPublishingCredentialsPoliciesCompleteResult struct { - Items []CsmPublishingCredentialsPoliciesEntity -} - -func (r ListBasicPublishingCredentialsPoliciesOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListBasicPublishingCredentialsPoliciesOperationResponse) LoadMore(ctx context.Context) (resp ListBasicPublishingCredentialsPoliciesOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListBasicPublishingCredentialsPolicies ... -func (c WebAppsClient) ListBasicPublishingCredentialsPolicies(ctx context.Context, id SiteId) (resp ListBasicPublishingCredentialsPoliciesOperationResponse, err error) { - req, err := c.preparerForListBasicPublishingCredentialsPolicies(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListBasicPublishingCredentialsPolicies", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListBasicPublishingCredentialsPolicies", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListBasicPublishingCredentialsPolicies(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListBasicPublishingCredentialsPolicies", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListBasicPublishingCredentialsPolicies prepares the ListBasicPublishingCredentialsPolicies request. -func (c WebAppsClient) preparerForListBasicPublishingCredentialsPolicies(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/basicPublishingCredentialsPolicies", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListBasicPublishingCredentialsPoliciesWithNextLink prepares the ListBasicPublishingCredentialsPolicies request with the given nextLink token. -func (c WebAppsClient) preparerForListBasicPublishingCredentialsPoliciesWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListBasicPublishingCredentialsPolicies handles the response to the ListBasicPublishingCredentialsPolicies request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListBasicPublishingCredentialsPolicies(resp *http.Response) (result ListBasicPublishingCredentialsPoliciesOperationResponse, err error) { - type page struct { - Values []CsmPublishingCredentialsPoliciesEntity `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListBasicPublishingCredentialsPoliciesOperationResponse, err error) { - req, err := c.preparerForListBasicPublishingCredentialsPoliciesWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListBasicPublishingCredentialsPolicies", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListBasicPublishingCredentialsPolicies", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListBasicPublishingCredentialsPolicies(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListBasicPublishingCredentialsPolicies", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListBasicPublishingCredentialsPoliciesComplete retrieves all of the results into a single object -func (c WebAppsClient) ListBasicPublishingCredentialsPoliciesComplete(ctx context.Context, id SiteId) (ListBasicPublishingCredentialsPoliciesCompleteResult, error) { - return c.ListBasicPublishingCredentialsPoliciesCompleteMatchingPredicate(ctx, id, CsmPublishingCredentialsPoliciesEntityOperationPredicate{}) -} - -// ListBasicPublishingCredentialsPoliciesCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListBasicPublishingCredentialsPoliciesCompleteMatchingPredicate(ctx context.Context, id SiteId, predicate CsmPublishingCredentialsPoliciesEntityOperationPredicate) (resp ListBasicPublishingCredentialsPoliciesCompleteResult, err error) { - items := make([]CsmPublishingCredentialsPoliciesEntity, 0) - - page, err := c.ListBasicPublishingCredentialsPolicies(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListBasicPublishingCredentialsPoliciesCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listbasicpublishingcredentialspoliciesslot.go b/resource-manager/web/2022-09-01/webapps/method_listbasicpublishingcredentialspoliciesslot.go new file mode 100644 index 00000000000..1f5b79b9ea1 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listbasicpublishingcredentialspoliciesslot.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListBasicPublishingCredentialsPoliciesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CsmPublishingCredentialsPoliciesEntity +} + +type ListBasicPublishingCredentialsPoliciesSlotCompleteResult struct { + Items []CsmPublishingCredentialsPoliciesEntity +} + +// ListBasicPublishingCredentialsPoliciesSlot ... +func (c WebAppsClient) ListBasicPublishingCredentialsPoliciesSlot(ctx context.Context, id SlotId) (result ListBasicPublishingCredentialsPoliciesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/basicPublishingCredentialsPolicies", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]CsmPublishingCredentialsPoliciesEntity `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBasicPublishingCredentialsPoliciesSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListBasicPublishingCredentialsPoliciesSlotComplete(ctx context.Context, id SlotId) (ListBasicPublishingCredentialsPoliciesSlotCompleteResult, error) { + return c.ListBasicPublishingCredentialsPoliciesSlotCompleteMatchingPredicate(ctx, id, CsmPublishingCredentialsPoliciesEntityOperationPredicate{}) +} + +// ListBasicPublishingCredentialsPoliciesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListBasicPublishingCredentialsPoliciesSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate CsmPublishingCredentialsPoliciesEntityOperationPredicate) (result ListBasicPublishingCredentialsPoliciesSlotCompleteResult, err error) { + items := make([]CsmPublishingCredentialsPoliciesEntity, 0) + + resp, err := c.ListBasicPublishingCredentialsPoliciesSlot(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListBasicPublishingCredentialsPoliciesSlotCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listbasicpublishingcredentialspoliciesslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listbasicpublishingcredentialspoliciesslot_autorest.go deleted file mode 100644 index fd3f39daf96..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listbasicpublishingcredentialspoliciesslot_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListBasicPublishingCredentialsPoliciesSlotOperationResponse struct { - HttpResponse *http.Response - Model *[]CsmPublishingCredentialsPoliciesEntity - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListBasicPublishingCredentialsPoliciesSlotOperationResponse, error) -} - -type ListBasicPublishingCredentialsPoliciesSlotCompleteResult struct { - Items []CsmPublishingCredentialsPoliciesEntity -} - -func (r ListBasicPublishingCredentialsPoliciesSlotOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListBasicPublishingCredentialsPoliciesSlotOperationResponse) LoadMore(ctx context.Context) (resp ListBasicPublishingCredentialsPoliciesSlotOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListBasicPublishingCredentialsPoliciesSlot ... -func (c WebAppsClient) ListBasicPublishingCredentialsPoliciesSlot(ctx context.Context, id SlotId) (resp ListBasicPublishingCredentialsPoliciesSlotOperationResponse, err error) { - req, err := c.preparerForListBasicPublishingCredentialsPoliciesSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListBasicPublishingCredentialsPoliciesSlot", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListBasicPublishingCredentialsPoliciesSlot", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListBasicPublishingCredentialsPoliciesSlot(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListBasicPublishingCredentialsPoliciesSlot", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListBasicPublishingCredentialsPoliciesSlot prepares the ListBasicPublishingCredentialsPoliciesSlot request. -func (c WebAppsClient) preparerForListBasicPublishingCredentialsPoliciesSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/basicPublishingCredentialsPolicies", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListBasicPublishingCredentialsPoliciesSlotWithNextLink prepares the ListBasicPublishingCredentialsPoliciesSlot request with the given nextLink token. -func (c WebAppsClient) preparerForListBasicPublishingCredentialsPoliciesSlotWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListBasicPublishingCredentialsPoliciesSlot handles the response to the ListBasicPublishingCredentialsPoliciesSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListBasicPublishingCredentialsPoliciesSlot(resp *http.Response) (result ListBasicPublishingCredentialsPoliciesSlotOperationResponse, err error) { - type page struct { - Values []CsmPublishingCredentialsPoliciesEntity `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListBasicPublishingCredentialsPoliciesSlotOperationResponse, err error) { - req, err := c.preparerForListBasicPublishingCredentialsPoliciesSlotWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListBasicPublishingCredentialsPoliciesSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListBasicPublishingCredentialsPoliciesSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListBasicPublishingCredentialsPoliciesSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListBasicPublishingCredentialsPoliciesSlot", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListBasicPublishingCredentialsPoliciesSlotComplete retrieves all of the results into a single object -func (c WebAppsClient) ListBasicPublishingCredentialsPoliciesSlotComplete(ctx context.Context, id SlotId) (ListBasicPublishingCredentialsPoliciesSlotCompleteResult, error) { - return c.ListBasicPublishingCredentialsPoliciesSlotCompleteMatchingPredicate(ctx, id, CsmPublishingCredentialsPoliciesEntityOperationPredicate{}) -} - -// ListBasicPublishingCredentialsPoliciesSlotCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListBasicPublishingCredentialsPoliciesSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate CsmPublishingCredentialsPoliciesEntityOperationPredicate) (resp ListBasicPublishingCredentialsPoliciesSlotCompleteResult, err error) { - items := make([]CsmPublishingCredentialsPoliciesEntity, 0) - - page, err := c.ListBasicPublishingCredentialsPoliciesSlot(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListBasicPublishingCredentialsPoliciesSlotCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listbyresourcegroup.go b/resource-manager/web/2022-09-01/webapps/method_listbyresourcegroup.go new file mode 100644 index 00000000000..f3d6fd38978 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listbyresourcegroup.go @@ -0,0 +1,118 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "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 ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Site +} + +type ListByResourceGroupCompleteResult struct { + Items []Site +} + +type ListByResourceGroupOperationOptions struct { + IncludeSlots *bool +} + +func DefaultListByResourceGroupOperationOptions() ListByResourceGroupOperationOptions { + return ListByResourceGroupOperationOptions{} +} + +func (o ListByResourceGroupOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByResourceGroupOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByResourceGroupOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.IncludeSlots != nil { + out.Append("includeSlots", fmt.Sprintf("%v", *o.IncludeSlots)) + } + return &out +} + +// ListByResourceGroup ... +func (c WebAppsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/sites", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Site `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c WebAppsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, options, SiteOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions, predicate SiteOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]Site, 0) + + resp, err := c.ListByResourceGroup(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listbyresourcegroup_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listbyresourcegroup_autorest.go deleted file mode 100644 index f90a895f1e7..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listbyresourcegroup_autorest.go +++ /dev/null @@ -1,216 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListByResourceGroupOperationResponse struct { - HttpResponse *http.Response - Model *[]Site - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListByResourceGroupOperationResponse, error) -} - -type ListByResourceGroupCompleteResult struct { - Items []Site -} - -func (r ListByResourceGroupOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListByResourceGroupOperationResponse) LoadMore(ctx context.Context) (resp ListByResourceGroupOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListByResourceGroupOperationOptions struct { - IncludeSlots *bool -} - -func DefaultListByResourceGroupOperationOptions() ListByResourceGroupOperationOptions { - return ListByResourceGroupOperationOptions{} -} - -func (o ListByResourceGroupOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListByResourceGroupOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.IncludeSlots != nil { - out["includeSlots"] = *o.IncludeSlots - } - - return out -} - -// ListByResourceGroup ... -func (c WebAppsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (resp ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroup(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListByResourceGroup", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListByResourceGroup(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListByResourceGroup", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListByResourceGroup prepares the ListByResourceGroup request. -func (c WebAppsClient) preparerForListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/providers/Microsoft.Web/sites", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListByResourceGroupWithNextLink prepares the ListByResourceGroup request with the given nextLink token. -func (c WebAppsClient) preparerForListByResourceGroupWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListByResourceGroup handles the response to the ListByResourceGroup request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListByResourceGroup(resp *http.Response) (result ListByResourceGroupOperationResponse, err error) { - type page struct { - Values []Site `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListByResourceGroupOperationResponse, err error) { - req, err := c.preparerForListByResourceGroupWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListByResourceGroup", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListByResourceGroup(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListByResourceGroup", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListByResourceGroupComplete retrieves all of the results into a single object -func (c WebAppsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (ListByResourceGroupCompleteResult, error) { - return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, options, SiteOperationPredicate{}) -} - -// ListByResourceGroupCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions, predicate SiteOperationPredicate) (resp ListByResourceGroupCompleteResult, err error) { - items := make([]Site, 0) - - page, err := c.ListByResourceGroup(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListByResourceGroupCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listconfigurations.go b/resource-manager/web/2022-09-01/webapps/method_listconfigurations.go new file mode 100644 index 00000000000..30dea4dc34e --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listconfigurations.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListConfigurationsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SiteConfigResource +} + +type ListConfigurationsCompleteResult struct { + Items []SiteConfigResource +} + +// ListConfigurations ... +func (c WebAppsClient) ListConfigurations(ctx context.Context, id SiteId) (result ListConfigurationsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/config", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]SiteConfigResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListConfigurationsComplete retrieves all the results into a single object +func (c WebAppsClient) ListConfigurationsComplete(ctx context.Context, id SiteId) (ListConfigurationsCompleteResult, error) { + return c.ListConfigurationsCompleteMatchingPredicate(ctx, id, SiteConfigResourceOperationPredicate{}) +} + +// ListConfigurationsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListConfigurationsCompleteMatchingPredicate(ctx context.Context, id SiteId, predicate SiteConfigResourceOperationPredicate) (result ListConfigurationsCompleteResult, err error) { + items := make([]SiteConfigResource, 0) + + resp, err := c.ListConfigurations(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListConfigurationsCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listconfigurations_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listconfigurations_autorest.go deleted file mode 100644 index 115c7127d01..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listconfigurations_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListConfigurationsOperationResponse struct { - HttpResponse *http.Response - Model *[]SiteConfigResource - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListConfigurationsOperationResponse, error) -} - -type ListConfigurationsCompleteResult struct { - Items []SiteConfigResource -} - -func (r ListConfigurationsOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListConfigurationsOperationResponse) LoadMore(ctx context.Context) (resp ListConfigurationsOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListConfigurations ... -func (c WebAppsClient) ListConfigurations(ctx context.Context, id SiteId) (resp ListConfigurationsOperationResponse, err error) { - req, err := c.preparerForListConfigurations(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListConfigurations", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListConfigurations", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListConfigurations(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListConfigurations", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListConfigurations prepares the ListConfigurations request. -func (c WebAppsClient) preparerForListConfigurations(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListConfigurationsWithNextLink prepares the ListConfigurations request with the given nextLink token. -func (c WebAppsClient) preparerForListConfigurationsWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListConfigurations handles the response to the ListConfigurations request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListConfigurations(resp *http.Response) (result ListConfigurationsOperationResponse, err error) { - type page struct { - Values []SiteConfigResource `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListConfigurationsOperationResponse, err error) { - req, err := c.preparerForListConfigurationsWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListConfigurations", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListConfigurations", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListConfigurations(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListConfigurations", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListConfigurationsComplete retrieves all of the results into a single object -func (c WebAppsClient) ListConfigurationsComplete(ctx context.Context, id SiteId) (ListConfigurationsCompleteResult, error) { - return c.ListConfigurationsCompleteMatchingPredicate(ctx, id, SiteConfigResourceOperationPredicate{}) -} - -// ListConfigurationsCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListConfigurationsCompleteMatchingPredicate(ctx context.Context, id SiteId, predicate SiteConfigResourceOperationPredicate) (resp ListConfigurationsCompleteResult, err error) { - items := make([]SiteConfigResource, 0) - - page, err := c.ListConfigurations(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListConfigurationsCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listconfigurationsnapshotinfo.go b/resource-manager/web/2022-09-01/webapps/method_listconfigurationsnapshotinfo.go new file mode 100644 index 00000000000..874ad2dffdc --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listconfigurationsnapshotinfo.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListConfigurationSnapshotInfoOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SiteConfigurationSnapshotInfo +} + +type ListConfigurationSnapshotInfoCompleteResult struct { + Items []SiteConfigurationSnapshotInfo +} + +// ListConfigurationSnapshotInfo ... +func (c WebAppsClient) ListConfigurationSnapshotInfo(ctx context.Context, id SiteId) (result ListConfigurationSnapshotInfoOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/config/web/snapshots", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]SiteConfigurationSnapshotInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListConfigurationSnapshotInfoComplete retrieves all the results into a single object +func (c WebAppsClient) ListConfigurationSnapshotInfoComplete(ctx context.Context, id SiteId) (ListConfigurationSnapshotInfoCompleteResult, error) { + return c.ListConfigurationSnapshotInfoCompleteMatchingPredicate(ctx, id, SiteConfigurationSnapshotInfoOperationPredicate{}) +} + +// ListConfigurationSnapshotInfoCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListConfigurationSnapshotInfoCompleteMatchingPredicate(ctx context.Context, id SiteId, predicate SiteConfigurationSnapshotInfoOperationPredicate) (result ListConfigurationSnapshotInfoCompleteResult, err error) { + items := make([]SiteConfigurationSnapshotInfo, 0) + + resp, err := c.ListConfigurationSnapshotInfo(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListConfigurationSnapshotInfoCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listconfigurationsnapshotinfo_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listconfigurationsnapshotinfo_autorest.go deleted file mode 100644 index 77a9f5ee051..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listconfigurationsnapshotinfo_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListConfigurationSnapshotInfoOperationResponse struct { - HttpResponse *http.Response - Model *[]SiteConfigurationSnapshotInfo - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListConfigurationSnapshotInfoOperationResponse, error) -} - -type ListConfigurationSnapshotInfoCompleteResult struct { - Items []SiteConfigurationSnapshotInfo -} - -func (r ListConfigurationSnapshotInfoOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListConfigurationSnapshotInfoOperationResponse) LoadMore(ctx context.Context) (resp ListConfigurationSnapshotInfoOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListConfigurationSnapshotInfo ... -func (c WebAppsClient) ListConfigurationSnapshotInfo(ctx context.Context, id SiteId) (resp ListConfigurationSnapshotInfoOperationResponse, err error) { - req, err := c.preparerForListConfigurationSnapshotInfo(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListConfigurationSnapshotInfo", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListConfigurationSnapshotInfo", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListConfigurationSnapshotInfo(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListConfigurationSnapshotInfo", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListConfigurationSnapshotInfo prepares the ListConfigurationSnapshotInfo request. -func (c WebAppsClient) preparerForListConfigurationSnapshotInfo(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/web/snapshots", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListConfigurationSnapshotInfoWithNextLink prepares the ListConfigurationSnapshotInfo request with the given nextLink token. -func (c WebAppsClient) preparerForListConfigurationSnapshotInfoWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListConfigurationSnapshotInfo handles the response to the ListConfigurationSnapshotInfo request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListConfigurationSnapshotInfo(resp *http.Response) (result ListConfigurationSnapshotInfoOperationResponse, err error) { - type page struct { - Values []SiteConfigurationSnapshotInfo `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListConfigurationSnapshotInfoOperationResponse, err error) { - req, err := c.preparerForListConfigurationSnapshotInfoWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListConfigurationSnapshotInfo", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListConfigurationSnapshotInfo", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListConfigurationSnapshotInfo(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListConfigurationSnapshotInfo", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListConfigurationSnapshotInfoComplete retrieves all of the results into a single object -func (c WebAppsClient) ListConfigurationSnapshotInfoComplete(ctx context.Context, id SiteId) (ListConfigurationSnapshotInfoCompleteResult, error) { - return c.ListConfigurationSnapshotInfoCompleteMatchingPredicate(ctx, id, SiteConfigurationSnapshotInfoOperationPredicate{}) -} - -// ListConfigurationSnapshotInfoCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListConfigurationSnapshotInfoCompleteMatchingPredicate(ctx context.Context, id SiteId, predicate SiteConfigurationSnapshotInfoOperationPredicate) (resp ListConfigurationSnapshotInfoCompleteResult, err error) { - items := make([]SiteConfigurationSnapshotInfo, 0) - - page, err := c.ListConfigurationSnapshotInfo(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListConfigurationSnapshotInfoCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listconfigurationsnapshotinfoslot.go b/resource-manager/web/2022-09-01/webapps/method_listconfigurationsnapshotinfoslot.go new file mode 100644 index 00000000000..06fcfbd2d11 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listconfigurationsnapshotinfoslot.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListConfigurationSnapshotInfoSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SiteConfigurationSnapshotInfo +} + +type ListConfigurationSnapshotInfoSlotCompleteResult struct { + Items []SiteConfigurationSnapshotInfo +} + +// ListConfigurationSnapshotInfoSlot ... +func (c WebAppsClient) ListConfigurationSnapshotInfoSlot(ctx context.Context, id SlotId) (result ListConfigurationSnapshotInfoSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/config/web/snapshots", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]SiteConfigurationSnapshotInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListConfigurationSnapshotInfoSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListConfigurationSnapshotInfoSlotComplete(ctx context.Context, id SlotId) (ListConfigurationSnapshotInfoSlotCompleteResult, error) { + return c.ListConfigurationSnapshotInfoSlotCompleteMatchingPredicate(ctx, id, SiteConfigurationSnapshotInfoOperationPredicate{}) +} + +// ListConfigurationSnapshotInfoSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListConfigurationSnapshotInfoSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate SiteConfigurationSnapshotInfoOperationPredicate) (result ListConfigurationSnapshotInfoSlotCompleteResult, err error) { + items := make([]SiteConfigurationSnapshotInfo, 0) + + resp, err := c.ListConfigurationSnapshotInfoSlot(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListConfigurationSnapshotInfoSlotCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listconfigurationsnapshotinfoslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listconfigurationsnapshotinfoslot_autorest.go deleted file mode 100644 index 6428960906b..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listconfigurationsnapshotinfoslot_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListConfigurationSnapshotInfoSlotOperationResponse struct { - HttpResponse *http.Response - Model *[]SiteConfigurationSnapshotInfo - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListConfigurationSnapshotInfoSlotOperationResponse, error) -} - -type ListConfigurationSnapshotInfoSlotCompleteResult struct { - Items []SiteConfigurationSnapshotInfo -} - -func (r ListConfigurationSnapshotInfoSlotOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListConfigurationSnapshotInfoSlotOperationResponse) LoadMore(ctx context.Context) (resp ListConfigurationSnapshotInfoSlotOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListConfigurationSnapshotInfoSlot ... -func (c WebAppsClient) ListConfigurationSnapshotInfoSlot(ctx context.Context, id SlotId) (resp ListConfigurationSnapshotInfoSlotOperationResponse, err error) { - req, err := c.preparerForListConfigurationSnapshotInfoSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListConfigurationSnapshotInfoSlot", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListConfigurationSnapshotInfoSlot", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListConfigurationSnapshotInfoSlot(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListConfigurationSnapshotInfoSlot", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListConfigurationSnapshotInfoSlot prepares the ListConfigurationSnapshotInfoSlot request. -func (c WebAppsClient) preparerForListConfigurationSnapshotInfoSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/web/snapshots", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListConfigurationSnapshotInfoSlotWithNextLink prepares the ListConfigurationSnapshotInfoSlot request with the given nextLink token. -func (c WebAppsClient) preparerForListConfigurationSnapshotInfoSlotWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListConfigurationSnapshotInfoSlot handles the response to the ListConfigurationSnapshotInfoSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListConfigurationSnapshotInfoSlot(resp *http.Response) (result ListConfigurationSnapshotInfoSlotOperationResponse, err error) { - type page struct { - Values []SiteConfigurationSnapshotInfo `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListConfigurationSnapshotInfoSlotOperationResponse, err error) { - req, err := c.preparerForListConfigurationSnapshotInfoSlotWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListConfigurationSnapshotInfoSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListConfigurationSnapshotInfoSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListConfigurationSnapshotInfoSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListConfigurationSnapshotInfoSlot", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListConfigurationSnapshotInfoSlotComplete retrieves all of the results into a single object -func (c WebAppsClient) ListConfigurationSnapshotInfoSlotComplete(ctx context.Context, id SlotId) (ListConfigurationSnapshotInfoSlotCompleteResult, error) { - return c.ListConfigurationSnapshotInfoSlotCompleteMatchingPredicate(ctx, id, SiteConfigurationSnapshotInfoOperationPredicate{}) -} - -// ListConfigurationSnapshotInfoSlotCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListConfigurationSnapshotInfoSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate SiteConfigurationSnapshotInfoOperationPredicate) (resp ListConfigurationSnapshotInfoSlotCompleteResult, err error) { - items := make([]SiteConfigurationSnapshotInfo, 0) - - page, err := c.ListConfigurationSnapshotInfoSlot(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListConfigurationSnapshotInfoSlotCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listconfigurationsslot.go b/resource-manager/web/2022-09-01/webapps/method_listconfigurationsslot.go new file mode 100644 index 00000000000..dbea40fd661 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listconfigurationsslot.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListConfigurationsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SiteConfigResource +} + +type ListConfigurationsSlotCompleteResult struct { + Items []SiteConfigResource +} + +// ListConfigurationsSlot ... +func (c WebAppsClient) ListConfigurationsSlot(ctx context.Context, id SlotId) (result ListConfigurationsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/config", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]SiteConfigResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListConfigurationsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListConfigurationsSlotComplete(ctx context.Context, id SlotId) (ListConfigurationsSlotCompleteResult, error) { + return c.ListConfigurationsSlotCompleteMatchingPredicate(ctx, id, SiteConfigResourceOperationPredicate{}) +} + +// ListConfigurationsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListConfigurationsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate SiteConfigResourceOperationPredicate) (result ListConfigurationsSlotCompleteResult, err error) { + items := make([]SiteConfigResource, 0) + + resp, err := c.ListConfigurationsSlot(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListConfigurationsSlotCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listconfigurationsslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listconfigurationsslot_autorest.go deleted file mode 100644 index 5051152bdf5..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listconfigurationsslot_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListConfigurationsSlotOperationResponse struct { - HttpResponse *http.Response - Model *[]SiteConfigResource - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListConfigurationsSlotOperationResponse, error) -} - -type ListConfigurationsSlotCompleteResult struct { - Items []SiteConfigResource -} - -func (r ListConfigurationsSlotOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListConfigurationsSlotOperationResponse) LoadMore(ctx context.Context) (resp ListConfigurationsSlotOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListConfigurationsSlot ... -func (c WebAppsClient) ListConfigurationsSlot(ctx context.Context, id SlotId) (resp ListConfigurationsSlotOperationResponse, err error) { - req, err := c.preparerForListConfigurationsSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListConfigurationsSlot", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListConfigurationsSlot", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListConfigurationsSlot(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListConfigurationsSlot", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListConfigurationsSlot prepares the ListConfigurationsSlot request. -func (c WebAppsClient) preparerForListConfigurationsSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListConfigurationsSlotWithNextLink prepares the ListConfigurationsSlot request with the given nextLink token. -func (c WebAppsClient) preparerForListConfigurationsSlotWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListConfigurationsSlot handles the response to the ListConfigurationsSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListConfigurationsSlot(resp *http.Response) (result ListConfigurationsSlotOperationResponse, err error) { - type page struct { - Values []SiteConfigResource `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListConfigurationsSlotOperationResponse, err error) { - req, err := c.preparerForListConfigurationsSlotWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListConfigurationsSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListConfigurationsSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListConfigurationsSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListConfigurationsSlot", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListConfigurationsSlotComplete retrieves all of the results into a single object -func (c WebAppsClient) ListConfigurationsSlotComplete(ctx context.Context, id SlotId) (ListConfigurationsSlotCompleteResult, error) { - return c.ListConfigurationsSlotCompleteMatchingPredicate(ctx, id, SiteConfigResourceOperationPredicate{}) -} - -// ListConfigurationsSlotCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListConfigurationsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate SiteConfigResourceOperationPredicate) (resp ListConfigurationsSlotCompleteResult, err error) { - items := make([]SiteConfigResource, 0) - - page, err := c.ListConfigurationsSlot(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListConfigurationsSlotCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listconnectionstrings.go b/resource-manager/web/2022-09-01/webapps/method_listconnectionstrings.go new file mode 100644 index 00000000000..34943831d9a --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listconnectionstrings.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListConnectionStringsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ConnectionStringDictionary +} + +// ListConnectionStrings ... +func (c WebAppsClient) ListConnectionStrings(ctx context.Context, id SiteId) (result ListConnectionStringsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/connectionStrings/list", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listconnectionstrings_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listconnectionstrings_autorest.go deleted file mode 100644 index eb33c1a32ed..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listconnectionstrings_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListConnectionStringsOperationResponse struct { - HttpResponse *http.Response - Model *ConnectionStringDictionary -} - -// ListConnectionStrings ... -func (c WebAppsClient) ListConnectionStrings(ctx context.Context, id SiteId) (result ListConnectionStringsOperationResponse, err error) { - req, err := c.preparerForListConnectionStrings(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListConnectionStrings", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListConnectionStrings", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListConnectionStrings(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListConnectionStrings", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListConnectionStrings prepares the ListConnectionStrings request. -func (c WebAppsClient) preparerForListConnectionStrings(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/connectionStrings/list", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListConnectionStrings handles the response to the ListConnectionStrings request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListConnectionStrings(resp *http.Response) (result ListConnectionStringsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listconnectionstringsslot.go b/resource-manager/web/2022-09-01/webapps/method_listconnectionstringsslot.go new file mode 100644 index 00000000000..e5a71875614 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listconnectionstringsslot.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListConnectionStringsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ConnectionStringDictionary +} + +// ListConnectionStringsSlot ... +func (c WebAppsClient) ListConnectionStringsSlot(ctx context.Context, id SlotId) (result ListConnectionStringsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/connectionStrings/list", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listconnectionstringsslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listconnectionstringsslot_autorest.go deleted file mode 100644 index e3e3e7289d1..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listconnectionstringsslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListConnectionStringsSlotOperationResponse struct { - HttpResponse *http.Response - Model *ConnectionStringDictionary -} - -// ListConnectionStringsSlot ... -func (c WebAppsClient) ListConnectionStringsSlot(ctx context.Context, id SlotId) (result ListConnectionStringsSlotOperationResponse, err error) { - req, err := c.preparerForListConnectionStringsSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListConnectionStringsSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListConnectionStringsSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListConnectionStringsSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListConnectionStringsSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListConnectionStringsSlot prepares the ListConnectionStringsSlot request. -func (c WebAppsClient) preparerForListConnectionStringsSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/connectionStrings/list", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListConnectionStringsSlot handles the response to the ListConnectionStringsSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListConnectionStringsSlot(resp *http.Response) (result ListConnectionStringsSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listcontinuouswebjobs.go b/resource-manager/web/2022-09-01/webapps/method_listcontinuouswebjobs.go new file mode 100644 index 00000000000..0b0c90a8fab --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listcontinuouswebjobs.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListContinuousWebJobsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ContinuousWebJob +} + +type ListContinuousWebJobsCompleteResult struct { + Items []ContinuousWebJob +} + +// ListContinuousWebJobs ... +func (c WebAppsClient) ListContinuousWebJobs(ctx context.Context, id SiteId) (result ListContinuousWebJobsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/continuousWebJobs", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ContinuousWebJob `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListContinuousWebJobsComplete retrieves all the results into a single object +func (c WebAppsClient) ListContinuousWebJobsComplete(ctx context.Context, id SiteId) (ListContinuousWebJobsCompleteResult, error) { + return c.ListContinuousWebJobsCompleteMatchingPredicate(ctx, id, ContinuousWebJobOperationPredicate{}) +} + +// ListContinuousWebJobsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListContinuousWebJobsCompleteMatchingPredicate(ctx context.Context, id SiteId, predicate ContinuousWebJobOperationPredicate) (result ListContinuousWebJobsCompleteResult, err error) { + items := make([]ContinuousWebJob, 0) + + resp, err := c.ListContinuousWebJobs(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListContinuousWebJobsCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listcontinuouswebjobs_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listcontinuouswebjobs_autorest.go deleted file mode 100644 index 2f01c8a5733..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listcontinuouswebjobs_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListContinuousWebJobsOperationResponse struct { - HttpResponse *http.Response - Model *[]ContinuousWebJob - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListContinuousWebJobsOperationResponse, error) -} - -type ListContinuousWebJobsCompleteResult struct { - Items []ContinuousWebJob -} - -func (r ListContinuousWebJobsOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListContinuousWebJobsOperationResponse) LoadMore(ctx context.Context) (resp ListContinuousWebJobsOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListContinuousWebJobs ... -func (c WebAppsClient) ListContinuousWebJobs(ctx context.Context, id SiteId) (resp ListContinuousWebJobsOperationResponse, err error) { - req, err := c.preparerForListContinuousWebJobs(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListContinuousWebJobs", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListContinuousWebJobs", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListContinuousWebJobs(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListContinuousWebJobs", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListContinuousWebJobs prepares the ListContinuousWebJobs request. -func (c WebAppsClient) preparerForListContinuousWebJobs(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/continuousWebJobs", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListContinuousWebJobsWithNextLink prepares the ListContinuousWebJobs request with the given nextLink token. -func (c WebAppsClient) preparerForListContinuousWebJobsWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListContinuousWebJobs handles the response to the ListContinuousWebJobs request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListContinuousWebJobs(resp *http.Response) (result ListContinuousWebJobsOperationResponse, err error) { - type page struct { - Values []ContinuousWebJob `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListContinuousWebJobsOperationResponse, err error) { - req, err := c.preparerForListContinuousWebJobsWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListContinuousWebJobs", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListContinuousWebJobs", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListContinuousWebJobs(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListContinuousWebJobs", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListContinuousWebJobsComplete retrieves all of the results into a single object -func (c WebAppsClient) ListContinuousWebJobsComplete(ctx context.Context, id SiteId) (ListContinuousWebJobsCompleteResult, error) { - return c.ListContinuousWebJobsCompleteMatchingPredicate(ctx, id, ContinuousWebJobOperationPredicate{}) -} - -// ListContinuousWebJobsCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListContinuousWebJobsCompleteMatchingPredicate(ctx context.Context, id SiteId, predicate ContinuousWebJobOperationPredicate) (resp ListContinuousWebJobsCompleteResult, err error) { - items := make([]ContinuousWebJob, 0) - - page, err := c.ListContinuousWebJobs(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListContinuousWebJobsCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listcontinuouswebjobsslot.go b/resource-manager/web/2022-09-01/webapps/method_listcontinuouswebjobsslot.go new file mode 100644 index 00000000000..7d860d7b6e6 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listcontinuouswebjobsslot.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListContinuousWebJobsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ContinuousWebJob +} + +type ListContinuousWebJobsSlotCompleteResult struct { + Items []ContinuousWebJob +} + +// ListContinuousWebJobsSlot ... +func (c WebAppsClient) ListContinuousWebJobsSlot(ctx context.Context, id SlotId) (result ListContinuousWebJobsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/continuousWebJobs", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ContinuousWebJob `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListContinuousWebJobsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListContinuousWebJobsSlotComplete(ctx context.Context, id SlotId) (ListContinuousWebJobsSlotCompleteResult, error) { + return c.ListContinuousWebJobsSlotCompleteMatchingPredicate(ctx, id, ContinuousWebJobOperationPredicate{}) +} + +// ListContinuousWebJobsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListContinuousWebJobsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate ContinuousWebJobOperationPredicate) (result ListContinuousWebJobsSlotCompleteResult, err error) { + items := make([]ContinuousWebJob, 0) + + resp, err := c.ListContinuousWebJobsSlot(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListContinuousWebJobsSlotCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listcontinuouswebjobsslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listcontinuouswebjobsslot_autorest.go deleted file mode 100644 index e8c3c0ddaa2..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listcontinuouswebjobsslot_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListContinuousWebJobsSlotOperationResponse struct { - HttpResponse *http.Response - Model *[]ContinuousWebJob - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListContinuousWebJobsSlotOperationResponse, error) -} - -type ListContinuousWebJobsSlotCompleteResult struct { - Items []ContinuousWebJob -} - -func (r ListContinuousWebJobsSlotOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListContinuousWebJobsSlotOperationResponse) LoadMore(ctx context.Context) (resp ListContinuousWebJobsSlotOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListContinuousWebJobsSlot ... -func (c WebAppsClient) ListContinuousWebJobsSlot(ctx context.Context, id SlotId) (resp ListContinuousWebJobsSlotOperationResponse, err error) { - req, err := c.preparerForListContinuousWebJobsSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListContinuousWebJobsSlot", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListContinuousWebJobsSlot", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListContinuousWebJobsSlot(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListContinuousWebJobsSlot", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListContinuousWebJobsSlot prepares the ListContinuousWebJobsSlot request. -func (c WebAppsClient) preparerForListContinuousWebJobsSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/continuousWebJobs", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListContinuousWebJobsSlotWithNextLink prepares the ListContinuousWebJobsSlot request with the given nextLink token. -func (c WebAppsClient) preparerForListContinuousWebJobsSlotWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListContinuousWebJobsSlot handles the response to the ListContinuousWebJobsSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListContinuousWebJobsSlot(resp *http.Response) (result ListContinuousWebJobsSlotOperationResponse, err error) { - type page struct { - Values []ContinuousWebJob `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListContinuousWebJobsSlotOperationResponse, err error) { - req, err := c.preparerForListContinuousWebJobsSlotWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListContinuousWebJobsSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListContinuousWebJobsSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListContinuousWebJobsSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListContinuousWebJobsSlot", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListContinuousWebJobsSlotComplete retrieves all of the results into a single object -func (c WebAppsClient) ListContinuousWebJobsSlotComplete(ctx context.Context, id SlotId) (ListContinuousWebJobsSlotCompleteResult, error) { - return c.ListContinuousWebJobsSlotCompleteMatchingPredicate(ctx, id, ContinuousWebJobOperationPredicate{}) -} - -// ListContinuousWebJobsSlotCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListContinuousWebJobsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate ContinuousWebJobOperationPredicate) (resp ListContinuousWebJobsSlotCompleteResult, err error) { - items := make([]ContinuousWebJob, 0) - - page, err := c.ListContinuousWebJobsSlot(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListContinuousWebJobsSlotCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listdeploymentlog.go b/resource-manager/web/2022-09-01/webapps/method_listdeploymentlog.go new file mode 100644 index 00000000000..b3723c328e9 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listdeploymentlog.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListDeploymentLogOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Deployment +} + +// ListDeploymentLog ... +func (c WebAppsClient) ListDeploymentLog(ctx context.Context, id DeploymentId) (result ListDeploymentLogOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/log", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listdeploymentlog_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listdeploymentlog_autorest.go deleted file mode 100644 index ce4cf75f288..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listdeploymentlog_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListDeploymentLogOperationResponse struct { - HttpResponse *http.Response - Model *Deployment -} - -// ListDeploymentLog ... -func (c WebAppsClient) ListDeploymentLog(ctx context.Context, id DeploymentId) (result ListDeploymentLogOperationResponse, err error) { - req, err := c.preparerForListDeploymentLog(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListDeploymentLog", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListDeploymentLog", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListDeploymentLog(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListDeploymentLog", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListDeploymentLog prepares the ListDeploymentLog request. -func (c WebAppsClient) preparerForListDeploymentLog(ctx context.Context, id DeploymentId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/log", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListDeploymentLog handles the response to the ListDeploymentLog request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListDeploymentLog(resp *http.Response) (result ListDeploymentLogOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listdeploymentlogslot.go b/resource-manager/web/2022-09-01/webapps/method_listdeploymentlogslot.go new file mode 100644 index 00000000000..5f4e5ef2e22 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listdeploymentlogslot.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListDeploymentLogSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Deployment +} + +// ListDeploymentLogSlot ... +func (c WebAppsClient) ListDeploymentLogSlot(ctx context.Context, id SlotDeploymentId) (result ListDeploymentLogSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/log", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listdeploymentlogslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listdeploymentlogslot_autorest.go deleted file mode 100644 index 276b6a949e8..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listdeploymentlogslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListDeploymentLogSlotOperationResponse struct { - HttpResponse *http.Response - Model *Deployment -} - -// ListDeploymentLogSlot ... -func (c WebAppsClient) ListDeploymentLogSlot(ctx context.Context, id SlotDeploymentId) (result ListDeploymentLogSlotOperationResponse, err error) { - req, err := c.preparerForListDeploymentLogSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListDeploymentLogSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListDeploymentLogSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListDeploymentLogSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListDeploymentLogSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListDeploymentLogSlot prepares the ListDeploymentLogSlot request. -func (c WebAppsClient) preparerForListDeploymentLogSlot(ctx context.Context, id SlotDeploymentId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/log", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListDeploymentLogSlot handles the response to the ListDeploymentLogSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListDeploymentLogSlot(resp *http.Response) (result ListDeploymentLogSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listdeployments.go b/resource-manager/web/2022-09-01/webapps/method_listdeployments.go new file mode 100644 index 00000000000..f239a891db7 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listdeployments.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListDeploymentsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Deployment +} + +type ListDeploymentsCompleteResult struct { + Items []Deployment +} + +// ListDeployments ... +func (c WebAppsClient) ListDeployments(ctx context.Context, id SiteId) (result ListDeploymentsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/deployments", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Deployment `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListDeploymentsComplete retrieves all the results into a single object +func (c WebAppsClient) ListDeploymentsComplete(ctx context.Context, id SiteId) (ListDeploymentsCompleteResult, error) { + return c.ListDeploymentsCompleteMatchingPredicate(ctx, id, DeploymentOperationPredicate{}) +} + +// ListDeploymentsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListDeploymentsCompleteMatchingPredicate(ctx context.Context, id SiteId, predicate DeploymentOperationPredicate) (result ListDeploymentsCompleteResult, err error) { + items := make([]Deployment, 0) + + resp, err := c.ListDeployments(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListDeploymentsCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listdeployments_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listdeployments_autorest.go deleted file mode 100644 index 8e390d8a0aa..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listdeployments_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListDeploymentsOperationResponse struct { - HttpResponse *http.Response - Model *[]Deployment - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListDeploymentsOperationResponse, error) -} - -type ListDeploymentsCompleteResult struct { - Items []Deployment -} - -func (r ListDeploymentsOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListDeploymentsOperationResponse) LoadMore(ctx context.Context) (resp ListDeploymentsOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListDeployments ... -func (c WebAppsClient) ListDeployments(ctx context.Context, id SiteId) (resp ListDeploymentsOperationResponse, err error) { - req, err := c.preparerForListDeployments(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListDeployments", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListDeployments", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListDeployments(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListDeployments", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListDeployments prepares the ListDeployments request. -func (c WebAppsClient) preparerForListDeployments(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/deployments", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListDeploymentsWithNextLink prepares the ListDeployments request with the given nextLink token. -func (c WebAppsClient) preparerForListDeploymentsWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListDeployments handles the response to the ListDeployments request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListDeployments(resp *http.Response) (result ListDeploymentsOperationResponse, err error) { - type page struct { - Values []Deployment `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListDeploymentsOperationResponse, err error) { - req, err := c.preparerForListDeploymentsWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListDeployments", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListDeployments", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListDeployments(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListDeployments", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListDeploymentsComplete retrieves all of the results into a single object -func (c WebAppsClient) ListDeploymentsComplete(ctx context.Context, id SiteId) (ListDeploymentsCompleteResult, error) { - return c.ListDeploymentsCompleteMatchingPredicate(ctx, id, DeploymentOperationPredicate{}) -} - -// ListDeploymentsCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListDeploymentsCompleteMatchingPredicate(ctx context.Context, id SiteId, predicate DeploymentOperationPredicate) (resp ListDeploymentsCompleteResult, err error) { - items := make([]Deployment, 0) - - page, err := c.ListDeployments(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListDeploymentsCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listdeploymentsslot.go b/resource-manager/web/2022-09-01/webapps/method_listdeploymentsslot.go new file mode 100644 index 00000000000..d8041e645df --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listdeploymentsslot.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListDeploymentsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Deployment +} + +type ListDeploymentsSlotCompleteResult struct { + Items []Deployment +} + +// ListDeploymentsSlot ... +func (c WebAppsClient) ListDeploymentsSlot(ctx context.Context, id SlotId) (result ListDeploymentsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/deployments", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Deployment `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListDeploymentsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListDeploymentsSlotComplete(ctx context.Context, id SlotId) (ListDeploymentsSlotCompleteResult, error) { + return c.ListDeploymentsSlotCompleteMatchingPredicate(ctx, id, DeploymentOperationPredicate{}) +} + +// ListDeploymentsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListDeploymentsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate DeploymentOperationPredicate) (result ListDeploymentsSlotCompleteResult, err error) { + items := make([]Deployment, 0) + + resp, err := c.ListDeploymentsSlot(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListDeploymentsSlotCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listdeploymentsslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listdeploymentsslot_autorest.go deleted file mode 100644 index c61101b1644..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listdeploymentsslot_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListDeploymentsSlotOperationResponse struct { - HttpResponse *http.Response - Model *[]Deployment - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListDeploymentsSlotOperationResponse, error) -} - -type ListDeploymentsSlotCompleteResult struct { - Items []Deployment -} - -func (r ListDeploymentsSlotOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListDeploymentsSlotOperationResponse) LoadMore(ctx context.Context) (resp ListDeploymentsSlotOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListDeploymentsSlot ... -func (c WebAppsClient) ListDeploymentsSlot(ctx context.Context, id SlotId) (resp ListDeploymentsSlotOperationResponse, err error) { - req, err := c.preparerForListDeploymentsSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListDeploymentsSlot", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListDeploymentsSlot", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListDeploymentsSlot(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListDeploymentsSlot", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListDeploymentsSlot prepares the ListDeploymentsSlot request. -func (c WebAppsClient) preparerForListDeploymentsSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/deployments", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListDeploymentsSlotWithNextLink prepares the ListDeploymentsSlot request with the given nextLink token. -func (c WebAppsClient) preparerForListDeploymentsSlotWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListDeploymentsSlot handles the response to the ListDeploymentsSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListDeploymentsSlot(resp *http.Response) (result ListDeploymentsSlotOperationResponse, err error) { - type page struct { - Values []Deployment `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListDeploymentsSlotOperationResponse, err error) { - req, err := c.preparerForListDeploymentsSlotWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListDeploymentsSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListDeploymentsSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListDeploymentsSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListDeploymentsSlot", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListDeploymentsSlotComplete retrieves all of the results into a single object -func (c WebAppsClient) ListDeploymentsSlotComplete(ctx context.Context, id SlotId) (ListDeploymentsSlotCompleteResult, error) { - return c.ListDeploymentsSlotCompleteMatchingPredicate(ctx, id, DeploymentOperationPredicate{}) -} - -// ListDeploymentsSlotCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListDeploymentsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate DeploymentOperationPredicate) (resp ListDeploymentsSlotCompleteResult, err error) { - items := make([]Deployment, 0) - - page, err := c.ListDeploymentsSlot(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListDeploymentsSlotCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listdomainownershipidentifiers.go b/resource-manager/web/2022-09-01/webapps/method_listdomainownershipidentifiers.go new file mode 100644 index 00000000000..3af917f3175 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listdomainownershipidentifiers.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListDomainOwnershipIdentifiersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Identifier +} + +type ListDomainOwnershipIdentifiersCompleteResult struct { + Items []Identifier +} + +// ListDomainOwnershipIdentifiers ... +func (c WebAppsClient) ListDomainOwnershipIdentifiers(ctx context.Context, id SiteId) (result ListDomainOwnershipIdentifiersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/domainOwnershipIdentifiers", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Identifier `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListDomainOwnershipIdentifiersComplete retrieves all the results into a single object +func (c WebAppsClient) ListDomainOwnershipIdentifiersComplete(ctx context.Context, id SiteId) (ListDomainOwnershipIdentifiersCompleteResult, error) { + return c.ListDomainOwnershipIdentifiersCompleteMatchingPredicate(ctx, id, IdentifierOperationPredicate{}) +} + +// ListDomainOwnershipIdentifiersCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListDomainOwnershipIdentifiersCompleteMatchingPredicate(ctx context.Context, id SiteId, predicate IdentifierOperationPredicate) (result ListDomainOwnershipIdentifiersCompleteResult, err error) { + items := make([]Identifier, 0) + + resp, err := c.ListDomainOwnershipIdentifiers(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListDomainOwnershipIdentifiersCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listdomainownershipidentifiers_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listdomainownershipidentifiers_autorest.go deleted file mode 100644 index bcc674970eb..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listdomainownershipidentifiers_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListDomainOwnershipIdentifiersOperationResponse struct { - HttpResponse *http.Response - Model *[]Identifier - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListDomainOwnershipIdentifiersOperationResponse, error) -} - -type ListDomainOwnershipIdentifiersCompleteResult struct { - Items []Identifier -} - -func (r ListDomainOwnershipIdentifiersOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListDomainOwnershipIdentifiersOperationResponse) LoadMore(ctx context.Context) (resp ListDomainOwnershipIdentifiersOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListDomainOwnershipIdentifiers ... -func (c WebAppsClient) ListDomainOwnershipIdentifiers(ctx context.Context, id SiteId) (resp ListDomainOwnershipIdentifiersOperationResponse, err error) { - req, err := c.preparerForListDomainOwnershipIdentifiers(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListDomainOwnershipIdentifiers", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListDomainOwnershipIdentifiers", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListDomainOwnershipIdentifiers(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListDomainOwnershipIdentifiers", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListDomainOwnershipIdentifiers prepares the ListDomainOwnershipIdentifiers request. -func (c WebAppsClient) preparerForListDomainOwnershipIdentifiers(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/domainOwnershipIdentifiers", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListDomainOwnershipIdentifiersWithNextLink prepares the ListDomainOwnershipIdentifiers request with the given nextLink token. -func (c WebAppsClient) preparerForListDomainOwnershipIdentifiersWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListDomainOwnershipIdentifiers handles the response to the ListDomainOwnershipIdentifiers request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListDomainOwnershipIdentifiers(resp *http.Response) (result ListDomainOwnershipIdentifiersOperationResponse, err error) { - type page struct { - Values []Identifier `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListDomainOwnershipIdentifiersOperationResponse, err error) { - req, err := c.preparerForListDomainOwnershipIdentifiersWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListDomainOwnershipIdentifiers", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListDomainOwnershipIdentifiers", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListDomainOwnershipIdentifiers(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListDomainOwnershipIdentifiers", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListDomainOwnershipIdentifiersComplete retrieves all of the results into a single object -func (c WebAppsClient) ListDomainOwnershipIdentifiersComplete(ctx context.Context, id SiteId) (ListDomainOwnershipIdentifiersCompleteResult, error) { - return c.ListDomainOwnershipIdentifiersCompleteMatchingPredicate(ctx, id, IdentifierOperationPredicate{}) -} - -// ListDomainOwnershipIdentifiersCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListDomainOwnershipIdentifiersCompleteMatchingPredicate(ctx context.Context, id SiteId, predicate IdentifierOperationPredicate) (resp ListDomainOwnershipIdentifiersCompleteResult, err error) { - items := make([]Identifier, 0) - - page, err := c.ListDomainOwnershipIdentifiers(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListDomainOwnershipIdentifiersCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listdomainownershipidentifiersslot.go b/resource-manager/web/2022-09-01/webapps/method_listdomainownershipidentifiersslot.go new file mode 100644 index 00000000000..b97d2c57104 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listdomainownershipidentifiersslot.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListDomainOwnershipIdentifiersSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Identifier +} + +type ListDomainOwnershipIdentifiersSlotCompleteResult struct { + Items []Identifier +} + +// ListDomainOwnershipIdentifiersSlot ... +func (c WebAppsClient) ListDomainOwnershipIdentifiersSlot(ctx context.Context, id SlotId) (result ListDomainOwnershipIdentifiersSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/domainOwnershipIdentifiers", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Identifier `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListDomainOwnershipIdentifiersSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListDomainOwnershipIdentifiersSlotComplete(ctx context.Context, id SlotId) (ListDomainOwnershipIdentifiersSlotCompleteResult, error) { + return c.ListDomainOwnershipIdentifiersSlotCompleteMatchingPredicate(ctx, id, IdentifierOperationPredicate{}) +} + +// ListDomainOwnershipIdentifiersSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListDomainOwnershipIdentifiersSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate IdentifierOperationPredicate) (result ListDomainOwnershipIdentifiersSlotCompleteResult, err error) { + items := make([]Identifier, 0) + + resp, err := c.ListDomainOwnershipIdentifiersSlot(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListDomainOwnershipIdentifiersSlotCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listdomainownershipidentifiersslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listdomainownershipidentifiersslot_autorest.go deleted file mode 100644 index 63f9454a39f..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listdomainownershipidentifiersslot_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListDomainOwnershipIdentifiersSlotOperationResponse struct { - HttpResponse *http.Response - Model *[]Identifier - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListDomainOwnershipIdentifiersSlotOperationResponse, error) -} - -type ListDomainOwnershipIdentifiersSlotCompleteResult struct { - Items []Identifier -} - -func (r ListDomainOwnershipIdentifiersSlotOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListDomainOwnershipIdentifiersSlotOperationResponse) LoadMore(ctx context.Context) (resp ListDomainOwnershipIdentifiersSlotOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListDomainOwnershipIdentifiersSlot ... -func (c WebAppsClient) ListDomainOwnershipIdentifiersSlot(ctx context.Context, id SlotId) (resp ListDomainOwnershipIdentifiersSlotOperationResponse, err error) { - req, err := c.preparerForListDomainOwnershipIdentifiersSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListDomainOwnershipIdentifiersSlot", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListDomainOwnershipIdentifiersSlot", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListDomainOwnershipIdentifiersSlot(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListDomainOwnershipIdentifiersSlot", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListDomainOwnershipIdentifiersSlot prepares the ListDomainOwnershipIdentifiersSlot request. -func (c WebAppsClient) preparerForListDomainOwnershipIdentifiersSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/domainOwnershipIdentifiers", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListDomainOwnershipIdentifiersSlotWithNextLink prepares the ListDomainOwnershipIdentifiersSlot request with the given nextLink token. -func (c WebAppsClient) preparerForListDomainOwnershipIdentifiersSlotWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListDomainOwnershipIdentifiersSlot handles the response to the ListDomainOwnershipIdentifiersSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListDomainOwnershipIdentifiersSlot(resp *http.Response) (result ListDomainOwnershipIdentifiersSlotOperationResponse, err error) { - type page struct { - Values []Identifier `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListDomainOwnershipIdentifiersSlotOperationResponse, err error) { - req, err := c.preparerForListDomainOwnershipIdentifiersSlotWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListDomainOwnershipIdentifiersSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListDomainOwnershipIdentifiersSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListDomainOwnershipIdentifiersSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListDomainOwnershipIdentifiersSlot", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListDomainOwnershipIdentifiersSlotComplete retrieves all of the results into a single object -func (c WebAppsClient) ListDomainOwnershipIdentifiersSlotComplete(ctx context.Context, id SlotId) (ListDomainOwnershipIdentifiersSlotCompleteResult, error) { - return c.ListDomainOwnershipIdentifiersSlotCompleteMatchingPredicate(ctx, id, IdentifierOperationPredicate{}) -} - -// ListDomainOwnershipIdentifiersSlotCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListDomainOwnershipIdentifiersSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate IdentifierOperationPredicate) (resp ListDomainOwnershipIdentifiersSlotCompleteResult, err error) { - items := make([]Identifier, 0) - - page, err := c.ListDomainOwnershipIdentifiersSlot(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListDomainOwnershipIdentifiersSlotCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listfunctionkeys.go b/resource-manager/web/2022-09-01/webapps/method_listfunctionkeys.go new file mode 100644 index 00000000000..5fd4df9e8f6 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listfunctionkeys.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListFunctionKeysOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// ListFunctionKeys ... +func (c WebAppsClient) ListFunctionKeys(ctx context.Context, id FunctionId) (result ListFunctionKeysOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listkeys", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listfunctionkeys_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listfunctionkeys_autorest.go deleted file mode 100644 index 61a5578d5c3..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listfunctionkeys_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListFunctionKeysOperationResponse struct { - HttpResponse *http.Response - Model *StringDictionary -} - -// ListFunctionKeys ... -func (c WebAppsClient) ListFunctionKeys(ctx context.Context, id FunctionId) (result ListFunctionKeysOperationResponse, err error) { - req, err := c.preparerForListFunctionKeys(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListFunctionKeys", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListFunctionKeys", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListFunctionKeys(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListFunctionKeys", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListFunctionKeys prepares the ListFunctionKeys request. -func (c WebAppsClient) preparerForListFunctionKeys(ctx context.Context, id FunctionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/listkeys", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListFunctionKeys handles the response to the ListFunctionKeys request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListFunctionKeys(resp *http.Response) (result ListFunctionKeysOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listfunctionkeysslot.go b/resource-manager/web/2022-09-01/webapps/method_listfunctionkeysslot.go new file mode 100644 index 00000000000..fa8f29ef72b --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listfunctionkeysslot.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListFunctionKeysSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// ListFunctionKeysSlot ... +func (c WebAppsClient) ListFunctionKeysSlot(ctx context.Context, id SlotFunctionId) (result ListFunctionKeysSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listkeys", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listfunctionkeysslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listfunctionkeysslot_autorest.go deleted file mode 100644 index 3b4cfa3d3c8..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listfunctionkeysslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListFunctionKeysSlotOperationResponse struct { - HttpResponse *http.Response - Model *StringDictionary -} - -// ListFunctionKeysSlot ... -func (c WebAppsClient) ListFunctionKeysSlot(ctx context.Context, id SlotFunctionId) (result ListFunctionKeysSlotOperationResponse, err error) { - req, err := c.preparerForListFunctionKeysSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListFunctionKeysSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListFunctionKeysSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListFunctionKeysSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListFunctionKeysSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListFunctionKeysSlot prepares the ListFunctionKeysSlot request. -func (c WebAppsClient) preparerForListFunctionKeysSlot(ctx context.Context, id SlotFunctionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/listkeys", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListFunctionKeysSlot handles the response to the ListFunctionKeysSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListFunctionKeysSlot(resp *http.Response) (result ListFunctionKeysSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listfunctions.go b/resource-manager/web/2022-09-01/webapps/method_listfunctions.go new file mode 100644 index 00000000000..7b3e2f65fb2 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listfunctions.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListFunctionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]FunctionEnvelope +} + +type ListFunctionsCompleteResult struct { + Items []FunctionEnvelope +} + +// ListFunctions ... +func (c WebAppsClient) ListFunctions(ctx context.Context, id SiteId) (result ListFunctionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/functions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]FunctionEnvelope `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListFunctionsComplete retrieves all the results into a single object +func (c WebAppsClient) ListFunctionsComplete(ctx context.Context, id SiteId) (ListFunctionsCompleteResult, error) { + return c.ListFunctionsCompleteMatchingPredicate(ctx, id, FunctionEnvelopeOperationPredicate{}) +} + +// ListFunctionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListFunctionsCompleteMatchingPredicate(ctx context.Context, id SiteId, predicate FunctionEnvelopeOperationPredicate) (result ListFunctionsCompleteResult, err error) { + items := make([]FunctionEnvelope, 0) + + resp, err := c.ListFunctions(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListFunctionsCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listfunctions_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listfunctions_autorest.go deleted file mode 100644 index beffbd59e22..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listfunctions_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListFunctionsOperationResponse struct { - HttpResponse *http.Response - Model *[]FunctionEnvelope - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListFunctionsOperationResponse, error) -} - -type ListFunctionsCompleteResult struct { - Items []FunctionEnvelope -} - -func (r ListFunctionsOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListFunctionsOperationResponse) LoadMore(ctx context.Context) (resp ListFunctionsOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListFunctions ... -func (c WebAppsClient) ListFunctions(ctx context.Context, id SiteId) (resp ListFunctionsOperationResponse, err error) { - req, err := c.preparerForListFunctions(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListFunctions", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListFunctions", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListFunctions(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListFunctions", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListFunctions prepares the ListFunctions request. -func (c WebAppsClient) preparerForListFunctions(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/functions", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListFunctionsWithNextLink prepares the ListFunctions request with the given nextLink token. -func (c WebAppsClient) preparerForListFunctionsWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListFunctions handles the response to the ListFunctions request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListFunctions(resp *http.Response) (result ListFunctionsOperationResponse, err error) { - type page struct { - Values []FunctionEnvelope `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListFunctionsOperationResponse, err error) { - req, err := c.preparerForListFunctionsWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListFunctions", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListFunctions", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListFunctions(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListFunctions", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListFunctionsComplete retrieves all of the results into a single object -func (c WebAppsClient) ListFunctionsComplete(ctx context.Context, id SiteId) (ListFunctionsCompleteResult, error) { - return c.ListFunctionsCompleteMatchingPredicate(ctx, id, FunctionEnvelopeOperationPredicate{}) -} - -// ListFunctionsCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListFunctionsCompleteMatchingPredicate(ctx context.Context, id SiteId, predicate FunctionEnvelopeOperationPredicate) (resp ListFunctionsCompleteResult, err error) { - items := make([]FunctionEnvelope, 0) - - page, err := c.ListFunctions(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListFunctionsCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listfunctionsecrets.go b/resource-manager/web/2022-09-01/webapps/method_listfunctionsecrets.go new file mode 100644 index 00000000000..99442e5a1d8 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listfunctionsecrets.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListFunctionSecretsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *FunctionSecrets +} + +// ListFunctionSecrets ... +func (c WebAppsClient) ListFunctionSecrets(ctx context.Context, id FunctionId) (result ListFunctionSecretsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listsecrets", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listfunctionsecrets_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listfunctionsecrets_autorest.go deleted file mode 100644 index afd7b3e9241..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listfunctionsecrets_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListFunctionSecretsOperationResponse struct { - HttpResponse *http.Response - Model *FunctionSecrets -} - -// ListFunctionSecrets ... -func (c WebAppsClient) ListFunctionSecrets(ctx context.Context, id FunctionId) (result ListFunctionSecretsOperationResponse, err error) { - req, err := c.preparerForListFunctionSecrets(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListFunctionSecrets", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListFunctionSecrets", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListFunctionSecrets(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListFunctionSecrets", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListFunctionSecrets prepares the ListFunctionSecrets request. -func (c WebAppsClient) preparerForListFunctionSecrets(ctx context.Context, id FunctionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/listsecrets", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListFunctionSecrets handles the response to the ListFunctionSecrets request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListFunctionSecrets(resp *http.Response) (result ListFunctionSecretsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listfunctionsecretsslot.go b/resource-manager/web/2022-09-01/webapps/method_listfunctionsecretsslot.go new file mode 100644 index 00000000000..5859187e8bd --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listfunctionsecretsslot.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListFunctionSecretsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *FunctionSecrets +} + +// ListFunctionSecretsSlot ... +func (c WebAppsClient) ListFunctionSecretsSlot(ctx context.Context, id SlotFunctionId) (result ListFunctionSecretsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listsecrets", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listfunctionsecretsslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listfunctionsecretsslot_autorest.go deleted file mode 100644 index 2642eff97d2..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listfunctionsecretsslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListFunctionSecretsSlotOperationResponse struct { - HttpResponse *http.Response - Model *FunctionSecrets -} - -// ListFunctionSecretsSlot ... -func (c WebAppsClient) ListFunctionSecretsSlot(ctx context.Context, id SlotFunctionId) (result ListFunctionSecretsSlotOperationResponse, err error) { - req, err := c.preparerForListFunctionSecretsSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListFunctionSecretsSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListFunctionSecretsSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListFunctionSecretsSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListFunctionSecretsSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListFunctionSecretsSlot prepares the ListFunctionSecretsSlot request. -func (c WebAppsClient) preparerForListFunctionSecretsSlot(ctx context.Context, id SlotFunctionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/listsecrets", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListFunctionSecretsSlot handles the response to the ListFunctionSecretsSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListFunctionSecretsSlot(resp *http.Response) (result ListFunctionSecretsSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listhostkeys.go b/resource-manager/web/2022-09-01/webapps/method_listhostkeys.go new file mode 100644 index 00000000000..3672d4ecedd --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listhostkeys.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListHostKeysOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HostKeys +} + +// ListHostKeys ... +func (c WebAppsClient) ListHostKeys(ctx context.Context, id SiteId) (result ListHostKeysOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/host/default/listkeys", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listhostkeys_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listhostkeys_autorest.go deleted file mode 100644 index 4e3b1600d47..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listhostkeys_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListHostKeysOperationResponse struct { - HttpResponse *http.Response - Model *HostKeys -} - -// ListHostKeys ... -func (c WebAppsClient) ListHostKeys(ctx context.Context, id SiteId) (result ListHostKeysOperationResponse, err error) { - req, err := c.preparerForListHostKeys(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListHostKeys", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListHostKeys", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListHostKeys(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListHostKeys", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListHostKeys prepares the ListHostKeys request. -func (c WebAppsClient) preparerForListHostKeys(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/host/default/listkeys", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListHostKeys handles the response to the ListHostKeys request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListHostKeys(resp *http.Response) (result ListHostKeysOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listhostkeysslot.go b/resource-manager/web/2022-09-01/webapps/method_listhostkeysslot.go new file mode 100644 index 00000000000..fcac8e068c8 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listhostkeysslot.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListHostKeysSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HostKeys +} + +// ListHostKeysSlot ... +func (c WebAppsClient) ListHostKeysSlot(ctx context.Context, id SlotId) (result ListHostKeysSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/host/default/listkeys", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listhostkeysslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listhostkeysslot_autorest.go deleted file mode 100644 index 73beaf009a9..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listhostkeysslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListHostKeysSlotOperationResponse struct { - HttpResponse *http.Response - Model *HostKeys -} - -// ListHostKeysSlot ... -func (c WebAppsClient) ListHostKeysSlot(ctx context.Context, id SlotId) (result ListHostKeysSlotOperationResponse, err error) { - req, err := c.preparerForListHostKeysSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListHostKeysSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListHostKeysSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListHostKeysSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListHostKeysSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListHostKeysSlot prepares the ListHostKeysSlot request. -func (c WebAppsClient) preparerForListHostKeysSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/host/default/listkeys", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListHostKeysSlot handles the response to the ListHostKeysSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListHostKeysSlot(resp *http.Response) (result ListHostKeysSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listhostnamebindings.go b/resource-manager/web/2022-09-01/webapps/method_listhostnamebindings.go new file mode 100644 index 00000000000..fe2c2f5e212 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listhostnamebindings.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListHostNameBindingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]HostNameBinding +} + +type ListHostNameBindingsCompleteResult struct { + Items []HostNameBinding +} + +// ListHostNameBindings ... +func (c WebAppsClient) ListHostNameBindings(ctx context.Context, id SiteId) (result ListHostNameBindingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/hostNameBindings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]HostNameBinding `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListHostNameBindingsComplete retrieves all the results into a single object +func (c WebAppsClient) ListHostNameBindingsComplete(ctx context.Context, id SiteId) (ListHostNameBindingsCompleteResult, error) { + return c.ListHostNameBindingsCompleteMatchingPredicate(ctx, id, HostNameBindingOperationPredicate{}) +} + +// ListHostNameBindingsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListHostNameBindingsCompleteMatchingPredicate(ctx context.Context, id SiteId, predicate HostNameBindingOperationPredicate) (result ListHostNameBindingsCompleteResult, err error) { + items := make([]HostNameBinding, 0) + + resp, err := c.ListHostNameBindings(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListHostNameBindingsCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listhostnamebindings_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listhostnamebindings_autorest.go deleted file mode 100644 index 3b4ec435f11..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listhostnamebindings_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListHostNameBindingsOperationResponse struct { - HttpResponse *http.Response - Model *[]HostNameBinding - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListHostNameBindingsOperationResponse, error) -} - -type ListHostNameBindingsCompleteResult struct { - Items []HostNameBinding -} - -func (r ListHostNameBindingsOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListHostNameBindingsOperationResponse) LoadMore(ctx context.Context) (resp ListHostNameBindingsOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListHostNameBindings ... -func (c WebAppsClient) ListHostNameBindings(ctx context.Context, id SiteId) (resp ListHostNameBindingsOperationResponse, err error) { - req, err := c.preparerForListHostNameBindings(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListHostNameBindings", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListHostNameBindings", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListHostNameBindings(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListHostNameBindings", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListHostNameBindings prepares the ListHostNameBindings request. -func (c WebAppsClient) preparerForListHostNameBindings(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/hostNameBindings", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListHostNameBindingsWithNextLink prepares the ListHostNameBindings request with the given nextLink token. -func (c WebAppsClient) preparerForListHostNameBindingsWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListHostNameBindings handles the response to the ListHostNameBindings request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListHostNameBindings(resp *http.Response) (result ListHostNameBindingsOperationResponse, err error) { - type page struct { - Values []HostNameBinding `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListHostNameBindingsOperationResponse, err error) { - req, err := c.preparerForListHostNameBindingsWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListHostNameBindings", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListHostNameBindings", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListHostNameBindings(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListHostNameBindings", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListHostNameBindingsComplete retrieves all of the results into a single object -func (c WebAppsClient) ListHostNameBindingsComplete(ctx context.Context, id SiteId) (ListHostNameBindingsCompleteResult, error) { - return c.ListHostNameBindingsCompleteMatchingPredicate(ctx, id, HostNameBindingOperationPredicate{}) -} - -// ListHostNameBindingsCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListHostNameBindingsCompleteMatchingPredicate(ctx context.Context, id SiteId, predicate HostNameBindingOperationPredicate) (resp ListHostNameBindingsCompleteResult, err error) { - items := make([]HostNameBinding, 0) - - page, err := c.ListHostNameBindings(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListHostNameBindingsCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listhostnamebindingsslot.go b/resource-manager/web/2022-09-01/webapps/method_listhostnamebindingsslot.go new file mode 100644 index 00000000000..a0efbe88524 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listhostnamebindingsslot.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListHostNameBindingsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]HostNameBinding +} + +type ListHostNameBindingsSlotCompleteResult struct { + Items []HostNameBinding +} + +// ListHostNameBindingsSlot ... +func (c WebAppsClient) ListHostNameBindingsSlot(ctx context.Context, id SlotId) (result ListHostNameBindingsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/hostNameBindings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]HostNameBinding `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListHostNameBindingsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListHostNameBindingsSlotComplete(ctx context.Context, id SlotId) (ListHostNameBindingsSlotCompleteResult, error) { + return c.ListHostNameBindingsSlotCompleteMatchingPredicate(ctx, id, HostNameBindingOperationPredicate{}) +} + +// ListHostNameBindingsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListHostNameBindingsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate HostNameBindingOperationPredicate) (result ListHostNameBindingsSlotCompleteResult, err error) { + items := make([]HostNameBinding, 0) + + resp, err := c.ListHostNameBindingsSlot(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListHostNameBindingsSlotCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listhostnamebindingsslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listhostnamebindingsslot_autorest.go deleted file mode 100644 index a6de913fc4b..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listhostnamebindingsslot_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListHostNameBindingsSlotOperationResponse struct { - HttpResponse *http.Response - Model *[]HostNameBinding - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListHostNameBindingsSlotOperationResponse, error) -} - -type ListHostNameBindingsSlotCompleteResult struct { - Items []HostNameBinding -} - -func (r ListHostNameBindingsSlotOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListHostNameBindingsSlotOperationResponse) LoadMore(ctx context.Context) (resp ListHostNameBindingsSlotOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListHostNameBindingsSlot ... -func (c WebAppsClient) ListHostNameBindingsSlot(ctx context.Context, id SlotId) (resp ListHostNameBindingsSlotOperationResponse, err error) { - req, err := c.preparerForListHostNameBindingsSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListHostNameBindingsSlot", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListHostNameBindingsSlot", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListHostNameBindingsSlot(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListHostNameBindingsSlot", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListHostNameBindingsSlot prepares the ListHostNameBindingsSlot request. -func (c WebAppsClient) preparerForListHostNameBindingsSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/hostNameBindings", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListHostNameBindingsSlotWithNextLink prepares the ListHostNameBindingsSlot request with the given nextLink token. -func (c WebAppsClient) preparerForListHostNameBindingsSlotWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListHostNameBindingsSlot handles the response to the ListHostNameBindingsSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListHostNameBindingsSlot(resp *http.Response) (result ListHostNameBindingsSlotOperationResponse, err error) { - type page struct { - Values []HostNameBinding `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListHostNameBindingsSlotOperationResponse, err error) { - req, err := c.preparerForListHostNameBindingsSlotWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListHostNameBindingsSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListHostNameBindingsSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListHostNameBindingsSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListHostNameBindingsSlot", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListHostNameBindingsSlotComplete retrieves all of the results into a single object -func (c WebAppsClient) ListHostNameBindingsSlotComplete(ctx context.Context, id SlotId) (ListHostNameBindingsSlotCompleteResult, error) { - return c.ListHostNameBindingsSlotCompleteMatchingPredicate(ctx, id, HostNameBindingOperationPredicate{}) -} - -// ListHostNameBindingsSlotCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListHostNameBindingsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate HostNameBindingOperationPredicate) (resp ListHostNameBindingsSlotCompleteResult, err error) { - items := make([]HostNameBinding, 0) - - page, err := c.ListHostNameBindingsSlot(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListHostNameBindingsSlotCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listhybridconnections.go b/resource-manager/web/2022-09-01/webapps/method_listhybridconnections.go new file mode 100644 index 00000000000..a672e873ddf --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listhybridconnections.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListHybridConnectionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HybridConnection +} + +// ListHybridConnections ... +func (c WebAppsClient) ListHybridConnections(ctx context.Context, id SiteId) (result ListHybridConnectionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/hybridConnectionRelays", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listhybridconnections_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listhybridconnections_autorest.go deleted file mode 100644 index 6d71f7f5a9a..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listhybridconnections_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListHybridConnectionsOperationResponse struct { - HttpResponse *http.Response - Model *HybridConnection -} - -// ListHybridConnections ... -func (c WebAppsClient) ListHybridConnections(ctx context.Context, id SiteId) (result ListHybridConnectionsOperationResponse, err error) { - req, err := c.preparerForListHybridConnections(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListHybridConnections", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListHybridConnections", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListHybridConnections(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListHybridConnections", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListHybridConnections prepares the ListHybridConnections request. -func (c WebAppsClient) preparerForListHybridConnections(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/hybridConnectionRelays", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListHybridConnections handles the response to the ListHybridConnections request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListHybridConnections(resp *http.Response) (result ListHybridConnectionsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listhybridconnectionsslot.go b/resource-manager/web/2022-09-01/webapps/method_listhybridconnectionsslot.go new file mode 100644 index 00000000000..1c6f037521d --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listhybridconnectionsslot.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListHybridConnectionsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HybridConnection +} + +// ListHybridConnectionsSlot ... +func (c WebAppsClient) ListHybridConnectionsSlot(ctx context.Context, id SlotId) (result ListHybridConnectionsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/hybridConnectionRelays", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listhybridconnectionsslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listhybridconnectionsslot_autorest.go deleted file mode 100644 index 986f4bd4dab..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listhybridconnectionsslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListHybridConnectionsSlotOperationResponse struct { - HttpResponse *http.Response - Model *HybridConnection -} - -// ListHybridConnectionsSlot ... -func (c WebAppsClient) ListHybridConnectionsSlot(ctx context.Context, id SlotId) (result ListHybridConnectionsSlotOperationResponse, err error) { - req, err := c.preparerForListHybridConnectionsSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListHybridConnectionsSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListHybridConnectionsSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListHybridConnectionsSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListHybridConnectionsSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListHybridConnectionsSlot prepares the ListHybridConnectionsSlot request. -func (c WebAppsClient) preparerForListHybridConnectionsSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/hybridConnectionRelays", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListHybridConnectionsSlot handles the response to the ListHybridConnectionsSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListHybridConnectionsSlot(resp *http.Response) (result ListHybridConnectionsSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listinstancefunctionsslot.go b/resource-manager/web/2022-09-01/webapps/method_listinstancefunctionsslot.go new file mode 100644 index 00000000000..49cfdbb1491 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listinstancefunctionsslot.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListInstanceFunctionsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]FunctionEnvelope +} + +type ListInstanceFunctionsSlotCompleteResult struct { + Items []FunctionEnvelope +} + +// ListInstanceFunctionsSlot ... +func (c WebAppsClient) ListInstanceFunctionsSlot(ctx context.Context, id SlotId) (result ListInstanceFunctionsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/functions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]FunctionEnvelope `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListInstanceFunctionsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListInstanceFunctionsSlotComplete(ctx context.Context, id SlotId) (ListInstanceFunctionsSlotCompleteResult, error) { + return c.ListInstanceFunctionsSlotCompleteMatchingPredicate(ctx, id, FunctionEnvelopeOperationPredicate{}) +} + +// ListInstanceFunctionsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListInstanceFunctionsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate FunctionEnvelopeOperationPredicate) (result ListInstanceFunctionsSlotCompleteResult, err error) { + items := make([]FunctionEnvelope, 0) + + resp, err := c.ListInstanceFunctionsSlot(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListInstanceFunctionsSlotCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listinstancefunctionsslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listinstancefunctionsslot_autorest.go deleted file mode 100644 index 55d9d53a01e..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listinstancefunctionsslot_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListInstanceFunctionsSlotOperationResponse struct { - HttpResponse *http.Response - Model *[]FunctionEnvelope - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListInstanceFunctionsSlotOperationResponse, error) -} - -type ListInstanceFunctionsSlotCompleteResult struct { - Items []FunctionEnvelope -} - -func (r ListInstanceFunctionsSlotOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListInstanceFunctionsSlotOperationResponse) LoadMore(ctx context.Context) (resp ListInstanceFunctionsSlotOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListInstanceFunctionsSlot ... -func (c WebAppsClient) ListInstanceFunctionsSlot(ctx context.Context, id SlotId) (resp ListInstanceFunctionsSlotOperationResponse, err error) { - req, err := c.preparerForListInstanceFunctionsSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceFunctionsSlot", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceFunctionsSlot", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListInstanceFunctionsSlot(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceFunctionsSlot", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListInstanceFunctionsSlot prepares the ListInstanceFunctionsSlot request. -func (c WebAppsClient) preparerForListInstanceFunctionsSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/functions", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListInstanceFunctionsSlotWithNextLink prepares the ListInstanceFunctionsSlot request with the given nextLink token. -func (c WebAppsClient) preparerForListInstanceFunctionsSlotWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListInstanceFunctionsSlot handles the response to the ListInstanceFunctionsSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListInstanceFunctionsSlot(resp *http.Response) (result ListInstanceFunctionsSlotOperationResponse, err error) { - type page struct { - Values []FunctionEnvelope `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListInstanceFunctionsSlotOperationResponse, err error) { - req, err := c.preparerForListInstanceFunctionsSlotWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceFunctionsSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceFunctionsSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListInstanceFunctionsSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceFunctionsSlot", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListInstanceFunctionsSlotComplete retrieves all of the results into a single object -func (c WebAppsClient) ListInstanceFunctionsSlotComplete(ctx context.Context, id SlotId) (ListInstanceFunctionsSlotCompleteResult, error) { - return c.ListInstanceFunctionsSlotCompleteMatchingPredicate(ctx, id, FunctionEnvelopeOperationPredicate{}) -} - -// ListInstanceFunctionsSlotCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListInstanceFunctionsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate FunctionEnvelopeOperationPredicate) (resp ListInstanceFunctionsSlotCompleteResult, err error) { - items := make([]FunctionEnvelope, 0) - - page, err := c.ListInstanceFunctionsSlot(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListInstanceFunctionsSlotCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listinstanceidentifiers.go b/resource-manager/web/2022-09-01/webapps/method_listinstanceidentifiers.go new file mode 100644 index 00000000000..305f71bcd1c --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listinstanceidentifiers.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListInstanceIdentifiersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WebSiteInstanceStatus +} + +type ListInstanceIdentifiersCompleteResult struct { + Items []WebSiteInstanceStatus +} + +// ListInstanceIdentifiers ... +func (c WebAppsClient) ListInstanceIdentifiers(ctx context.Context, id SiteId) (result ListInstanceIdentifiersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/instances", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]WebSiteInstanceStatus `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListInstanceIdentifiersComplete retrieves all the results into a single object +func (c WebAppsClient) ListInstanceIdentifiersComplete(ctx context.Context, id SiteId) (ListInstanceIdentifiersCompleteResult, error) { + return c.ListInstanceIdentifiersCompleteMatchingPredicate(ctx, id, WebSiteInstanceStatusOperationPredicate{}) +} + +// ListInstanceIdentifiersCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListInstanceIdentifiersCompleteMatchingPredicate(ctx context.Context, id SiteId, predicate WebSiteInstanceStatusOperationPredicate) (result ListInstanceIdentifiersCompleteResult, err error) { + items := make([]WebSiteInstanceStatus, 0) + + resp, err := c.ListInstanceIdentifiers(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListInstanceIdentifiersCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listinstanceidentifiers_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listinstanceidentifiers_autorest.go deleted file mode 100644 index bf12dc7e38c..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listinstanceidentifiers_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListInstanceIdentifiersOperationResponse struct { - HttpResponse *http.Response - Model *[]WebSiteInstanceStatus - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListInstanceIdentifiersOperationResponse, error) -} - -type ListInstanceIdentifiersCompleteResult struct { - Items []WebSiteInstanceStatus -} - -func (r ListInstanceIdentifiersOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListInstanceIdentifiersOperationResponse) LoadMore(ctx context.Context) (resp ListInstanceIdentifiersOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListInstanceIdentifiers ... -func (c WebAppsClient) ListInstanceIdentifiers(ctx context.Context, id SiteId) (resp ListInstanceIdentifiersOperationResponse, err error) { - req, err := c.preparerForListInstanceIdentifiers(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceIdentifiers", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceIdentifiers", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListInstanceIdentifiers(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceIdentifiers", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListInstanceIdentifiers prepares the ListInstanceIdentifiers request. -func (c WebAppsClient) preparerForListInstanceIdentifiers(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/instances", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListInstanceIdentifiersWithNextLink prepares the ListInstanceIdentifiers request with the given nextLink token. -func (c WebAppsClient) preparerForListInstanceIdentifiersWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListInstanceIdentifiers handles the response to the ListInstanceIdentifiers request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListInstanceIdentifiers(resp *http.Response) (result ListInstanceIdentifiersOperationResponse, err error) { - type page struct { - Values []WebSiteInstanceStatus `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListInstanceIdentifiersOperationResponse, err error) { - req, err := c.preparerForListInstanceIdentifiersWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceIdentifiers", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceIdentifiers", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListInstanceIdentifiers(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceIdentifiers", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListInstanceIdentifiersComplete retrieves all of the results into a single object -func (c WebAppsClient) ListInstanceIdentifiersComplete(ctx context.Context, id SiteId) (ListInstanceIdentifiersCompleteResult, error) { - return c.ListInstanceIdentifiersCompleteMatchingPredicate(ctx, id, WebSiteInstanceStatusOperationPredicate{}) -} - -// ListInstanceIdentifiersCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListInstanceIdentifiersCompleteMatchingPredicate(ctx context.Context, id SiteId, predicate WebSiteInstanceStatusOperationPredicate) (resp ListInstanceIdentifiersCompleteResult, err error) { - items := make([]WebSiteInstanceStatus, 0) - - page, err := c.ListInstanceIdentifiers(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListInstanceIdentifiersCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listinstanceidentifiersslot.go b/resource-manager/web/2022-09-01/webapps/method_listinstanceidentifiersslot.go new file mode 100644 index 00000000000..1f5a5b2d87b --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listinstanceidentifiersslot.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListInstanceIdentifiersSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WebSiteInstanceStatus +} + +type ListInstanceIdentifiersSlotCompleteResult struct { + Items []WebSiteInstanceStatus +} + +// ListInstanceIdentifiersSlot ... +func (c WebAppsClient) ListInstanceIdentifiersSlot(ctx context.Context, id SlotId) (result ListInstanceIdentifiersSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/instances", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]WebSiteInstanceStatus `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListInstanceIdentifiersSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListInstanceIdentifiersSlotComplete(ctx context.Context, id SlotId) (ListInstanceIdentifiersSlotCompleteResult, error) { + return c.ListInstanceIdentifiersSlotCompleteMatchingPredicate(ctx, id, WebSiteInstanceStatusOperationPredicate{}) +} + +// ListInstanceIdentifiersSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListInstanceIdentifiersSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate WebSiteInstanceStatusOperationPredicate) (result ListInstanceIdentifiersSlotCompleteResult, err error) { + items := make([]WebSiteInstanceStatus, 0) + + resp, err := c.ListInstanceIdentifiersSlot(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListInstanceIdentifiersSlotCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listinstanceidentifiersslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listinstanceidentifiersslot_autorest.go deleted file mode 100644 index e469b6d0335..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listinstanceidentifiersslot_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListInstanceIdentifiersSlotOperationResponse struct { - HttpResponse *http.Response - Model *[]WebSiteInstanceStatus - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListInstanceIdentifiersSlotOperationResponse, error) -} - -type ListInstanceIdentifiersSlotCompleteResult struct { - Items []WebSiteInstanceStatus -} - -func (r ListInstanceIdentifiersSlotOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListInstanceIdentifiersSlotOperationResponse) LoadMore(ctx context.Context) (resp ListInstanceIdentifiersSlotOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListInstanceIdentifiersSlot ... -func (c WebAppsClient) ListInstanceIdentifiersSlot(ctx context.Context, id SlotId) (resp ListInstanceIdentifiersSlotOperationResponse, err error) { - req, err := c.preparerForListInstanceIdentifiersSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceIdentifiersSlot", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceIdentifiersSlot", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListInstanceIdentifiersSlot(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceIdentifiersSlot", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListInstanceIdentifiersSlot prepares the ListInstanceIdentifiersSlot request. -func (c WebAppsClient) preparerForListInstanceIdentifiersSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/instances", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListInstanceIdentifiersSlotWithNextLink prepares the ListInstanceIdentifiersSlot request with the given nextLink token. -func (c WebAppsClient) preparerForListInstanceIdentifiersSlotWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListInstanceIdentifiersSlot handles the response to the ListInstanceIdentifiersSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListInstanceIdentifiersSlot(resp *http.Response) (result ListInstanceIdentifiersSlotOperationResponse, err error) { - type page struct { - Values []WebSiteInstanceStatus `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListInstanceIdentifiersSlotOperationResponse, err error) { - req, err := c.preparerForListInstanceIdentifiersSlotWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceIdentifiersSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceIdentifiersSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListInstanceIdentifiersSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceIdentifiersSlot", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListInstanceIdentifiersSlotComplete retrieves all of the results into a single object -func (c WebAppsClient) ListInstanceIdentifiersSlotComplete(ctx context.Context, id SlotId) (ListInstanceIdentifiersSlotCompleteResult, error) { - return c.ListInstanceIdentifiersSlotCompleteMatchingPredicate(ctx, id, WebSiteInstanceStatusOperationPredicate{}) -} - -// ListInstanceIdentifiersSlotCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListInstanceIdentifiersSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate WebSiteInstanceStatusOperationPredicate) (resp ListInstanceIdentifiersSlotCompleteResult, err error) { - items := make([]WebSiteInstanceStatus, 0) - - page, err := c.ListInstanceIdentifiersSlot(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListInstanceIdentifiersSlotCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listinstanceprocesses.go b/resource-manager/web/2022-09-01/webapps/method_listinstanceprocesses.go new file mode 100644 index 00000000000..d9556e18462 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listinstanceprocesses.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListInstanceProcessesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProcessInfo +} + +type ListInstanceProcessesCompleteResult struct { + Items []ProcessInfo +} + +// ListInstanceProcesses ... +func (c WebAppsClient) ListInstanceProcesses(ctx context.Context, id InstanceId) (result ListInstanceProcessesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/processes", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ProcessInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListInstanceProcessesComplete retrieves all the results into a single object +func (c WebAppsClient) ListInstanceProcessesComplete(ctx context.Context, id InstanceId) (ListInstanceProcessesCompleteResult, error) { + return c.ListInstanceProcessesCompleteMatchingPredicate(ctx, id, ProcessInfoOperationPredicate{}) +} + +// ListInstanceProcessesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListInstanceProcessesCompleteMatchingPredicate(ctx context.Context, id InstanceId, predicate ProcessInfoOperationPredicate) (result ListInstanceProcessesCompleteResult, err error) { + items := make([]ProcessInfo, 0) + + resp, err := c.ListInstanceProcesses(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListInstanceProcessesCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listinstanceprocesses_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listinstanceprocesses_autorest.go deleted file mode 100644 index 650cddb0112..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listinstanceprocesses_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListInstanceProcessesOperationResponse struct { - HttpResponse *http.Response - Model *[]ProcessInfo - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListInstanceProcessesOperationResponse, error) -} - -type ListInstanceProcessesCompleteResult struct { - Items []ProcessInfo -} - -func (r ListInstanceProcessesOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListInstanceProcessesOperationResponse) LoadMore(ctx context.Context) (resp ListInstanceProcessesOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListInstanceProcesses ... -func (c WebAppsClient) ListInstanceProcesses(ctx context.Context, id InstanceId) (resp ListInstanceProcessesOperationResponse, err error) { - req, err := c.preparerForListInstanceProcesses(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceProcesses", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceProcesses", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListInstanceProcesses(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceProcesses", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListInstanceProcesses prepares the ListInstanceProcesses request. -func (c WebAppsClient) preparerForListInstanceProcesses(ctx context.Context, id InstanceId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/processes", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListInstanceProcessesWithNextLink prepares the ListInstanceProcesses request with the given nextLink token. -func (c WebAppsClient) preparerForListInstanceProcessesWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListInstanceProcesses handles the response to the ListInstanceProcesses request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListInstanceProcesses(resp *http.Response) (result ListInstanceProcessesOperationResponse, err error) { - type page struct { - Values []ProcessInfo `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListInstanceProcessesOperationResponse, err error) { - req, err := c.preparerForListInstanceProcessesWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceProcesses", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceProcesses", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListInstanceProcesses(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceProcesses", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListInstanceProcessesComplete retrieves all of the results into a single object -func (c WebAppsClient) ListInstanceProcessesComplete(ctx context.Context, id InstanceId) (ListInstanceProcessesCompleteResult, error) { - return c.ListInstanceProcessesCompleteMatchingPredicate(ctx, id, ProcessInfoOperationPredicate{}) -} - -// ListInstanceProcessesCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListInstanceProcessesCompleteMatchingPredicate(ctx context.Context, id InstanceId, predicate ProcessInfoOperationPredicate) (resp ListInstanceProcessesCompleteResult, err error) { - items := make([]ProcessInfo, 0) - - page, err := c.ListInstanceProcesses(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListInstanceProcessesCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listinstanceprocessesslot.go b/resource-manager/web/2022-09-01/webapps/method_listinstanceprocessesslot.go new file mode 100644 index 00000000000..5ebef5a2468 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listinstanceprocessesslot.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListInstanceProcessesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProcessInfo +} + +type ListInstanceProcessesSlotCompleteResult struct { + Items []ProcessInfo +} + +// ListInstanceProcessesSlot ... +func (c WebAppsClient) ListInstanceProcessesSlot(ctx context.Context, id SlotInstanceId) (result ListInstanceProcessesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/processes", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ProcessInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListInstanceProcessesSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListInstanceProcessesSlotComplete(ctx context.Context, id SlotInstanceId) (ListInstanceProcessesSlotCompleteResult, error) { + return c.ListInstanceProcessesSlotCompleteMatchingPredicate(ctx, id, ProcessInfoOperationPredicate{}) +} + +// ListInstanceProcessesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListInstanceProcessesSlotCompleteMatchingPredicate(ctx context.Context, id SlotInstanceId, predicate ProcessInfoOperationPredicate) (result ListInstanceProcessesSlotCompleteResult, err error) { + items := make([]ProcessInfo, 0) + + resp, err := c.ListInstanceProcessesSlot(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListInstanceProcessesSlotCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listinstanceprocessesslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listinstanceprocessesslot_autorest.go deleted file mode 100644 index 2e6d4999d69..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listinstanceprocessesslot_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListInstanceProcessesSlotOperationResponse struct { - HttpResponse *http.Response - Model *[]ProcessInfo - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListInstanceProcessesSlotOperationResponse, error) -} - -type ListInstanceProcessesSlotCompleteResult struct { - Items []ProcessInfo -} - -func (r ListInstanceProcessesSlotOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListInstanceProcessesSlotOperationResponse) LoadMore(ctx context.Context) (resp ListInstanceProcessesSlotOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListInstanceProcessesSlot ... -func (c WebAppsClient) ListInstanceProcessesSlot(ctx context.Context, id SlotInstanceId) (resp ListInstanceProcessesSlotOperationResponse, err error) { - req, err := c.preparerForListInstanceProcessesSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceProcessesSlot", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceProcessesSlot", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListInstanceProcessesSlot(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceProcessesSlot", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListInstanceProcessesSlot prepares the ListInstanceProcessesSlot request. -func (c WebAppsClient) preparerForListInstanceProcessesSlot(ctx context.Context, id SlotInstanceId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/processes", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListInstanceProcessesSlotWithNextLink prepares the ListInstanceProcessesSlot request with the given nextLink token. -func (c WebAppsClient) preparerForListInstanceProcessesSlotWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListInstanceProcessesSlot handles the response to the ListInstanceProcessesSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListInstanceProcessesSlot(resp *http.Response) (result ListInstanceProcessesSlotOperationResponse, err error) { - type page struct { - Values []ProcessInfo `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListInstanceProcessesSlotOperationResponse, err error) { - req, err := c.preparerForListInstanceProcessesSlotWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceProcessesSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceProcessesSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListInstanceProcessesSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceProcessesSlot", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListInstanceProcessesSlotComplete retrieves all of the results into a single object -func (c WebAppsClient) ListInstanceProcessesSlotComplete(ctx context.Context, id SlotInstanceId) (ListInstanceProcessesSlotCompleteResult, error) { - return c.ListInstanceProcessesSlotCompleteMatchingPredicate(ctx, id, ProcessInfoOperationPredicate{}) -} - -// ListInstanceProcessesSlotCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListInstanceProcessesSlotCompleteMatchingPredicate(ctx context.Context, id SlotInstanceId, predicate ProcessInfoOperationPredicate) (resp ListInstanceProcessesSlotCompleteResult, err error) { - items := make([]ProcessInfo, 0) - - page, err := c.ListInstanceProcessesSlot(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListInstanceProcessesSlotCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listinstanceprocessmodules.go b/resource-manager/web/2022-09-01/webapps/method_listinstanceprocessmodules.go new file mode 100644 index 00000000000..4562fe53de5 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listinstanceprocessmodules.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListInstanceProcessModulesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProcessModuleInfo +} + +type ListInstanceProcessModulesCompleteResult struct { + Items []ProcessModuleInfo +} + +// ListInstanceProcessModules ... +func (c WebAppsClient) ListInstanceProcessModules(ctx context.Context, id InstanceProcessId) (result ListInstanceProcessModulesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/modules", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ProcessModuleInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListInstanceProcessModulesComplete retrieves all the results into a single object +func (c WebAppsClient) ListInstanceProcessModulesComplete(ctx context.Context, id InstanceProcessId) (ListInstanceProcessModulesCompleteResult, error) { + return c.ListInstanceProcessModulesCompleteMatchingPredicate(ctx, id, ProcessModuleInfoOperationPredicate{}) +} + +// ListInstanceProcessModulesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListInstanceProcessModulesCompleteMatchingPredicate(ctx context.Context, id InstanceProcessId, predicate ProcessModuleInfoOperationPredicate) (result ListInstanceProcessModulesCompleteResult, err error) { + items := make([]ProcessModuleInfo, 0) + + resp, err := c.ListInstanceProcessModules(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListInstanceProcessModulesCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listinstanceprocessmodules_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listinstanceprocessmodules_autorest.go deleted file mode 100644 index c83149fb733..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listinstanceprocessmodules_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListInstanceProcessModulesOperationResponse struct { - HttpResponse *http.Response - Model *[]ProcessModuleInfo - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListInstanceProcessModulesOperationResponse, error) -} - -type ListInstanceProcessModulesCompleteResult struct { - Items []ProcessModuleInfo -} - -func (r ListInstanceProcessModulesOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListInstanceProcessModulesOperationResponse) LoadMore(ctx context.Context) (resp ListInstanceProcessModulesOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListInstanceProcessModules ... -func (c WebAppsClient) ListInstanceProcessModules(ctx context.Context, id InstanceProcessId) (resp ListInstanceProcessModulesOperationResponse, err error) { - req, err := c.preparerForListInstanceProcessModules(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceProcessModules", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceProcessModules", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListInstanceProcessModules(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceProcessModules", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListInstanceProcessModules prepares the ListInstanceProcessModules request. -func (c WebAppsClient) preparerForListInstanceProcessModules(ctx context.Context, id InstanceProcessId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/modules", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListInstanceProcessModulesWithNextLink prepares the ListInstanceProcessModules request with the given nextLink token. -func (c WebAppsClient) preparerForListInstanceProcessModulesWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListInstanceProcessModules handles the response to the ListInstanceProcessModules request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListInstanceProcessModules(resp *http.Response) (result ListInstanceProcessModulesOperationResponse, err error) { - type page struct { - Values []ProcessModuleInfo `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListInstanceProcessModulesOperationResponse, err error) { - req, err := c.preparerForListInstanceProcessModulesWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceProcessModules", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceProcessModules", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListInstanceProcessModules(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceProcessModules", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListInstanceProcessModulesComplete retrieves all of the results into a single object -func (c WebAppsClient) ListInstanceProcessModulesComplete(ctx context.Context, id InstanceProcessId) (ListInstanceProcessModulesCompleteResult, error) { - return c.ListInstanceProcessModulesCompleteMatchingPredicate(ctx, id, ProcessModuleInfoOperationPredicate{}) -} - -// ListInstanceProcessModulesCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListInstanceProcessModulesCompleteMatchingPredicate(ctx context.Context, id InstanceProcessId, predicate ProcessModuleInfoOperationPredicate) (resp ListInstanceProcessModulesCompleteResult, err error) { - items := make([]ProcessModuleInfo, 0) - - page, err := c.ListInstanceProcessModules(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListInstanceProcessModulesCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listinstanceprocessmodulesslot.go b/resource-manager/web/2022-09-01/webapps/method_listinstanceprocessmodulesslot.go new file mode 100644 index 00000000000..a96ca9ad815 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listinstanceprocessmodulesslot.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListInstanceProcessModulesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProcessModuleInfo +} + +type ListInstanceProcessModulesSlotCompleteResult struct { + Items []ProcessModuleInfo +} + +// ListInstanceProcessModulesSlot ... +func (c WebAppsClient) ListInstanceProcessModulesSlot(ctx context.Context, id SlotInstanceProcessId) (result ListInstanceProcessModulesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/modules", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ProcessModuleInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListInstanceProcessModulesSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListInstanceProcessModulesSlotComplete(ctx context.Context, id SlotInstanceProcessId) (ListInstanceProcessModulesSlotCompleteResult, error) { + return c.ListInstanceProcessModulesSlotCompleteMatchingPredicate(ctx, id, ProcessModuleInfoOperationPredicate{}) +} + +// ListInstanceProcessModulesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListInstanceProcessModulesSlotCompleteMatchingPredicate(ctx context.Context, id SlotInstanceProcessId, predicate ProcessModuleInfoOperationPredicate) (result ListInstanceProcessModulesSlotCompleteResult, err error) { + items := make([]ProcessModuleInfo, 0) + + resp, err := c.ListInstanceProcessModulesSlot(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListInstanceProcessModulesSlotCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listinstanceprocessmodulesslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listinstanceprocessmodulesslot_autorest.go deleted file mode 100644 index 5e877fc3fb6..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listinstanceprocessmodulesslot_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListInstanceProcessModulesSlotOperationResponse struct { - HttpResponse *http.Response - Model *[]ProcessModuleInfo - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListInstanceProcessModulesSlotOperationResponse, error) -} - -type ListInstanceProcessModulesSlotCompleteResult struct { - Items []ProcessModuleInfo -} - -func (r ListInstanceProcessModulesSlotOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListInstanceProcessModulesSlotOperationResponse) LoadMore(ctx context.Context) (resp ListInstanceProcessModulesSlotOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListInstanceProcessModulesSlot ... -func (c WebAppsClient) ListInstanceProcessModulesSlot(ctx context.Context, id SlotInstanceProcessId) (resp ListInstanceProcessModulesSlotOperationResponse, err error) { - req, err := c.preparerForListInstanceProcessModulesSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceProcessModulesSlot", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceProcessModulesSlot", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListInstanceProcessModulesSlot(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceProcessModulesSlot", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListInstanceProcessModulesSlot prepares the ListInstanceProcessModulesSlot request. -func (c WebAppsClient) preparerForListInstanceProcessModulesSlot(ctx context.Context, id SlotInstanceProcessId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/modules", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListInstanceProcessModulesSlotWithNextLink prepares the ListInstanceProcessModulesSlot request with the given nextLink token. -func (c WebAppsClient) preparerForListInstanceProcessModulesSlotWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListInstanceProcessModulesSlot handles the response to the ListInstanceProcessModulesSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListInstanceProcessModulesSlot(resp *http.Response) (result ListInstanceProcessModulesSlotOperationResponse, err error) { - type page struct { - Values []ProcessModuleInfo `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListInstanceProcessModulesSlotOperationResponse, err error) { - req, err := c.preparerForListInstanceProcessModulesSlotWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceProcessModulesSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceProcessModulesSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListInstanceProcessModulesSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceProcessModulesSlot", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListInstanceProcessModulesSlotComplete retrieves all of the results into a single object -func (c WebAppsClient) ListInstanceProcessModulesSlotComplete(ctx context.Context, id SlotInstanceProcessId) (ListInstanceProcessModulesSlotCompleteResult, error) { - return c.ListInstanceProcessModulesSlotCompleteMatchingPredicate(ctx, id, ProcessModuleInfoOperationPredicate{}) -} - -// ListInstanceProcessModulesSlotCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListInstanceProcessModulesSlotCompleteMatchingPredicate(ctx context.Context, id SlotInstanceProcessId, predicate ProcessModuleInfoOperationPredicate) (resp ListInstanceProcessModulesSlotCompleteResult, err error) { - items := make([]ProcessModuleInfo, 0) - - page, err := c.ListInstanceProcessModulesSlot(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListInstanceProcessModulesSlotCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listinstanceprocessthreads.go b/resource-manager/web/2022-09-01/webapps/method_listinstanceprocessthreads.go new file mode 100644 index 00000000000..48edc624417 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listinstanceprocessthreads.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListInstanceProcessThreadsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProcessThreadInfo +} + +type ListInstanceProcessThreadsCompleteResult struct { + Items []ProcessThreadInfo +} + +// ListInstanceProcessThreads ... +func (c WebAppsClient) ListInstanceProcessThreads(ctx context.Context, id InstanceProcessId) (result ListInstanceProcessThreadsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/threads", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ProcessThreadInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListInstanceProcessThreadsComplete retrieves all the results into a single object +func (c WebAppsClient) ListInstanceProcessThreadsComplete(ctx context.Context, id InstanceProcessId) (ListInstanceProcessThreadsCompleteResult, error) { + return c.ListInstanceProcessThreadsCompleteMatchingPredicate(ctx, id, ProcessThreadInfoOperationPredicate{}) +} + +// ListInstanceProcessThreadsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListInstanceProcessThreadsCompleteMatchingPredicate(ctx context.Context, id InstanceProcessId, predicate ProcessThreadInfoOperationPredicate) (result ListInstanceProcessThreadsCompleteResult, err error) { + items := make([]ProcessThreadInfo, 0) + + resp, err := c.ListInstanceProcessThreads(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListInstanceProcessThreadsCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listinstanceprocessthreads_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listinstanceprocessthreads_autorest.go deleted file mode 100644 index b1bb732aedd..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listinstanceprocessthreads_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListInstanceProcessThreadsOperationResponse struct { - HttpResponse *http.Response - Model *[]ProcessThreadInfo - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListInstanceProcessThreadsOperationResponse, error) -} - -type ListInstanceProcessThreadsCompleteResult struct { - Items []ProcessThreadInfo -} - -func (r ListInstanceProcessThreadsOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListInstanceProcessThreadsOperationResponse) LoadMore(ctx context.Context) (resp ListInstanceProcessThreadsOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListInstanceProcessThreads ... -func (c WebAppsClient) ListInstanceProcessThreads(ctx context.Context, id InstanceProcessId) (resp ListInstanceProcessThreadsOperationResponse, err error) { - req, err := c.preparerForListInstanceProcessThreads(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceProcessThreads", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceProcessThreads", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListInstanceProcessThreads(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceProcessThreads", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListInstanceProcessThreads prepares the ListInstanceProcessThreads request. -func (c WebAppsClient) preparerForListInstanceProcessThreads(ctx context.Context, id InstanceProcessId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/threads", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListInstanceProcessThreadsWithNextLink prepares the ListInstanceProcessThreads request with the given nextLink token. -func (c WebAppsClient) preparerForListInstanceProcessThreadsWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListInstanceProcessThreads handles the response to the ListInstanceProcessThreads request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListInstanceProcessThreads(resp *http.Response) (result ListInstanceProcessThreadsOperationResponse, err error) { - type page struct { - Values []ProcessThreadInfo `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListInstanceProcessThreadsOperationResponse, err error) { - req, err := c.preparerForListInstanceProcessThreadsWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceProcessThreads", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceProcessThreads", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListInstanceProcessThreads(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceProcessThreads", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListInstanceProcessThreadsComplete retrieves all of the results into a single object -func (c WebAppsClient) ListInstanceProcessThreadsComplete(ctx context.Context, id InstanceProcessId) (ListInstanceProcessThreadsCompleteResult, error) { - return c.ListInstanceProcessThreadsCompleteMatchingPredicate(ctx, id, ProcessThreadInfoOperationPredicate{}) -} - -// ListInstanceProcessThreadsCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListInstanceProcessThreadsCompleteMatchingPredicate(ctx context.Context, id InstanceProcessId, predicate ProcessThreadInfoOperationPredicate) (resp ListInstanceProcessThreadsCompleteResult, err error) { - items := make([]ProcessThreadInfo, 0) - - page, err := c.ListInstanceProcessThreads(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListInstanceProcessThreadsCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listinstanceprocessthreadsslot.go b/resource-manager/web/2022-09-01/webapps/method_listinstanceprocessthreadsslot.go new file mode 100644 index 00000000000..9281beff7a6 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listinstanceprocessthreadsslot.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListInstanceProcessThreadsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProcessThreadInfo +} + +type ListInstanceProcessThreadsSlotCompleteResult struct { + Items []ProcessThreadInfo +} + +// ListInstanceProcessThreadsSlot ... +func (c WebAppsClient) ListInstanceProcessThreadsSlot(ctx context.Context, id SlotInstanceProcessId) (result ListInstanceProcessThreadsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/threads", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ProcessThreadInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListInstanceProcessThreadsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListInstanceProcessThreadsSlotComplete(ctx context.Context, id SlotInstanceProcessId) (ListInstanceProcessThreadsSlotCompleteResult, error) { + return c.ListInstanceProcessThreadsSlotCompleteMatchingPredicate(ctx, id, ProcessThreadInfoOperationPredicate{}) +} + +// ListInstanceProcessThreadsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListInstanceProcessThreadsSlotCompleteMatchingPredicate(ctx context.Context, id SlotInstanceProcessId, predicate ProcessThreadInfoOperationPredicate) (result ListInstanceProcessThreadsSlotCompleteResult, err error) { + items := make([]ProcessThreadInfo, 0) + + resp, err := c.ListInstanceProcessThreadsSlot(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListInstanceProcessThreadsSlotCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listinstanceprocessthreadsslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listinstanceprocessthreadsslot_autorest.go deleted file mode 100644 index 6c08247e2eb..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listinstanceprocessthreadsslot_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListInstanceProcessThreadsSlotOperationResponse struct { - HttpResponse *http.Response - Model *[]ProcessThreadInfo - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListInstanceProcessThreadsSlotOperationResponse, error) -} - -type ListInstanceProcessThreadsSlotCompleteResult struct { - Items []ProcessThreadInfo -} - -func (r ListInstanceProcessThreadsSlotOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListInstanceProcessThreadsSlotOperationResponse) LoadMore(ctx context.Context) (resp ListInstanceProcessThreadsSlotOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListInstanceProcessThreadsSlot ... -func (c WebAppsClient) ListInstanceProcessThreadsSlot(ctx context.Context, id SlotInstanceProcessId) (resp ListInstanceProcessThreadsSlotOperationResponse, err error) { - req, err := c.preparerForListInstanceProcessThreadsSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceProcessThreadsSlot", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceProcessThreadsSlot", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListInstanceProcessThreadsSlot(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceProcessThreadsSlot", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListInstanceProcessThreadsSlot prepares the ListInstanceProcessThreadsSlot request. -func (c WebAppsClient) preparerForListInstanceProcessThreadsSlot(ctx context.Context, id SlotInstanceProcessId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/threads", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListInstanceProcessThreadsSlotWithNextLink prepares the ListInstanceProcessThreadsSlot request with the given nextLink token. -func (c WebAppsClient) preparerForListInstanceProcessThreadsSlotWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListInstanceProcessThreadsSlot handles the response to the ListInstanceProcessThreadsSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListInstanceProcessThreadsSlot(resp *http.Response) (result ListInstanceProcessThreadsSlotOperationResponse, err error) { - type page struct { - Values []ProcessThreadInfo `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListInstanceProcessThreadsSlotOperationResponse, err error) { - req, err := c.preparerForListInstanceProcessThreadsSlotWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceProcessThreadsSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceProcessThreadsSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListInstanceProcessThreadsSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceProcessThreadsSlot", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListInstanceProcessThreadsSlotComplete retrieves all of the results into a single object -func (c WebAppsClient) ListInstanceProcessThreadsSlotComplete(ctx context.Context, id SlotInstanceProcessId) (ListInstanceProcessThreadsSlotCompleteResult, error) { - return c.ListInstanceProcessThreadsSlotCompleteMatchingPredicate(ctx, id, ProcessThreadInfoOperationPredicate{}) -} - -// ListInstanceProcessThreadsSlotCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListInstanceProcessThreadsSlotCompleteMatchingPredicate(ctx context.Context, id SlotInstanceProcessId, predicate ProcessThreadInfoOperationPredicate) (resp ListInstanceProcessThreadsSlotCompleteResult, err error) { - items := make([]ProcessThreadInfo, 0) - - page, err := c.ListInstanceProcessThreadsSlot(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListInstanceProcessThreadsSlotCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listinstanceworkflowsslot.go b/resource-manager/web/2022-09-01/webapps/method_listinstanceworkflowsslot.go new file mode 100644 index 00000000000..1bd24a7a0d5 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listinstanceworkflowsslot.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListInstanceWorkflowsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WorkflowEnvelope +} + +type ListInstanceWorkflowsSlotCompleteResult struct { + Items []WorkflowEnvelope +} + +// ListInstanceWorkflowsSlot ... +func (c WebAppsClient) ListInstanceWorkflowsSlot(ctx context.Context, id SlotId) (result ListInstanceWorkflowsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/workflows", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]WorkflowEnvelope `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListInstanceWorkflowsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListInstanceWorkflowsSlotComplete(ctx context.Context, id SlotId) (ListInstanceWorkflowsSlotCompleteResult, error) { + return c.ListInstanceWorkflowsSlotCompleteMatchingPredicate(ctx, id, WorkflowEnvelopeOperationPredicate{}) +} + +// ListInstanceWorkflowsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListInstanceWorkflowsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate WorkflowEnvelopeOperationPredicate) (result ListInstanceWorkflowsSlotCompleteResult, err error) { + items := make([]WorkflowEnvelope, 0) + + resp, err := c.ListInstanceWorkflowsSlot(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListInstanceWorkflowsSlotCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listinstanceworkflowsslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listinstanceworkflowsslot_autorest.go deleted file mode 100644 index 21483717e7b..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listinstanceworkflowsslot_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListInstanceWorkflowsSlotOperationResponse struct { - HttpResponse *http.Response - Model *[]WorkflowEnvelope - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListInstanceWorkflowsSlotOperationResponse, error) -} - -type ListInstanceWorkflowsSlotCompleteResult struct { - Items []WorkflowEnvelope -} - -func (r ListInstanceWorkflowsSlotOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListInstanceWorkflowsSlotOperationResponse) LoadMore(ctx context.Context) (resp ListInstanceWorkflowsSlotOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListInstanceWorkflowsSlot ... -func (c WebAppsClient) ListInstanceWorkflowsSlot(ctx context.Context, id SlotId) (resp ListInstanceWorkflowsSlotOperationResponse, err error) { - req, err := c.preparerForListInstanceWorkflowsSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceWorkflowsSlot", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceWorkflowsSlot", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListInstanceWorkflowsSlot(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceWorkflowsSlot", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListInstanceWorkflowsSlot prepares the ListInstanceWorkflowsSlot request. -func (c WebAppsClient) preparerForListInstanceWorkflowsSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/workflows", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListInstanceWorkflowsSlotWithNextLink prepares the ListInstanceWorkflowsSlot request with the given nextLink token. -func (c WebAppsClient) preparerForListInstanceWorkflowsSlotWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListInstanceWorkflowsSlot handles the response to the ListInstanceWorkflowsSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListInstanceWorkflowsSlot(resp *http.Response) (result ListInstanceWorkflowsSlotOperationResponse, err error) { - type page struct { - Values []WorkflowEnvelope `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListInstanceWorkflowsSlotOperationResponse, err error) { - req, err := c.preparerForListInstanceWorkflowsSlotWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceWorkflowsSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceWorkflowsSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListInstanceWorkflowsSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListInstanceWorkflowsSlot", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListInstanceWorkflowsSlotComplete retrieves all of the results into a single object -func (c WebAppsClient) ListInstanceWorkflowsSlotComplete(ctx context.Context, id SlotId) (ListInstanceWorkflowsSlotCompleteResult, error) { - return c.ListInstanceWorkflowsSlotCompleteMatchingPredicate(ctx, id, WorkflowEnvelopeOperationPredicate{}) -} - -// ListInstanceWorkflowsSlotCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListInstanceWorkflowsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate WorkflowEnvelopeOperationPredicate) (resp ListInstanceWorkflowsSlotCompleteResult, err error) { - items := make([]WorkflowEnvelope, 0) - - page, err := c.ListInstanceWorkflowsSlot(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListInstanceWorkflowsSlotCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listmetadata.go b/resource-manager/web/2022-09-01/webapps/method_listmetadata.go new file mode 100644 index 00000000000..d5d41fd79ae --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listmetadata.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListMetadataOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// ListMetadata ... +func (c WebAppsClient) ListMetadata(ctx context.Context, id SiteId) (result ListMetadataOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/metadata/list", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listmetadata_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listmetadata_autorest.go deleted file mode 100644 index 4f3e729449a..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listmetadata_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListMetadataOperationResponse struct { - HttpResponse *http.Response - Model *StringDictionary -} - -// ListMetadata ... -func (c WebAppsClient) ListMetadata(ctx context.Context, id SiteId) (result ListMetadataOperationResponse, err error) { - req, err := c.preparerForListMetadata(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListMetadata", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListMetadata", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListMetadata(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListMetadata", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListMetadata prepares the ListMetadata request. -func (c WebAppsClient) preparerForListMetadata(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/metadata/list", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListMetadata handles the response to the ListMetadata request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListMetadata(resp *http.Response) (result ListMetadataOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listmetadataslot.go b/resource-manager/web/2022-09-01/webapps/method_listmetadataslot.go new file mode 100644 index 00000000000..9493ea339cf --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listmetadataslot.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListMetadataSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// ListMetadataSlot ... +func (c WebAppsClient) ListMetadataSlot(ctx context.Context, id SlotId) (result ListMetadataSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/metadata/list", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listmetadataslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listmetadataslot_autorest.go deleted file mode 100644 index bdf4fe3291b..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listmetadataslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListMetadataSlotOperationResponse struct { - HttpResponse *http.Response - Model *StringDictionary -} - -// ListMetadataSlot ... -func (c WebAppsClient) ListMetadataSlot(ctx context.Context, id SlotId) (result ListMetadataSlotOperationResponse, err error) { - req, err := c.preparerForListMetadataSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListMetadataSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListMetadataSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListMetadataSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListMetadataSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListMetadataSlot prepares the ListMetadataSlot request. -func (c WebAppsClient) preparerForListMetadataSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/metadata/list", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListMetadataSlot handles the response to the ListMetadataSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListMetadataSlot(resp *http.Response) (result ListMetadataSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listnetworkfeatures.go b/resource-manager/web/2022-09-01/webapps/method_listnetworkfeatures.go new file mode 100644 index 00000000000..ddc698c091c --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listnetworkfeatures.go @@ -0,0 +1,51 @@ +package webapps + +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 ListNetworkFeaturesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetworkFeatures +} + +// ListNetworkFeatures ... +func (c WebAppsClient) ListNetworkFeatures(ctx context.Context, id NetworkFeatureId) (result ListNetworkFeaturesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listnetworkfeatures_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listnetworkfeatures_autorest.go deleted file mode 100644 index e3337a4cace..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listnetworkfeatures_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListNetworkFeaturesOperationResponse struct { - HttpResponse *http.Response - Model *NetworkFeatures -} - -// ListNetworkFeatures ... -func (c WebAppsClient) ListNetworkFeatures(ctx context.Context, id NetworkFeatureId) (result ListNetworkFeaturesOperationResponse, err error) { - req, err := c.preparerForListNetworkFeatures(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListNetworkFeatures", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListNetworkFeatures", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListNetworkFeatures(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListNetworkFeatures", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListNetworkFeatures prepares the ListNetworkFeatures request. -func (c WebAppsClient) preparerForListNetworkFeatures(ctx context.Context, id NetworkFeatureId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListNetworkFeatures handles the response to the ListNetworkFeatures request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListNetworkFeatures(resp *http.Response) (result ListNetworkFeaturesOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listnetworkfeaturesslot.go b/resource-manager/web/2022-09-01/webapps/method_listnetworkfeaturesslot.go new file mode 100644 index 00000000000..4bec23279b7 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listnetworkfeaturesslot.go @@ -0,0 +1,51 @@ +package webapps + +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 ListNetworkFeaturesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetworkFeatures +} + +// ListNetworkFeaturesSlot ... +func (c WebAppsClient) ListNetworkFeaturesSlot(ctx context.Context, id SlotNetworkFeatureId) (result ListNetworkFeaturesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listnetworkfeaturesslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listnetworkfeaturesslot_autorest.go deleted file mode 100644 index 8710893c58f..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listnetworkfeaturesslot_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListNetworkFeaturesSlotOperationResponse struct { - HttpResponse *http.Response - Model *NetworkFeatures -} - -// ListNetworkFeaturesSlot ... -func (c WebAppsClient) ListNetworkFeaturesSlot(ctx context.Context, id SlotNetworkFeatureId) (result ListNetworkFeaturesSlotOperationResponse, err error) { - req, err := c.preparerForListNetworkFeaturesSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListNetworkFeaturesSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListNetworkFeaturesSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListNetworkFeaturesSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListNetworkFeaturesSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListNetworkFeaturesSlot prepares the ListNetworkFeaturesSlot request. -func (c WebAppsClient) preparerForListNetworkFeaturesSlot(ctx context.Context, id SlotNetworkFeatureId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListNetworkFeaturesSlot handles the response to the ListNetworkFeaturesSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListNetworkFeaturesSlot(resp *http.Response) (result ListNetworkFeaturesSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listperfmoncounters.go b/resource-manager/web/2022-09-01/webapps/method_listperfmoncounters.go new file mode 100644 index 00000000000..9649193c5d3 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listperfmoncounters.go @@ -0,0 +1,117 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListPerfMonCountersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PerfMonResponse +} + +type ListPerfMonCountersCompleteResult struct { + Items []PerfMonResponse +} + +type ListPerfMonCountersOperationOptions struct { + Filter *string +} + +func DefaultListPerfMonCountersOperationOptions() ListPerfMonCountersOperationOptions { + return ListPerfMonCountersOperationOptions{} +} + +func (o ListPerfMonCountersOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListPerfMonCountersOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListPerfMonCountersOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +// ListPerfMonCounters ... +func (c WebAppsClient) ListPerfMonCounters(ctx context.Context, id SiteId, options ListPerfMonCountersOperationOptions) (result ListPerfMonCountersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/perfcounters", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PerfMonResponse `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListPerfMonCountersComplete retrieves all the results into a single object +func (c WebAppsClient) ListPerfMonCountersComplete(ctx context.Context, id SiteId, options ListPerfMonCountersOperationOptions) (ListPerfMonCountersCompleteResult, error) { + return c.ListPerfMonCountersCompleteMatchingPredicate(ctx, id, options, PerfMonResponseOperationPredicate{}) +} + +// ListPerfMonCountersCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListPerfMonCountersCompleteMatchingPredicate(ctx context.Context, id SiteId, options ListPerfMonCountersOperationOptions, predicate PerfMonResponseOperationPredicate) (result ListPerfMonCountersCompleteResult, err error) { + items := make([]PerfMonResponse, 0) + + resp, err := c.ListPerfMonCounters(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListPerfMonCountersCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listperfmoncounters_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listperfmoncounters_autorest.go deleted file mode 100644 index ffd400a3ddb..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listperfmoncounters_autorest.go +++ /dev/null @@ -1,215 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListPerfMonCountersOperationResponse struct { - HttpResponse *http.Response - Model *[]PerfMonResponse - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListPerfMonCountersOperationResponse, error) -} - -type ListPerfMonCountersCompleteResult struct { - Items []PerfMonResponse -} - -func (r ListPerfMonCountersOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListPerfMonCountersOperationResponse) LoadMore(ctx context.Context) (resp ListPerfMonCountersOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListPerfMonCountersOperationOptions struct { - Filter *string -} - -func DefaultListPerfMonCountersOperationOptions() ListPerfMonCountersOperationOptions { - return ListPerfMonCountersOperationOptions{} -} - -func (o ListPerfMonCountersOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListPerfMonCountersOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - return out -} - -// ListPerfMonCounters ... -func (c WebAppsClient) ListPerfMonCounters(ctx context.Context, id SiteId, options ListPerfMonCountersOperationOptions) (resp ListPerfMonCountersOperationResponse, err error) { - req, err := c.preparerForListPerfMonCounters(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListPerfMonCounters", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListPerfMonCounters", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListPerfMonCounters(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListPerfMonCounters", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListPerfMonCounters prepares the ListPerfMonCounters request. -func (c WebAppsClient) preparerForListPerfMonCounters(ctx context.Context, id SiteId, options ListPerfMonCountersOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/perfcounters", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListPerfMonCountersWithNextLink prepares the ListPerfMonCounters request with the given nextLink token. -func (c WebAppsClient) preparerForListPerfMonCountersWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListPerfMonCounters handles the response to the ListPerfMonCounters request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListPerfMonCounters(resp *http.Response) (result ListPerfMonCountersOperationResponse, err error) { - type page struct { - Values []PerfMonResponse `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListPerfMonCountersOperationResponse, err error) { - req, err := c.preparerForListPerfMonCountersWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListPerfMonCounters", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListPerfMonCounters", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListPerfMonCounters(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListPerfMonCounters", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListPerfMonCountersComplete retrieves all of the results into a single object -func (c WebAppsClient) ListPerfMonCountersComplete(ctx context.Context, id SiteId, options ListPerfMonCountersOperationOptions) (ListPerfMonCountersCompleteResult, error) { - return c.ListPerfMonCountersCompleteMatchingPredicate(ctx, id, options, PerfMonResponseOperationPredicate{}) -} - -// ListPerfMonCountersCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListPerfMonCountersCompleteMatchingPredicate(ctx context.Context, id SiteId, options ListPerfMonCountersOperationOptions, predicate PerfMonResponseOperationPredicate) (resp ListPerfMonCountersCompleteResult, err error) { - items := make([]PerfMonResponse, 0) - - page, err := c.ListPerfMonCounters(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListPerfMonCountersCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listperfmoncountersslot.go b/resource-manager/web/2022-09-01/webapps/method_listperfmoncountersslot.go new file mode 100644 index 00000000000..8525ef17faf --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listperfmoncountersslot.go @@ -0,0 +1,117 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListPerfMonCountersSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PerfMonResponse +} + +type ListPerfMonCountersSlotCompleteResult struct { + Items []PerfMonResponse +} + +type ListPerfMonCountersSlotOperationOptions struct { + Filter *string +} + +func DefaultListPerfMonCountersSlotOperationOptions() ListPerfMonCountersSlotOperationOptions { + return ListPerfMonCountersSlotOperationOptions{} +} + +func (o ListPerfMonCountersSlotOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListPerfMonCountersSlotOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListPerfMonCountersSlotOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +// ListPerfMonCountersSlot ... +func (c WebAppsClient) ListPerfMonCountersSlot(ctx context.Context, id SlotId, options ListPerfMonCountersSlotOperationOptions) (result ListPerfMonCountersSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/perfcounters", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PerfMonResponse `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListPerfMonCountersSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListPerfMonCountersSlotComplete(ctx context.Context, id SlotId, options ListPerfMonCountersSlotOperationOptions) (ListPerfMonCountersSlotCompleteResult, error) { + return c.ListPerfMonCountersSlotCompleteMatchingPredicate(ctx, id, options, PerfMonResponseOperationPredicate{}) +} + +// ListPerfMonCountersSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListPerfMonCountersSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, options ListPerfMonCountersSlotOperationOptions, predicate PerfMonResponseOperationPredicate) (result ListPerfMonCountersSlotCompleteResult, err error) { + items := make([]PerfMonResponse, 0) + + resp, err := c.ListPerfMonCountersSlot(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListPerfMonCountersSlotCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listperfmoncountersslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listperfmoncountersslot_autorest.go deleted file mode 100644 index 3259878668d..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listperfmoncountersslot_autorest.go +++ /dev/null @@ -1,215 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListPerfMonCountersSlotOperationResponse struct { - HttpResponse *http.Response - Model *[]PerfMonResponse - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListPerfMonCountersSlotOperationResponse, error) -} - -type ListPerfMonCountersSlotCompleteResult struct { - Items []PerfMonResponse -} - -func (r ListPerfMonCountersSlotOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListPerfMonCountersSlotOperationResponse) LoadMore(ctx context.Context) (resp ListPerfMonCountersSlotOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListPerfMonCountersSlotOperationOptions struct { - Filter *string -} - -func DefaultListPerfMonCountersSlotOperationOptions() ListPerfMonCountersSlotOperationOptions { - return ListPerfMonCountersSlotOperationOptions{} -} - -func (o ListPerfMonCountersSlotOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListPerfMonCountersSlotOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - return out -} - -// ListPerfMonCountersSlot ... -func (c WebAppsClient) ListPerfMonCountersSlot(ctx context.Context, id SlotId, options ListPerfMonCountersSlotOperationOptions) (resp ListPerfMonCountersSlotOperationResponse, err error) { - req, err := c.preparerForListPerfMonCountersSlot(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListPerfMonCountersSlot", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListPerfMonCountersSlot", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListPerfMonCountersSlot(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListPerfMonCountersSlot", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListPerfMonCountersSlot prepares the ListPerfMonCountersSlot request. -func (c WebAppsClient) preparerForListPerfMonCountersSlot(ctx context.Context, id SlotId, options ListPerfMonCountersSlotOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/perfcounters", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListPerfMonCountersSlotWithNextLink prepares the ListPerfMonCountersSlot request with the given nextLink token. -func (c WebAppsClient) preparerForListPerfMonCountersSlotWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListPerfMonCountersSlot handles the response to the ListPerfMonCountersSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListPerfMonCountersSlot(resp *http.Response) (result ListPerfMonCountersSlotOperationResponse, err error) { - type page struct { - Values []PerfMonResponse `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListPerfMonCountersSlotOperationResponse, err error) { - req, err := c.preparerForListPerfMonCountersSlotWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListPerfMonCountersSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListPerfMonCountersSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListPerfMonCountersSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListPerfMonCountersSlot", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListPerfMonCountersSlotComplete retrieves all of the results into a single object -func (c WebAppsClient) ListPerfMonCountersSlotComplete(ctx context.Context, id SlotId, options ListPerfMonCountersSlotOperationOptions) (ListPerfMonCountersSlotCompleteResult, error) { - return c.ListPerfMonCountersSlotCompleteMatchingPredicate(ctx, id, options, PerfMonResponseOperationPredicate{}) -} - -// ListPerfMonCountersSlotCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListPerfMonCountersSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, options ListPerfMonCountersSlotOperationOptions, predicate PerfMonResponseOperationPredicate) (resp ListPerfMonCountersSlotCompleteResult, err error) { - items := make([]PerfMonResponse, 0) - - page, err := c.ListPerfMonCountersSlot(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListPerfMonCountersSlotCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listpremieraddons.go b/resource-manager/web/2022-09-01/webapps/method_listpremieraddons.go new file mode 100644 index 00000000000..582d1c79eb8 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listpremieraddons.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListPremierAddOnsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PremierAddOn +} + +// ListPremierAddOns ... +func (c WebAppsClient) ListPremierAddOns(ctx context.Context, id SiteId) (result ListPremierAddOnsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/premierAddons", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listpremieraddons_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listpremieraddons_autorest.go deleted file mode 100644 index 37d14dcfde5..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listpremieraddons_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListPremierAddOnsOperationResponse struct { - HttpResponse *http.Response - Model *PremierAddOn -} - -// ListPremierAddOns ... -func (c WebAppsClient) ListPremierAddOns(ctx context.Context, id SiteId) (result ListPremierAddOnsOperationResponse, err error) { - req, err := c.preparerForListPremierAddOns(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListPremierAddOns", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListPremierAddOns", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListPremierAddOns(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListPremierAddOns", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListPremierAddOns prepares the ListPremierAddOns request. -func (c WebAppsClient) preparerForListPremierAddOns(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/premierAddons", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListPremierAddOns handles the response to the ListPremierAddOns request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListPremierAddOns(resp *http.Response) (result ListPremierAddOnsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listpremieraddonsslot.go b/resource-manager/web/2022-09-01/webapps/method_listpremieraddonsslot.go new file mode 100644 index 00000000000..668e3674b63 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listpremieraddonsslot.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListPremierAddOnsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PremierAddOn +} + +// ListPremierAddOnsSlot ... +func (c WebAppsClient) ListPremierAddOnsSlot(ctx context.Context, id SlotId) (result ListPremierAddOnsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/premierAddons", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listpremieraddonsslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listpremieraddonsslot_autorest.go deleted file mode 100644 index 9741f676556..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listpremieraddonsslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListPremierAddOnsSlotOperationResponse struct { - HttpResponse *http.Response - Model *PremierAddOn -} - -// ListPremierAddOnsSlot ... -func (c WebAppsClient) ListPremierAddOnsSlot(ctx context.Context, id SlotId) (result ListPremierAddOnsSlotOperationResponse, err error) { - req, err := c.preparerForListPremierAddOnsSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListPremierAddOnsSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListPremierAddOnsSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListPremierAddOnsSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListPremierAddOnsSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListPremierAddOnsSlot prepares the ListPremierAddOnsSlot request. -func (c WebAppsClient) preparerForListPremierAddOnsSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/premierAddons", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListPremierAddOnsSlot handles the response to the ListPremierAddOnsSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListPremierAddOnsSlot(resp *http.Response) (result ListPremierAddOnsSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listprocesses.go b/resource-manager/web/2022-09-01/webapps/method_listprocesses.go new file mode 100644 index 00000000000..d89bd0550cd --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listprocesses.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListProcessesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProcessInfo +} + +type ListProcessesCompleteResult struct { + Items []ProcessInfo +} + +// ListProcesses ... +func (c WebAppsClient) ListProcesses(ctx context.Context, id SiteId) (result ListProcessesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/processes", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ProcessInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListProcessesComplete retrieves all the results into a single object +func (c WebAppsClient) ListProcessesComplete(ctx context.Context, id SiteId) (ListProcessesCompleteResult, error) { + return c.ListProcessesCompleteMatchingPredicate(ctx, id, ProcessInfoOperationPredicate{}) +} + +// ListProcessesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListProcessesCompleteMatchingPredicate(ctx context.Context, id SiteId, predicate ProcessInfoOperationPredicate) (result ListProcessesCompleteResult, err error) { + items := make([]ProcessInfo, 0) + + resp, err := c.ListProcesses(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListProcessesCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listprocesses_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listprocesses_autorest.go deleted file mode 100644 index a22d694a2fb..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listprocesses_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListProcessesOperationResponse struct { - HttpResponse *http.Response - Model *[]ProcessInfo - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListProcessesOperationResponse, error) -} - -type ListProcessesCompleteResult struct { - Items []ProcessInfo -} - -func (r ListProcessesOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListProcessesOperationResponse) LoadMore(ctx context.Context) (resp ListProcessesOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListProcesses ... -func (c WebAppsClient) ListProcesses(ctx context.Context, id SiteId) (resp ListProcessesOperationResponse, err error) { - req, err := c.preparerForListProcesses(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListProcesses", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListProcesses", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListProcesses(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListProcesses", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListProcesses prepares the ListProcesses request. -func (c WebAppsClient) preparerForListProcesses(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/processes", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListProcessesWithNextLink prepares the ListProcesses request with the given nextLink token. -func (c WebAppsClient) preparerForListProcessesWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListProcesses handles the response to the ListProcesses request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListProcesses(resp *http.Response) (result ListProcessesOperationResponse, err error) { - type page struct { - Values []ProcessInfo `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListProcessesOperationResponse, err error) { - req, err := c.preparerForListProcessesWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListProcesses", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListProcesses", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListProcesses(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListProcesses", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListProcessesComplete retrieves all of the results into a single object -func (c WebAppsClient) ListProcessesComplete(ctx context.Context, id SiteId) (ListProcessesCompleteResult, error) { - return c.ListProcessesCompleteMatchingPredicate(ctx, id, ProcessInfoOperationPredicate{}) -} - -// ListProcessesCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListProcessesCompleteMatchingPredicate(ctx context.Context, id SiteId, predicate ProcessInfoOperationPredicate) (resp ListProcessesCompleteResult, err error) { - items := make([]ProcessInfo, 0) - - page, err := c.ListProcesses(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListProcessesCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listprocessesslot.go b/resource-manager/web/2022-09-01/webapps/method_listprocessesslot.go new file mode 100644 index 00000000000..0b18b11d69f --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listprocessesslot.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListProcessesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProcessInfo +} + +type ListProcessesSlotCompleteResult struct { + Items []ProcessInfo +} + +// ListProcessesSlot ... +func (c WebAppsClient) ListProcessesSlot(ctx context.Context, id SlotId) (result ListProcessesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/processes", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ProcessInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListProcessesSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListProcessesSlotComplete(ctx context.Context, id SlotId) (ListProcessesSlotCompleteResult, error) { + return c.ListProcessesSlotCompleteMatchingPredicate(ctx, id, ProcessInfoOperationPredicate{}) +} + +// ListProcessesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListProcessesSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate ProcessInfoOperationPredicate) (result ListProcessesSlotCompleteResult, err error) { + items := make([]ProcessInfo, 0) + + resp, err := c.ListProcessesSlot(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListProcessesSlotCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listprocessesslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listprocessesslot_autorest.go deleted file mode 100644 index 5880aedb2ee..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listprocessesslot_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListProcessesSlotOperationResponse struct { - HttpResponse *http.Response - Model *[]ProcessInfo - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListProcessesSlotOperationResponse, error) -} - -type ListProcessesSlotCompleteResult struct { - Items []ProcessInfo -} - -func (r ListProcessesSlotOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListProcessesSlotOperationResponse) LoadMore(ctx context.Context) (resp ListProcessesSlotOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListProcessesSlot ... -func (c WebAppsClient) ListProcessesSlot(ctx context.Context, id SlotId) (resp ListProcessesSlotOperationResponse, err error) { - req, err := c.preparerForListProcessesSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListProcessesSlot", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListProcessesSlot", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListProcessesSlot(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListProcessesSlot", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListProcessesSlot prepares the ListProcessesSlot request. -func (c WebAppsClient) preparerForListProcessesSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/processes", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListProcessesSlotWithNextLink prepares the ListProcessesSlot request with the given nextLink token. -func (c WebAppsClient) preparerForListProcessesSlotWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListProcessesSlot handles the response to the ListProcessesSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListProcessesSlot(resp *http.Response) (result ListProcessesSlotOperationResponse, err error) { - type page struct { - Values []ProcessInfo `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListProcessesSlotOperationResponse, err error) { - req, err := c.preparerForListProcessesSlotWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListProcessesSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListProcessesSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListProcessesSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListProcessesSlot", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListProcessesSlotComplete retrieves all of the results into a single object -func (c WebAppsClient) ListProcessesSlotComplete(ctx context.Context, id SlotId) (ListProcessesSlotCompleteResult, error) { - return c.ListProcessesSlotCompleteMatchingPredicate(ctx, id, ProcessInfoOperationPredicate{}) -} - -// ListProcessesSlotCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListProcessesSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate ProcessInfoOperationPredicate) (resp ListProcessesSlotCompleteResult, err error) { - items := make([]ProcessInfo, 0) - - page, err := c.ListProcessesSlot(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListProcessesSlotCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listprocessmodules.go b/resource-manager/web/2022-09-01/webapps/method_listprocessmodules.go new file mode 100644 index 00000000000..1b997a84838 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listprocessmodules.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListProcessModulesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProcessModuleInfo +} + +type ListProcessModulesCompleteResult struct { + Items []ProcessModuleInfo +} + +// ListProcessModules ... +func (c WebAppsClient) ListProcessModules(ctx context.Context, id ProcessId) (result ListProcessModulesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/modules", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ProcessModuleInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListProcessModulesComplete retrieves all the results into a single object +func (c WebAppsClient) ListProcessModulesComplete(ctx context.Context, id ProcessId) (ListProcessModulesCompleteResult, error) { + return c.ListProcessModulesCompleteMatchingPredicate(ctx, id, ProcessModuleInfoOperationPredicate{}) +} + +// ListProcessModulesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListProcessModulesCompleteMatchingPredicate(ctx context.Context, id ProcessId, predicate ProcessModuleInfoOperationPredicate) (result ListProcessModulesCompleteResult, err error) { + items := make([]ProcessModuleInfo, 0) + + resp, err := c.ListProcessModules(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListProcessModulesCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listprocessmodules_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listprocessmodules_autorest.go deleted file mode 100644 index 2e718c3c875..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listprocessmodules_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListProcessModulesOperationResponse struct { - HttpResponse *http.Response - Model *[]ProcessModuleInfo - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListProcessModulesOperationResponse, error) -} - -type ListProcessModulesCompleteResult struct { - Items []ProcessModuleInfo -} - -func (r ListProcessModulesOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListProcessModulesOperationResponse) LoadMore(ctx context.Context) (resp ListProcessModulesOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListProcessModules ... -func (c WebAppsClient) ListProcessModules(ctx context.Context, id ProcessId) (resp ListProcessModulesOperationResponse, err error) { - req, err := c.preparerForListProcessModules(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListProcessModules", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListProcessModules", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListProcessModules(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListProcessModules", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListProcessModules prepares the ListProcessModules request. -func (c WebAppsClient) preparerForListProcessModules(ctx context.Context, id ProcessId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/modules", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListProcessModulesWithNextLink prepares the ListProcessModules request with the given nextLink token. -func (c WebAppsClient) preparerForListProcessModulesWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListProcessModules handles the response to the ListProcessModules request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListProcessModules(resp *http.Response) (result ListProcessModulesOperationResponse, err error) { - type page struct { - Values []ProcessModuleInfo `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListProcessModulesOperationResponse, err error) { - req, err := c.preparerForListProcessModulesWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListProcessModules", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListProcessModules", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListProcessModules(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListProcessModules", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListProcessModulesComplete retrieves all of the results into a single object -func (c WebAppsClient) ListProcessModulesComplete(ctx context.Context, id ProcessId) (ListProcessModulesCompleteResult, error) { - return c.ListProcessModulesCompleteMatchingPredicate(ctx, id, ProcessModuleInfoOperationPredicate{}) -} - -// ListProcessModulesCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListProcessModulesCompleteMatchingPredicate(ctx context.Context, id ProcessId, predicate ProcessModuleInfoOperationPredicate) (resp ListProcessModulesCompleteResult, err error) { - items := make([]ProcessModuleInfo, 0) - - page, err := c.ListProcessModules(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListProcessModulesCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listprocessmodulesslot.go b/resource-manager/web/2022-09-01/webapps/method_listprocessmodulesslot.go new file mode 100644 index 00000000000..9eefdd7c24e --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listprocessmodulesslot.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListProcessModulesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProcessModuleInfo +} + +type ListProcessModulesSlotCompleteResult struct { + Items []ProcessModuleInfo +} + +// ListProcessModulesSlot ... +func (c WebAppsClient) ListProcessModulesSlot(ctx context.Context, id SlotProcessId) (result ListProcessModulesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/modules", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ProcessModuleInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListProcessModulesSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListProcessModulesSlotComplete(ctx context.Context, id SlotProcessId) (ListProcessModulesSlotCompleteResult, error) { + return c.ListProcessModulesSlotCompleteMatchingPredicate(ctx, id, ProcessModuleInfoOperationPredicate{}) +} + +// ListProcessModulesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListProcessModulesSlotCompleteMatchingPredicate(ctx context.Context, id SlotProcessId, predicate ProcessModuleInfoOperationPredicate) (result ListProcessModulesSlotCompleteResult, err error) { + items := make([]ProcessModuleInfo, 0) + + resp, err := c.ListProcessModulesSlot(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListProcessModulesSlotCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listprocessmodulesslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listprocessmodulesslot_autorest.go deleted file mode 100644 index be9df6951b0..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listprocessmodulesslot_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListProcessModulesSlotOperationResponse struct { - HttpResponse *http.Response - Model *[]ProcessModuleInfo - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListProcessModulesSlotOperationResponse, error) -} - -type ListProcessModulesSlotCompleteResult struct { - Items []ProcessModuleInfo -} - -func (r ListProcessModulesSlotOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListProcessModulesSlotOperationResponse) LoadMore(ctx context.Context) (resp ListProcessModulesSlotOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListProcessModulesSlot ... -func (c WebAppsClient) ListProcessModulesSlot(ctx context.Context, id SlotProcessId) (resp ListProcessModulesSlotOperationResponse, err error) { - req, err := c.preparerForListProcessModulesSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListProcessModulesSlot", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListProcessModulesSlot", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListProcessModulesSlot(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListProcessModulesSlot", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListProcessModulesSlot prepares the ListProcessModulesSlot request. -func (c WebAppsClient) preparerForListProcessModulesSlot(ctx context.Context, id SlotProcessId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/modules", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListProcessModulesSlotWithNextLink prepares the ListProcessModulesSlot request with the given nextLink token. -func (c WebAppsClient) preparerForListProcessModulesSlotWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListProcessModulesSlot handles the response to the ListProcessModulesSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListProcessModulesSlot(resp *http.Response) (result ListProcessModulesSlotOperationResponse, err error) { - type page struct { - Values []ProcessModuleInfo `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListProcessModulesSlotOperationResponse, err error) { - req, err := c.preparerForListProcessModulesSlotWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListProcessModulesSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListProcessModulesSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListProcessModulesSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListProcessModulesSlot", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListProcessModulesSlotComplete retrieves all of the results into a single object -func (c WebAppsClient) ListProcessModulesSlotComplete(ctx context.Context, id SlotProcessId) (ListProcessModulesSlotCompleteResult, error) { - return c.ListProcessModulesSlotCompleteMatchingPredicate(ctx, id, ProcessModuleInfoOperationPredicate{}) -} - -// ListProcessModulesSlotCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListProcessModulesSlotCompleteMatchingPredicate(ctx context.Context, id SlotProcessId, predicate ProcessModuleInfoOperationPredicate) (resp ListProcessModulesSlotCompleteResult, err error) { - items := make([]ProcessModuleInfo, 0) - - page, err := c.ListProcessModulesSlot(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListProcessModulesSlotCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listprocessthreads.go b/resource-manager/web/2022-09-01/webapps/method_listprocessthreads.go new file mode 100644 index 00000000000..30dcc667f96 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listprocessthreads.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListProcessThreadsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProcessThreadInfo +} + +type ListProcessThreadsCompleteResult struct { + Items []ProcessThreadInfo +} + +// ListProcessThreads ... +func (c WebAppsClient) ListProcessThreads(ctx context.Context, id ProcessId) (result ListProcessThreadsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/threads", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ProcessThreadInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListProcessThreadsComplete retrieves all the results into a single object +func (c WebAppsClient) ListProcessThreadsComplete(ctx context.Context, id ProcessId) (ListProcessThreadsCompleteResult, error) { + return c.ListProcessThreadsCompleteMatchingPredicate(ctx, id, ProcessThreadInfoOperationPredicate{}) +} + +// ListProcessThreadsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListProcessThreadsCompleteMatchingPredicate(ctx context.Context, id ProcessId, predicate ProcessThreadInfoOperationPredicate) (result ListProcessThreadsCompleteResult, err error) { + items := make([]ProcessThreadInfo, 0) + + resp, err := c.ListProcessThreads(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListProcessThreadsCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listprocessthreads_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listprocessthreads_autorest.go deleted file mode 100644 index 71b47f5e7c4..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listprocessthreads_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListProcessThreadsOperationResponse struct { - HttpResponse *http.Response - Model *[]ProcessThreadInfo - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListProcessThreadsOperationResponse, error) -} - -type ListProcessThreadsCompleteResult struct { - Items []ProcessThreadInfo -} - -func (r ListProcessThreadsOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListProcessThreadsOperationResponse) LoadMore(ctx context.Context) (resp ListProcessThreadsOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListProcessThreads ... -func (c WebAppsClient) ListProcessThreads(ctx context.Context, id ProcessId) (resp ListProcessThreadsOperationResponse, err error) { - req, err := c.preparerForListProcessThreads(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListProcessThreads", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListProcessThreads", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListProcessThreads(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListProcessThreads", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListProcessThreads prepares the ListProcessThreads request. -func (c WebAppsClient) preparerForListProcessThreads(ctx context.Context, id ProcessId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/threads", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListProcessThreadsWithNextLink prepares the ListProcessThreads request with the given nextLink token. -func (c WebAppsClient) preparerForListProcessThreadsWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListProcessThreads handles the response to the ListProcessThreads request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListProcessThreads(resp *http.Response) (result ListProcessThreadsOperationResponse, err error) { - type page struct { - Values []ProcessThreadInfo `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListProcessThreadsOperationResponse, err error) { - req, err := c.preparerForListProcessThreadsWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListProcessThreads", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListProcessThreads", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListProcessThreads(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListProcessThreads", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListProcessThreadsComplete retrieves all of the results into a single object -func (c WebAppsClient) ListProcessThreadsComplete(ctx context.Context, id ProcessId) (ListProcessThreadsCompleteResult, error) { - return c.ListProcessThreadsCompleteMatchingPredicate(ctx, id, ProcessThreadInfoOperationPredicate{}) -} - -// ListProcessThreadsCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListProcessThreadsCompleteMatchingPredicate(ctx context.Context, id ProcessId, predicate ProcessThreadInfoOperationPredicate) (resp ListProcessThreadsCompleteResult, err error) { - items := make([]ProcessThreadInfo, 0) - - page, err := c.ListProcessThreads(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListProcessThreadsCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listprocessthreadsslot.go b/resource-manager/web/2022-09-01/webapps/method_listprocessthreadsslot.go new file mode 100644 index 00000000000..66a3dbdd5b3 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listprocessthreadsslot.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListProcessThreadsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProcessThreadInfo +} + +type ListProcessThreadsSlotCompleteResult struct { + Items []ProcessThreadInfo +} + +// ListProcessThreadsSlot ... +func (c WebAppsClient) ListProcessThreadsSlot(ctx context.Context, id SlotProcessId) (result ListProcessThreadsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/threads", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ProcessThreadInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListProcessThreadsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListProcessThreadsSlotComplete(ctx context.Context, id SlotProcessId) (ListProcessThreadsSlotCompleteResult, error) { + return c.ListProcessThreadsSlotCompleteMatchingPredicate(ctx, id, ProcessThreadInfoOperationPredicate{}) +} + +// ListProcessThreadsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListProcessThreadsSlotCompleteMatchingPredicate(ctx context.Context, id SlotProcessId, predicate ProcessThreadInfoOperationPredicate) (result ListProcessThreadsSlotCompleteResult, err error) { + items := make([]ProcessThreadInfo, 0) + + resp, err := c.ListProcessThreadsSlot(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListProcessThreadsSlotCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listprocessthreadsslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listprocessthreadsslot_autorest.go deleted file mode 100644 index b66efc3573b..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listprocessthreadsslot_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListProcessThreadsSlotOperationResponse struct { - HttpResponse *http.Response - Model *[]ProcessThreadInfo - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListProcessThreadsSlotOperationResponse, error) -} - -type ListProcessThreadsSlotCompleteResult struct { - Items []ProcessThreadInfo -} - -func (r ListProcessThreadsSlotOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListProcessThreadsSlotOperationResponse) LoadMore(ctx context.Context) (resp ListProcessThreadsSlotOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListProcessThreadsSlot ... -func (c WebAppsClient) ListProcessThreadsSlot(ctx context.Context, id SlotProcessId) (resp ListProcessThreadsSlotOperationResponse, err error) { - req, err := c.preparerForListProcessThreadsSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListProcessThreadsSlot", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListProcessThreadsSlot", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListProcessThreadsSlot(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListProcessThreadsSlot", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListProcessThreadsSlot prepares the ListProcessThreadsSlot request. -func (c WebAppsClient) preparerForListProcessThreadsSlot(ctx context.Context, id SlotProcessId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/threads", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListProcessThreadsSlotWithNextLink prepares the ListProcessThreadsSlot request with the given nextLink token. -func (c WebAppsClient) preparerForListProcessThreadsSlotWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListProcessThreadsSlot handles the response to the ListProcessThreadsSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListProcessThreadsSlot(resp *http.Response) (result ListProcessThreadsSlotOperationResponse, err error) { - type page struct { - Values []ProcessThreadInfo `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListProcessThreadsSlotOperationResponse, err error) { - req, err := c.preparerForListProcessThreadsSlotWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListProcessThreadsSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListProcessThreadsSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListProcessThreadsSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListProcessThreadsSlot", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListProcessThreadsSlotComplete retrieves all of the results into a single object -func (c WebAppsClient) ListProcessThreadsSlotComplete(ctx context.Context, id SlotProcessId) (ListProcessThreadsSlotCompleteResult, error) { - return c.ListProcessThreadsSlotCompleteMatchingPredicate(ctx, id, ProcessThreadInfoOperationPredicate{}) -} - -// ListProcessThreadsSlotCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListProcessThreadsSlotCompleteMatchingPredicate(ctx context.Context, id SlotProcessId, predicate ProcessThreadInfoOperationPredicate) (resp ListProcessThreadsSlotCompleteResult, err error) { - items := make([]ProcessThreadInfo, 0) - - page, err := c.ListProcessThreadsSlot(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListProcessThreadsSlotCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listproductionsitedeploymentstatuses.go b/resource-manager/web/2022-09-01/webapps/method_listproductionsitedeploymentstatuses.go new file mode 100644 index 00000000000..51fe09a844b --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listproductionsitedeploymentstatuses.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListProductionSiteDeploymentStatusesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CsmDeploymentStatus +} + +type ListProductionSiteDeploymentStatusesCompleteResult struct { + Items []CsmDeploymentStatus +} + +// ListProductionSiteDeploymentStatuses ... +func (c WebAppsClient) ListProductionSiteDeploymentStatuses(ctx context.Context, id SiteId) (result ListProductionSiteDeploymentStatusesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/deploymentStatus", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]CsmDeploymentStatus `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListProductionSiteDeploymentStatusesComplete retrieves all the results into a single object +func (c WebAppsClient) ListProductionSiteDeploymentStatusesComplete(ctx context.Context, id SiteId) (ListProductionSiteDeploymentStatusesCompleteResult, error) { + return c.ListProductionSiteDeploymentStatusesCompleteMatchingPredicate(ctx, id, CsmDeploymentStatusOperationPredicate{}) +} + +// ListProductionSiteDeploymentStatusesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListProductionSiteDeploymentStatusesCompleteMatchingPredicate(ctx context.Context, id SiteId, predicate CsmDeploymentStatusOperationPredicate) (result ListProductionSiteDeploymentStatusesCompleteResult, err error) { + items := make([]CsmDeploymentStatus, 0) + + resp, err := c.ListProductionSiteDeploymentStatuses(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListProductionSiteDeploymentStatusesCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listproductionsitedeploymentstatuses_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listproductionsitedeploymentstatuses_autorest.go deleted file mode 100644 index 7b58ca1fcdd..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listproductionsitedeploymentstatuses_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListProductionSiteDeploymentStatusesOperationResponse struct { - HttpResponse *http.Response - Model *[]CsmDeploymentStatus - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListProductionSiteDeploymentStatusesOperationResponse, error) -} - -type ListProductionSiteDeploymentStatusesCompleteResult struct { - Items []CsmDeploymentStatus -} - -func (r ListProductionSiteDeploymentStatusesOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListProductionSiteDeploymentStatusesOperationResponse) LoadMore(ctx context.Context) (resp ListProductionSiteDeploymentStatusesOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListProductionSiteDeploymentStatuses ... -func (c WebAppsClient) ListProductionSiteDeploymentStatuses(ctx context.Context, id SiteId) (resp ListProductionSiteDeploymentStatusesOperationResponse, err error) { - req, err := c.preparerForListProductionSiteDeploymentStatuses(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListProductionSiteDeploymentStatuses", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListProductionSiteDeploymentStatuses", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListProductionSiteDeploymentStatuses(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListProductionSiteDeploymentStatuses", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListProductionSiteDeploymentStatuses prepares the ListProductionSiteDeploymentStatuses request. -func (c WebAppsClient) preparerForListProductionSiteDeploymentStatuses(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/deploymentStatus", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListProductionSiteDeploymentStatusesWithNextLink prepares the ListProductionSiteDeploymentStatuses request with the given nextLink token. -func (c WebAppsClient) preparerForListProductionSiteDeploymentStatusesWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListProductionSiteDeploymentStatuses handles the response to the ListProductionSiteDeploymentStatuses request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListProductionSiteDeploymentStatuses(resp *http.Response) (result ListProductionSiteDeploymentStatusesOperationResponse, err error) { - type page struct { - Values []CsmDeploymentStatus `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListProductionSiteDeploymentStatusesOperationResponse, err error) { - req, err := c.preparerForListProductionSiteDeploymentStatusesWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListProductionSiteDeploymentStatuses", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListProductionSiteDeploymentStatuses", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListProductionSiteDeploymentStatuses(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListProductionSiteDeploymentStatuses", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListProductionSiteDeploymentStatusesComplete retrieves all of the results into a single object -func (c WebAppsClient) ListProductionSiteDeploymentStatusesComplete(ctx context.Context, id SiteId) (ListProductionSiteDeploymentStatusesCompleteResult, error) { - return c.ListProductionSiteDeploymentStatusesCompleteMatchingPredicate(ctx, id, CsmDeploymentStatusOperationPredicate{}) -} - -// ListProductionSiteDeploymentStatusesCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListProductionSiteDeploymentStatusesCompleteMatchingPredicate(ctx context.Context, id SiteId, predicate CsmDeploymentStatusOperationPredicate) (resp ListProductionSiteDeploymentStatusesCompleteResult, err error) { - items := make([]CsmDeploymentStatus, 0) - - page, err := c.ListProductionSiteDeploymentStatuses(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListProductionSiteDeploymentStatusesCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listpubliccertificates.go b/resource-manager/web/2022-09-01/webapps/method_listpubliccertificates.go new file mode 100644 index 00000000000..6e215bf2ccc --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listpubliccertificates.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListPublicCertificatesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PublicCertificate +} + +type ListPublicCertificatesCompleteResult struct { + Items []PublicCertificate +} + +// ListPublicCertificates ... +func (c WebAppsClient) ListPublicCertificates(ctx context.Context, id SiteId) (result ListPublicCertificatesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/publicCertificates", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PublicCertificate `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListPublicCertificatesComplete retrieves all the results into a single object +func (c WebAppsClient) ListPublicCertificatesComplete(ctx context.Context, id SiteId) (ListPublicCertificatesCompleteResult, error) { + return c.ListPublicCertificatesCompleteMatchingPredicate(ctx, id, PublicCertificateOperationPredicate{}) +} + +// ListPublicCertificatesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListPublicCertificatesCompleteMatchingPredicate(ctx context.Context, id SiteId, predicate PublicCertificateOperationPredicate) (result ListPublicCertificatesCompleteResult, err error) { + items := make([]PublicCertificate, 0) + + resp, err := c.ListPublicCertificates(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListPublicCertificatesCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listpubliccertificates_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listpubliccertificates_autorest.go deleted file mode 100644 index 3c7e5162b6c..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listpubliccertificates_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListPublicCertificatesOperationResponse struct { - HttpResponse *http.Response - Model *[]PublicCertificate - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListPublicCertificatesOperationResponse, error) -} - -type ListPublicCertificatesCompleteResult struct { - Items []PublicCertificate -} - -func (r ListPublicCertificatesOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListPublicCertificatesOperationResponse) LoadMore(ctx context.Context) (resp ListPublicCertificatesOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListPublicCertificates ... -func (c WebAppsClient) ListPublicCertificates(ctx context.Context, id SiteId) (resp ListPublicCertificatesOperationResponse, err error) { - req, err := c.preparerForListPublicCertificates(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListPublicCertificates", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListPublicCertificates", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListPublicCertificates(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListPublicCertificates", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListPublicCertificates prepares the ListPublicCertificates request. -func (c WebAppsClient) preparerForListPublicCertificates(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/publicCertificates", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListPublicCertificatesWithNextLink prepares the ListPublicCertificates request with the given nextLink token. -func (c WebAppsClient) preparerForListPublicCertificatesWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListPublicCertificates handles the response to the ListPublicCertificates request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListPublicCertificates(resp *http.Response) (result ListPublicCertificatesOperationResponse, err error) { - type page struct { - Values []PublicCertificate `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListPublicCertificatesOperationResponse, err error) { - req, err := c.preparerForListPublicCertificatesWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListPublicCertificates", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListPublicCertificates", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListPublicCertificates(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListPublicCertificates", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListPublicCertificatesComplete retrieves all of the results into a single object -func (c WebAppsClient) ListPublicCertificatesComplete(ctx context.Context, id SiteId) (ListPublicCertificatesCompleteResult, error) { - return c.ListPublicCertificatesCompleteMatchingPredicate(ctx, id, PublicCertificateOperationPredicate{}) -} - -// ListPublicCertificatesCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListPublicCertificatesCompleteMatchingPredicate(ctx context.Context, id SiteId, predicate PublicCertificateOperationPredicate) (resp ListPublicCertificatesCompleteResult, err error) { - items := make([]PublicCertificate, 0) - - page, err := c.ListPublicCertificates(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListPublicCertificatesCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listpubliccertificatesslot.go b/resource-manager/web/2022-09-01/webapps/method_listpubliccertificatesslot.go new file mode 100644 index 00000000000..9e224e71af6 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listpubliccertificatesslot.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListPublicCertificatesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PublicCertificate +} + +type ListPublicCertificatesSlotCompleteResult struct { + Items []PublicCertificate +} + +// ListPublicCertificatesSlot ... +func (c WebAppsClient) ListPublicCertificatesSlot(ctx context.Context, id SlotId) (result ListPublicCertificatesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/publicCertificates", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PublicCertificate `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListPublicCertificatesSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListPublicCertificatesSlotComplete(ctx context.Context, id SlotId) (ListPublicCertificatesSlotCompleteResult, error) { + return c.ListPublicCertificatesSlotCompleteMatchingPredicate(ctx, id, PublicCertificateOperationPredicate{}) +} + +// ListPublicCertificatesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListPublicCertificatesSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate PublicCertificateOperationPredicate) (result ListPublicCertificatesSlotCompleteResult, err error) { + items := make([]PublicCertificate, 0) + + resp, err := c.ListPublicCertificatesSlot(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListPublicCertificatesSlotCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listpubliccertificatesslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listpubliccertificatesslot_autorest.go deleted file mode 100644 index 5ba87e37815..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listpubliccertificatesslot_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListPublicCertificatesSlotOperationResponse struct { - HttpResponse *http.Response - Model *[]PublicCertificate - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListPublicCertificatesSlotOperationResponse, error) -} - -type ListPublicCertificatesSlotCompleteResult struct { - Items []PublicCertificate -} - -func (r ListPublicCertificatesSlotOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListPublicCertificatesSlotOperationResponse) LoadMore(ctx context.Context) (resp ListPublicCertificatesSlotOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListPublicCertificatesSlot ... -func (c WebAppsClient) ListPublicCertificatesSlot(ctx context.Context, id SlotId) (resp ListPublicCertificatesSlotOperationResponse, err error) { - req, err := c.preparerForListPublicCertificatesSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListPublicCertificatesSlot", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListPublicCertificatesSlot", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListPublicCertificatesSlot(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListPublicCertificatesSlot", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListPublicCertificatesSlot prepares the ListPublicCertificatesSlot request. -func (c WebAppsClient) preparerForListPublicCertificatesSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/publicCertificates", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListPublicCertificatesSlotWithNextLink prepares the ListPublicCertificatesSlot request with the given nextLink token. -func (c WebAppsClient) preparerForListPublicCertificatesSlotWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListPublicCertificatesSlot handles the response to the ListPublicCertificatesSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListPublicCertificatesSlot(resp *http.Response) (result ListPublicCertificatesSlotOperationResponse, err error) { - type page struct { - Values []PublicCertificate `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListPublicCertificatesSlotOperationResponse, err error) { - req, err := c.preparerForListPublicCertificatesSlotWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListPublicCertificatesSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListPublicCertificatesSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListPublicCertificatesSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListPublicCertificatesSlot", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListPublicCertificatesSlotComplete retrieves all of the results into a single object -func (c WebAppsClient) ListPublicCertificatesSlotComplete(ctx context.Context, id SlotId) (ListPublicCertificatesSlotCompleteResult, error) { - return c.ListPublicCertificatesSlotCompleteMatchingPredicate(ctx, id, PublicCertificateOperationPredicate{}) -} - -// ListPublicCertificatesSlotCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListPublicCertificatesSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate PublicCertificateOperationPredicate) (resp ListPublicCertificatesSlotCompleteResult, err error) { - items := make([]PublicCertificate, 0) - - page, err := c.ListPublicCertificatesSlot(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListPublicCertificatesSlotCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listpublishingcredentials.go b/resource-manager/web/2022-09-01/webapps/method_listpublishingcredentials.go new file mode 100644 index 00000000000..355bd2caf7a --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listpublishingcredentials.go @@ -0,0 +1,69 @@ +package webapps + +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 ListPublishingCredentialsOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ListPublishingCredentials ... +func (c WebAppsClient) ListPublishingCredentials(ctx context.Context, id SiteId) (result ListPublishingCredentialsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/publishingcredentials/list", 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 +} + +// ListPublishingCredentialsThenPoll performs ListPublishingCredentials then polls until it's completed +func (c WebAppsClient) ListPublishingCredentialsThenPoll(ctx context.Context, id SiteId) error { + result, err := c.ListPublishingCredentials(ctx, id) + if err != nil { + return fmt.Errorf("performing ListPublishingCredentials: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ListPublishingCredentials: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listpublishingcredentials_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listpublishingcredentials_autorest.go deleted file mode 100644 index 063f733d2bc..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listpublishingcredentials_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListPublishingCredentialsOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// ListPublishingCredentials ... -func (c WebAppsClient) ListPublishingCredentials(ctx context.Context, id SiteId) (result ListPublishingCredentialsOperationResponse, err error) { - req, err := c.preparerForListPublishingCredentials(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListPublishingCredentials", nil, "Failure preparing request") - return - } - - result, err = c.senderForListPublishingCredentials(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListPublishingCredentials", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// ListPublishingCredentialsThenPoll performs ListPublishingCredentials then polls until it's completed -func (c WebAppsClient) ListPublishingCredentialsThenPoll(ctx context.Context, id SiteId) error { - result, err := c.ListPublishingCredentials(ctx, id) - if err != nil { - return fmt.Errorf("performing ListPublishingCredentials: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after ListPublishingCredentials: %+v", err) - } - - return nil -} - -// preparerForListPublishingCredentials prepares the ListPublishingCredentials request. -func (c WebAppsClient) preparerForListPublishingCredentials(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/publishingcredentials/list", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForListPublishingCredentials sends the ListPublishingCredentials request. The method will close the -// http.Response Body if it receives an error. -func (c WebAppsClient) senderForListPublishingCredentials(ctx context.Context, req *http.Request) (future ListPublishingCredentialsOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listpublishingcredentialsslot.go b/resource-manager/web/2022-09-01/webapps/method_listpublishingcredentialsslot.go new file mode 100644 index 00000000000..0e65accee32 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listpublishingcredentialsslot.go @@ -0,0 +1,69 @@ +package webapps + +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 ListPublishingCredentialsSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ListPublishingCredentialsSlot ... +func (c WebAppsClient) ListPublishingCredentialsSlot(ctx context.Context, id SlotId) (result ListPublishingCredentialsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/publishingcredentials/list", 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 +} + +// ListPublishingCredentialsSlotThenPoll performs ListPublishingCredentialsSlot then polls until it's completed +func (c WebAppsClient) ListPublishingCredentialsSlotThenPoll(ctx context.Context, id SlotId) error { + result, err := c.ListPublishingCredentialsSlot(ctx, id) + if err != nil { + return fmt.Errorf("performing ListPublishingCredentialsSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ListPublishingCredentialsSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listpublishingcredentialsslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listpublishingcredentialsslot_autorest.go deleted file mode 100644 index 19686d9a43b..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listpublishingcredentialsslot_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListPublishingCredentialsSlotOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// ListPublishingCredentialsSlot ... -func (c WebAppsClient) ListPublishingCredentialsSlot(ctx context.Context, id SlotId) (result ListPublishingCredentialsSlotOperationResponse, err error) { - req, err := c.preparerForListPublishingCredentialsSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListPublishingCredentialsSlot", nil, "Failure preparing request") - return - } - - result, err = c.senderForListPublishingCredentialsSlot(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListPublishingCredentialsSlot", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// ListPublishingCredentialsSlotThenPoll performs ListPublishingCredentialsSlot then polls until it's completed -func (c WebAppsClient) ListPublishingCredentialsSlotThenPoll(ctx context.Context, id SlotId) error { - result, err := c.ListPublishingCredentialsSlot(ctx, id) - if err != nil { - return fmt.Errorf("performing ListPublishingCredentialsSlot: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after ListPublishingCredentialsSlot: %+v", err) - } - - return nil -} - -// preparerForListPublishingCredentialsSlot prepares the ListPublishingCredentialsSlot request. -func (c WebAppsClient) preparerForListPublishingCredentialsSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/publishingcredentials/list", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForListPublishingCredentialsSlot sends the ListPublishingCredentialsSlot request. The method will close the -// http.Response Body if it receives an error. -func (c WebAppsClient) senderForListPublishingCredentialsSlot(ctx context.Context, req *http.Request) (future ListPublishingCredentialsSlotOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listpublishingprofilexmlwithsecrets.go b/resource-manager/web/2022-09-01/webapps/method_listpublishingprofilexmlwithsecrets.go new file mode 100644 index 00000000000..d8353104bd6 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listpublishingprofilexmlwithsecrets.go @@ -0,0 +1,56 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListPublishingProfileXmlWithSecretsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]byte +} + +// ListPublishingProfileXmlWithSecrets ... +func (c WebAppsClient) ListPublishingProfileXmlWithSecrets(ctx context.Context, id SiteId, input CsmPublishingProfileOptions) (result ListPublishingProfileXmlWithSecretsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/publishxml", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listpublishingprofilexmlwithsecrets_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listpublishingprofilexmlwithsecrets_autorest.go deleted file mode 100644 index 4c973b4ac2a..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listpublishingprofilexmlwithsecrets_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListPublishingProfileXmlWithSecretsOperationResponse struct { - HttpResponse *http.Response - Model *[]byte -} - -// ListPublishingProfileXmlWithSecrets ... -func (c WebAppsClient) ListPublishingProfileXmlWithSecrets(ctx context.Context, id SiteId, input CsmPublishingProfileOptions) (result ListPublishingProfileXmlWithSecretsOperationResponse, err error) { - req, err := c.preparerForListPublishingProfileXmlWithSecrets(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListPublishingProfileXmlWithSecrets", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListPublishingProfileXmlWithSecrets", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListPublishingProfileXmlWithSecrets(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListPublishingProfileXmlWithSecrets", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListPublishingProfileXmlWithSecrets prepares the ListPublishingProfileXmlWithSecrets request. -func (c WebAppsClient) preparerForListPublishingProfileXmlWithSecrets(ctx context.Context, id SiteId, input CsmPublishingProfileOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/publishxml", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListPublishingProfileXmlWithSecrets handles the response to the ListPublishingProfileXmlWithSecrets request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListPublishingProfileXmlWithSecrets(resp *http.Response) (result ListPublishingProfileXmlWithSecretsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listpublishingprofilexmlwithsecretsslot.go b/resource-manager/web/2022-09-01/webapps/method_listpublishingprofilexmlwithsecretsslot.go new file mode 100644 index 00000000000..f1071773e93 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listpublishingprofilexmlwithsecretsslot.go @@ -0,0 +1,56 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListPublishingProfileXmlWithSecretsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]byte +} + +// ListPublishingProfileXmlWithSecretsSlot ... +func (c WebAppsClient) ListPublishingProfileXmlWithSecretsSlot(ctx context.Context, id SlotId, input CsmPublishingProfileOptions) (result ListPublishingProfileXmlWithSecretsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/publishxml", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listpublishingprofilexmlwithsecretsslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listpublishingprofilexmlwithsecretsslot_autorest.go deleted file mode 100644 index 2e391ba6e97..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listpublishingprofilexmlwithsecretsslot_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListPublishingProfileXmlWithSecretsSlotOperationResponse struct { - HttpResponse *http.Response - Model *[]byte -} - -// ListPublishingProfileXmlWithSecretsSlot ... -func (c WebAppsClient) ListPublishingProfileXmlWithSecretsSlot(ctx context.Context, id SlotId, input CsmPublishingProfileOptions) (result ListPublishingProfileXmlWithSecretsSlotOperationResponse, err error) { - req, err := c.preparerForListPublishingProfileXmlWithSecretsSlot(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListPublishingProfileXmlWithSecretsSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListPublishingProfileXmlWithSecretsSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListPublishingProfileXmlWithSecretsSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListPublishingProfileXmlWithSecretsSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListPublishingProfileXmlWithSecretsSlot prepares the ListPublishingProfileXmlWithSecretsSlot request. -func (c WebAppsClient) preparerForListPublishingProfileXmlWithSecretsSlot(ctx context.Context, id SlotId, input CsmPublishingProfileOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/publishxml", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListPublishingProfileXmlWithSecretsSlot handles the response to the ListPublishingProfileXmlWithSecretsSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListPublishingProfileXmlWithSecretsSlot(resp *http.Response) (result ListPublishingProfileXmlWithSecretsSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listrelayserviceconnections.go b/resource-manager/web/2022-09-01/webapps/method_listrelayserviceconnections.go new file mode 100644 index 00000000000..f336f37401d --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listrelayserviceconnections.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListRelayServiceConnectionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RelayServiceConnectionEntity +} + +// ListRelayServiceConnections ... +func (c WebAppsClient) ListRelayServiceConnections(ctx context.Context, id SiteId) (result ListRelayServiceConnectionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/hybridConnection", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listrelayserviceconnections_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listrelayserviceconnections_autorest.go deleted file mode 100644 index 229bca4c19e..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listrelayserviceconnections_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListRelayServiceConnectionsOperationResponse struct { - HttpResponse *http.Response - Model *RelayServiceConnectionEntity -} - -// ListRelayServiceConnections ... -func (c WebAppsClient) ListRelayServiceConnections(ctx context.Context, id SiteId) (result ListRelayServiceConnectionsOperationResponse, err error) { - req, err := c.preparerForListRelayServiceConnections(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListRelayServiceConnections", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListRelayServiceConnections", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListRelayServiceConnections(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListRelayServiceConnections", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListRelayServiceConnections prepares the ListRelayServiceConnections request. -func (c WebAppsClient) preparerForListRelayServiceConnections(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/hybridConnection", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListRelayServiceConnections handles the response to the ListRelayServiceConnections request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListRelayServiceConnections(resp *http.Response) (result ListRelayServiceConnectionsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listrelayserviceconnectionsslot.go b/resource-manager/web/2022-09-01/webapps/method_listrelayserviceconnectionsslot.go new file mode 100644 index 00000000000..032e21d1b51 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listrelayserviceconnectionsslot.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListRelayServiceConnectionsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RelayServiceConnectionEntity +} + +// ListRelayServiceConnectionsSlot ... +func (c WebAppsClient) ListRelayServiceConnectionsSlot(ctx context.Context, id SlotId) (result ListRelayServiceConnectionsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/hybridConnection", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listrelayserviceconnectionsslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listrelayserviceconnectionsslot_autorest.go deleted file mode 100644 index d8ac0b4c5a1..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listrelayserviceconnectionsslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListRelayServiceConnectionsSlotOperationResponse struct { - HttpResponse *http.Response - Model *RelayServiceConnectionEntity -} - -// ListRelayServiceConnectionsSlot ... -func (c WebAppsClient) ListRelayServiceConnectionsSlot(ctx context.Context, id SlotId) (result ListRelayServiceConnectionsSlotOperationResponse, err error) { - req, err := c.preparerForListRelayServiceConnectionsSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListRelayServiceConnectionsSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListRelayServiceConnectionsSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListRelayServiceConnectionsSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListRelayServiceConnectionsSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListRelayServiceConnectionsSlot prepares the ListRelayServiceConnectionsSlot request. -func (c WebAppsClient) preparerForListRelayServiceConnectionsSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/hybridConnection", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListRelayServiceConnectionsSlot handles the response to the ListRelayServiceConnectionsSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListRelayServiceConnectionsSlot(resp *http.Response) (result ListRelayServiceConnectionsSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listsitebackups.go b/resource-manager/web/2022-09-01/webapps/method_listsitebackups.go new file mode 100644 index 00000000000..118b60b0f89 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listsitebackups.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListSiteBackupsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]BackupItem +} + +type ListSiteBackupsCompleteResult struct { + Items []BackupItem +} + +// ListSiteBackups ... +func (c WebAppsClient) ListSiteBackups(ctx context.Context, id SiteId) (result ListSiteBackupsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listbackups", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]BackupItem `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteBackupsComplete retrieves all the results into a single object +func (c WebAppsClient) ListSiteBackupsComplete(ctx context.Context, id SiteId) (ListSiteBackupsCompleteResult, error) { + return c.ListSiteBackupsCompleteMatchingPredicate(ctx, id, BackupItemOperationPredicate{}) +} + +// ListSiteBackupsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListSiteBackupsCompleteMatchingPredicate(ctx context.Context, id SiteId, predicate BackupItemOperationPredicate) (result ListSiteBackupsCompleteResult, err error) { + items := make([]BackupItem, 0) + + resp, err := c.ListSiteBackups(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListSiteBackupsCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listsitebackups_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listsitebackups_autorest.go deleted file mode 100644 index c9ba1994fe0..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listsitebackups_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListSiteBackupsOperationResponse struct { - HttpResponse *http.Response - Model *[]BackupItem - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListSiteBackupsOperationResponse, error) -} - -type ListSiteBackupsCompleteResult struct { - Items []BackupItem -} - -func (r ListSiteBackupsOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListSiteBackupsOperationResponse) LoadMore(ctx context.Context) (resp ListSiteBackupsOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListSiteBackups ... -func (c WebAppsClient) ListSiteBackups(ctx context.Context, id SiteId) (resp ListSiteBackupsOperationResponse, err error) { - req, err := c.preparerForListSiteBackups(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSiteBackups", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSiteBackups", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListSiteBackups(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSiteBackups", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListSiteBackups prepares the ListSiteBackups request. -func (c WebAppsClient) preparerForListSiteBackups(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/listbackups", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListSiteBackupsWithNextLink prepares the ListSiteBackups request with the given nextLink token. -func (c WebAppsClient) preparerForListSiteBackupsWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListSiteBackups handles the response to the ListSiteBackups request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListSiteBackups(resp *http.Response) (result ListSiteBackupsOperationResponse, err error) { - type page struct { - Values []BackupItem `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListSiteBackupsOperationResponse, err error) { - req, err := c.preparerForListSiteBackupsWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSiteBackups", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSiteBackups", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListSiteBackups(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSiteBackups", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListSiteBackupsComplete retrieves all of the results into a single object -func (c WebAppsClient) ListSiteBackupsComplete(ctx context.Context, id SiteId) (ListSiteBackupsCompleteResult, error) { - return c.ListSiteBackupsCompleteMatchingPredicate(ctx, id, BackupItemOperationPredicate{}) -} - -// ListSiteBackupsCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListSiteBackupsCompleteMatchingPredicate(ctx context.Context, id SiteId, predicate BackupItemOperationPredicate) (resp ListSiteBackupsCompleteResult, err error) { - items := make([]BackupItem, 0) - - page, err := c.ListSiteBackups(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListSiteBackupsCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listsitebackupsslot.go b/resource-manager/web/2022-09-01/webapps/method_listsitebackupsslot.go new file mode 100644 index 00000000000..1af84c34f46 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listsitebackupsslot.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListSiteBackupsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]BackupItem +} + +type ListSiteBackupsSlotCompleteResult struct { + Items []BackupItem +} + +// ListSiteBackupsSlot ... +func (c WebAppsClient) ListSiteBackupsSlot(ctx context.Context, id SlotId) (result ListSiteBackupsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listbackups", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]BackupItem `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteBackupsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListSiteBackupsSlotComplete(ctx context.Context, id SlotId) (ListSiteBackupsSlotCompleteResult, error) { + return c.ListSiteBackupsSlotCompleteMatchingPredicate(ctx, id, BackupItemOperationPredicate{}) +} + +// ListSiteBackupsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListSiteBackupsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate BackupItemOperationPredicate) (result ListSiteBackupsSlotCompleteResult, err error) { + items := make([]BackupItem, 0) + + resp, err := c.ListSiteBackupsSlot(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListSiteBackupsSlotCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listsitebackupsslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listsitebackupsslot_autorest.go deleted file mode 100644 index 337fd809623..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listsitebackupsslot_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListSiteBackupsSlotOperationResponse struct { - HttpResponse *http.Response - Model *[]BackupItem - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListSiteBackupsSlotOperationResponse, error) -} - -type ListSiteBackupsSlotCompleteResult struct { - Items []BackupItem -} - -func (r ListSiteBackupsSlotOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListSiteBackupsSlotOperationResponse) LoadMore(ctx context.Context) (resp ListSiteBackupsSlotOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListSiteBackupsSlot ... -func (c WebAppsClient) ListSiteBackupsSlot(ctx context.Context, id SlotId) (resp ListSiteBackupsSlotOperationResponse, err error) { - req, err := c.preparerForListSiteBackupsSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSiteBackupsSlot", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSiteBackupsSlot", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListSiteBackupsSlot(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSiteBackupsSlot", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListSiteBackupsSlot prepares the ListSiteBackupsSlot request. -func (c WebAppsClient) preparerForListSiteBackupsSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/listbackups", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListSiteBackupsSlotWithNextLink prepares the ListSiteBackupsSlot request with the given nextLink token. -func (c WebAppsClient) preparerForListSiteBackupsSlotWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListSiteBackupsSlot handles the response to the ListSiteBackupsSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListSiteBackupsSlot(resp *http.Response) (result ListSiteBackupsSlotOperationResponse, err error) { - type page struct { - Values []BackupItem `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListSiteBackupsSlotOperationResponse, err error) { - req, err := c.preparerForListSiteBackupsSlotWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSiteBackupsSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSiteBackupsSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListSiteBackupsSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSiteBackupsSlot", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListSiteBackupsSlotComplete retrieves all of the results into a single object -func (c WebAppsClient) ListSiteBackupsSlotComplete(ctx context.Context, id SlotId) (ListSiteBackupsSlotCompleteResult, error) { - return c.ListSiteBackupsSlotCompleteMatchingPredicate(ctx, id, BackupItemOperationPredicate{}) -} - -// ListSiteBackupsSlotCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListSiteBackupsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate BackupItemOperationPredicate) (resp ListSiteBackupsSlotCompleteResult, err error) { - items := make([]BackupItem, 0) - - page, err := c.ListSiteBackupsSlot(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListSiteBackupsSlotCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listsiteextensions.go b/resource-manager/web/2022-09-01/webapps/method_listsiteextensions.go new file mode 100644 index 00000000000..0c9e423fcb5 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listsiteextensions.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListSiteExtensionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SiteExtensionInfo +} + +type ListSiteExtensionsCompleteResult struct { + Items []SiteExtensionInfo +} + +// ListSiteExtensions ... +func (c WebAppsClient) ListSiteExtensions(ctx context.Context, id SiteId) (result ListSiteExtensionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/siteExtensions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]SiteExtensionInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteExtensionsComplete retrieves all the results into a single object +func (c WebAppsClient) ListSiteExtensionsComplete(ctx context.Context, id SiteId) (ListSiteExtensionsCompleteResult, error) { + return c.ListSiteExtensionsCompleteMatchingPredicate(ctx, id, SiteExtensionInfoOperationPredicate{}) +} + +// ListSiteExtensionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListSiteExtensionsCompleteMatchingPredicate(ctx context.Context, id SiteId, predicate SiteExtensionInfoOperationPredicate) (result ListSiteExtensionsCompleteResult, err error) { + items := make([]SiteExtensionInfo, 0) + + resp, err := c.ListSiteExtensions(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListSiteExtensionsCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listsiteextensions_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listsiteextensions_autorest.go deleted file mode 100644 index 93c471ef0c9..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listsiteextensions_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListSiteExtensionsOperationResponse struct { - HttpResponse *http.Response - Model *[]SiteExtensionInfo - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListSiteExtensionsOperationResponse, error) -} - -type ListSiteExtensionsCompleteResult struct { - Items []SiteExtensionInfo -} - -func (r ListSiteExtensionsOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListSiteExtensionsOperationResponse) LoadMore(ctx context.Context) (resp ListSiteExtensionsOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListSiteExtensions ... -func (c WebAppsClient) ListSiteExtensions(ctx context.Context, id SiteId) (resp ListSiteExtensionsOperationResponse, err error) { - req, err := c.preparerForListSiteExtensions(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSiteExtensions", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSiteExtensions", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListSiteExtensions(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSiteExtensions", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListSiteExtensions prepares the ListSiteExtensions request. -func (c WebAppsClient) preparerForListSiteExtensions(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/siteExtensions", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListSiteExtensionsWithNextLink prepares the ListSiteExtensions request with the given nextLink token. -func (c WebAppsClient) preparerForListSiteExtensionsWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListSiteExtensions handles the response to the ListSiteExtensions request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListSiteExtensions(resp *http.Response) (result ListSiteExtensionsOperationResponse, err error) { - type page struct { - Values []SiteExtensionInfo `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListSiteExtensionsOperationResponse, err error) { - req, err := c.preparerForListSiteExtensionsWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSiteExtensions", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSiteExtensions", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListSiteExtensions(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSiteExtensions", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListSiteExtensionsComplete retrieves all of the results into a single object -func (c WebAppsClient) ListSiteExtensionsComplete(ctx context.Context, id SiteId) (ListSiteExtensionsCompleteResult, error) { - return c.ListSiteExtensionsCompleteMatchingPredicate(ctx, id, SiteExtensionInfoOperationPredicate{}) -} - -// ListSiteExtensionsCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListSiteExtensionsCompleteMatchingPredicate(ctx context.Context, id SiteId, predicate SiteExtensionInfoOperationPredicate) (resp ListSiteExtensionsCompleteResult, err error) { - items := make([]SiteExtensionInfo, 0) - - page, err := c.ListSiteExtensions(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListSiteExtensionsCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listsiteextensionsslot.go b/resource-manager/web/2022-09-01/webapps/method_listsiteextensionsslot.go new file mode 100644 index 00000000000..22caad50dad --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listsiteextensionsslot.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListSiteExtensionsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SiteExtensionInfo +} + +type ListSiteExtensionsSlotCompleteResult struct { + Items []SiteExtensionInfo +} + +// ListSiteExtensionsSlot ... +func (c WebAppsClient) ListSiteExtensionsSlot(ctx context.Context, id SlotId) (result ListSiteExtensionsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/siteExtensions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]SiteExtensionInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteExtensionsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListSiteExtensionsSlotComplete(ctx context.Context, id SlotId) (ListSiteExtensionsSlotCompleteResult, error) { + return c.ListSiteExtensionsSlotCompleteMatchingPredicate(ctx, id, SiteExtensionInfoOperationPredicate{}) +} + +// ListSiteExtensionsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListSiteExtensionsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate SiteExtensionInfoOperationPredicate) (result ListSiteExtensionsSlotCompleteResult, err error) { + items := make([]SiteExtensionInfo, 0) + + resp, err := c.ListSiteExtensionsSlot(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListSiteExtensionsSlotCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listsiteextensionsslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listsiteextensionsslot_autorest.go deleted file mode 100644 index 887a3bb7fa3..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listsiteextensionsslot_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListSiteExtensionsSlotOperationResponse struct { - HttpResponse *http.Response - Model *[]SiteExtensionInfo - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListSiteExtensionsSlotOperationResponse, error) -} - -type ListSiteExtensionsSlotCompleteResult struct { - Items []SiteExtensionInfo -} - -func (r ListSiteExtensionsSlotOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListSiteExtensionsSlotOperationResponse) LoadMore(ctx context.Context) (resp ListSiteExtensionsSlotOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListSiteExtensionsSlot ... -func (c WebAppsClient) ListSiteExtensionsSlot(ctx context.Context, id SlotId) (resp ListSiteExtensionsSlotOperationResponse, err error) { - req, err := c.preparerForListSiteExtensionsSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSiteExtensionsSlot", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSiteExtensionsSlot", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListSiteExtensionsSlot(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSiteExtensionsSlot", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListSiteExtensionsSlot prepares the ListSiteExtensionsSlot request. -func (c WebAppsClient) preparerForListSiteExtensionsSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/siteExtensions", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListSiteExtensionsSlotWithNextLink prepares the ListSiteExtensionsSlot request with the given nextLink token. -func (c WebAppsClient) preparerForListSiteExtensionsSlotWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListSiteExtensionsSlot handles the response to the ListSiteExtensionsSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListSiteExtensionsSlot(resp *http.Response) (result ListSiteExtensionsSlotOperationResponse, err error) { - type page struct { - Values []SiteExtensionInfo `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListSiteExtensionsSlotOperationResponse, err error) { - req, err := c.preparerForListSiteExtensionsSlotWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSiteExtensionsSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSiteExtensionsSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListSiteExtensionsSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSiteExtensionsSlot", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListSiteExtensionsSlotComplete retrieves all of the results into a single object -func (c WebAppsClient) ListSiteExtensionsSlotComplete(ctx context.Context, id SlotId) (ListSiteExtensionsSlotCompleteResult, error) { - return c.ListSiteExtensionsSlotCompleteMatchingPredicate(ctx, id, SiteExtensionInfoOperationPredicate{}) -} - -// ListSiteExtensionsSlotCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListSiteExtensionsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate SiteExtensionInfoOperationPredicate) (resp ListSiteExtensionsSlotCompleteResult, err error) { - items := make([]SiteExtensionInfo, 0) - - page, err := c.ListSiteExtensionsSlot(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListSiteExtensionsSlotCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listsitepushsettings.go b/resource-manager/web/2022-09-01/webapps/method_listsitepushsettings.go new file mode 100644 index 00000000000..d5d603d19ce --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listsitepushsettings.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListSitePushSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PushSettings +} + +// ListSitePushSettings ... +func (c WebAppsClient) ListSitePushSettings(ctx context.Context, id SiteId) (result ListSitePushSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/pushsettings/list", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listsitepushsettings_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listsitepushsettings_autorest.go deleted file mode 100644 index a645943f3fb..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listsitepushsettings_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListSitePushSettingsOperationResponse struct { - HttpResponse *http.Response - Model *PushSettings -} - -// ListSitePushSettings ... -func (c WebAppsClient) ListSitePushSettings(ctx context.Context, id SiteId) (result ListSitePushSettingsOperationResponse, err error) { - req, err := c.preparerForListSitePushSettings(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSitePushSettings", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSitePushSettings", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListSitePushSettings(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSitePushSettings", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListSitePushSettings prepares the ListSitePushSettings request. -func (c WebAppsClient) preparerForListSitePushSettings(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/pushsettings/list", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListSitePushSettings handles the response to the ListSitePushSettings request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListSitePushSettings(resp *http.Response) (result ListSitePushSettingsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listsitepushsettingsslot.go b/resource-manager/web/2022-09-01/webapps/method_listsitepushsettingsslot.go new file mode 100644 index 00000000000..e15cd811ffe --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listsitepushsettingsslot.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListSitePushSettingsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PushSettings +} + +// ListSitePushSettingsSlot ... +func (c WebAppsClient) ListSitePushSettingsSlot(ctx context.Context, id SlotId) (result ListSitePushSettingsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/pushsettings/list", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listsitepushsettingsslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listsitepushsettingsslot_autorest.go deleted file mode 100644 index a44a12fe0d0..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listsitepushsettingsslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListSitePushSettingsSlotOperationResponse struct { - HttpResponse *http.Response - Model *PushSettings -} - -// ListSitePushSettingsSlot ... -func (c WebAppsClient) ListSitePushSettingsSlot(ctx context.Context, id SlotId) (result ListSitePushSettingsSlotOperationResponse, err error) { - req, err := c.preparerForListSitePushSettingsSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSitePushSettingsSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSitePushSettingsSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListSitePushSettingsSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSitePushSettingsSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListSitePushSettingsSlot prepares the ListSitePushSettingsSlot request. -func (c WebAppsClient) preparerForListSitePushSettingsSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/pushsettings/list", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListSitePushSettingsSlot handles the response to the ListSitePushSettingsSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListSitePushSettingsSlot(resp *http.Response) (result ListSitePushSettingsSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listslotconfigurationnames.go b/resource-manager/web/2022-09-01/webapps/method_listslotconfigurationnames.go new file mode 100644 index 00000000000..f48df1e7e88 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listslotconfigurationnames.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListSlotConfigurationNamesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SlotConfigNamesResource +} + +// ListSlotConfigurationNames ... +func (c WebAppsClient) ListSlotConfigurationNames(ctx context.Context, id SiteId) (result ListSlotConfigurationNamesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/config/slotConfigNames", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listslotconfigurationnames_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listslotconfigurationnames_autorest.go deleted file mode 100644 index 0d81a8accbd..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listslotconfigurationnames_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListSlotConfigurationNamesOperationResponse struct { - HttpResponse *http.Response - Model *SlotConfigNamesResource -} - -// ListSlotConfigurationNames ... -func (c WebAppsClient) ListSlotConfigurationNames(ctx context.Context, id SiteId) (result ListSlotConfigurationNamesOperationResponse, err error) { - req, err := c.preparerForListSlotConfigurationNames(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSlotConfigurationNames", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSlotConfigurationNames", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListSlotConfigurationNames(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSlotConfigurationNames", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListSlotConfigurationNames prepares the ListSlotConfigurationNames request. -func (c WebAppsClient) preparerForListSlotConfigurationNames(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/slotConfigNames", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListSlotConfigurationNames handles the response to the ListSlotConfigurationNames request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListSlotConfigurationNames(resp *http.Response) (result ListSlotConfigurationNamesOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listslotdifferencesfromproduction.go b/resource-manager/web/2022-09-01/webapps/method_listslotdifferencesfromproduction.go new file mode 100644 index 00000000000..df7921f6dad --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listslotdifferencesfromproduction.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListSlotDifferencesFromProductionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SlotDifference +} + +type ListSlotDifferencesFromProductionCompleteResult struct { + Items []SlotDifference +} + +// ListSlotDifferencesFromProduction ... +func (c WebAppsClient) ListSlotDifferencesFromProduction(ctx context.Context, id SiteId, input CsmSlotEntity) (result ListSlotDifferencesFromProductionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/slotsdiffs", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]SlotDifference `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSlotDifferencesFromProductionComplete retrieves all the results into a single object +func (c WebAppsClient) ListSlotDifferencesFromProductionComplete(ctx context.Context, id SiteId, input CsmSlotEntity) (ListSlotDifferencesFromProductionCompleteResult, error) { + return c.ListSlotDifferencesFromProductionCompleteMatchingPredicate(ctx, id, input, SlotDifferenceOperationPredicate{}) +} + +// ListSlotDifferencesFromProductionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListSlotDifferencesFromProductionCompleteMatchingPredicate(ctx context.Context, id SiteId, input CsmSlotEntity, predicate SlotDifferenceOperationPredicate) (result ListSlotDifferencesFromProductionCompleteResult, err error) { + items := make([]SlotDifference, 0) + + resp, err := c.ListSlotDifferencesFromProduction(ctx, id, input) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListSlotDifferencesFromProductionCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listslotdifferencesfromproduction_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listslotdifferencesfromproduction_autorest.go deleted file mode 100644 index 5f015757300..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listslotdifferencesfromproduction_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListSlotDifferencesFromProductionOperationResponse struct { - HttpResponse *http.Response - Model *[]SlotDifference - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListSlotDifferencesFromProductionOperationResponse, error) -} - -type ListSlotDifferencesFromProductionCompleteResult struct { - Items []SlotDifference -} - -func (r ListSlotDifferencesFromProductionOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListSlotDifferencesFromProductionOperationResponse) LoadMore(ctx context.Context) (resp ListSlotDifferencesFromProductionOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListSlotDifferencesFromProduction ... -func (c WebAppsClient) ListSlotDifferencesFromProduction(ctx context.Context, id SiteId, input CsmSlotEntity) (resp ListSlotDifferencesFromProductionOperationResponse, err error) { - req, err := c.preparerForListSlotDifferencesFromProduction(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSlotDifferencesFromProduction", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSlotDifferencesFromProduction", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListSlotDifferencesFromProduction(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSlotDifferencesFromProduction", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListSlotDifferencesFromProduction prepares the ListSlotDifferencesFromProduction request. -func (c WebAppsClient) preparerForListSlotDifferencesFromProduction(ctx context.Context, id SiteId, input CsmSlotEntity) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/slotsdiffs", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListSlotDifferencesFromProductionWithNextLink prepares the ListSlotDifferencesFromProduction request with the given nextLink token. -func (c WebAppsClient) preparerForListSlotDifferencesFromProductionWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListSlotDifferencesFromProduction handles the response to the ListSlotDifferencesFromProduction request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListSlotDifferencesFromProduction(resp *http.Response) (result ListSlotDifferencesFromProductionOperationResponse, err error) { - type page struct { - Values []SlotDifference `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListSlotDifferencesFromProductionOperationResponse, err error) { - req, err := c.preparerForListSlotDifferencesFromProductionWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSlotDifferencesFromProduction", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSlotDifferencesFromProduction", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListSlotDifferencesFromProduction(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSlotDifferencesFromProduction", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListSlotDifferencesFromProductionComplete retrieves all of the results into a single object -func (c WebAppsClient) ListSlotDifferencesFromProductionComplete(ctx context.Context, id SiteId, input CsmSlotEntity) (ListSlotDifferencesFromProductionCompleteResult, error) { - return c.ListSlotDifferencesFromProductionCompleteMatchingPredicate(ctx, id, input, SlotDifferenceOperationPredicate{}) -} - -// ListSlotDifferencesFromProductionCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListSlotDifferencesFromProductionCompleteMatchingPredicate(ctx context.Context, id SiteId, input CsmSlotEntity, predicate SlotDifferenceOperationPredicate) (resp ListSlotDifferencesFromProductionCompleteResult, err error) { - items := make([]SlotDifference, 0) - - page, err := c.ListSlotDifferencesFromProduction(ctx, id, input) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListSlotDifferencesFromProductionCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listslotdifferencesslot.go b/resource-manager/web/2022-09-01/webapps/method_listslotdifferencesslot.go new file mode 100644 index 00000000000..f204d6e339d --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listslotdifferencesslot.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListSlotDifferencesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SlotDifference +} + +type ListSlotDifferencesSlotCompleteResult struct { + Items []SlotDifference +} + +// ListSlotDifferencesSlot ... +func (c WebAppsClient) ListSlotDifferencesSlot(ctx context.Context, id SlotId, input CsmSlotEntity) (result ListSlotDifferencesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/slotsdiffs", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]SlotDifference `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSlotDifferencesSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListSlotDifferencesSlotComplete(ctx context.Context, id SlotId, input CsmSlotEntity) (ListSlotDifferencesSlotCompleteResult, error) { + return c.ListSlotDifferencesSlotCompleteMatchingPredicate(ctx, id, input, SlotDifferenceOperationPredicate{}) +} + +// ListSlotDifferencesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListSlotDifferencesSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, input CsmSlotEntity, predicate SlotDifferenceOperationPredicate) (result ListSlotDifferencesSlotCompleteResult, err error) { + items := make([]SlotDifference, 0) + + resp, err := c.ListSlotDifferencesSlot(ctx, id, input) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListSlotDifferencesSlotCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listslotdifferencesslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listslotdifferencesslot_autorest.go deleted file mode 100644 index 0543e0c97a5..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listslotdifferencesslot_autorest.go +++ /dev/null @@ -1,187 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListSlotDifferencesSlotOperationResponse struct { - HttpResponse *http.Response - Model *[]SlotDifference - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListSlotDifferencesSlotOperationResponse, error) -} - -type ListSlotDifferencesSlotCompleteResult struct { - Items []SlotDifference -} - -func (r ListSlotDifferencesSlotOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListSlotDifferencesSlotOperationResponse) LoadMore(ctx context.Context) (resp ListSlotDifferencesSlotOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListSlotDifferencesSlot ... -func (c WebAppsClient) ListSlotDifferencesSlot(ctx context.Context, id SlotId, input CsmSlotEntity) (resp ListSlotDifferencesSlotOperationResponse, err error) { - req, err := c.preparerForListSlotDifferencesSlot(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSlotDifferencesSlot", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSlotDifferencesSlot", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListSlotDifferencesSlot(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSlotDifferencesSlot", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListSlotDifferencesSlot prepares the ListSlotDifferencesSlot request. -func (c WebAppsClient) preparerForListSlotDifferencesSlot(ctx context.Context, id SlotId, input CsmSlotEntity) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/slotsdiffs", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListSlotDifferencesSlotWithNextLink prepares the ListSlotDifferencesSlot request with the given nextLink token. -func (c WebAppsClient) preparerForListSlotDifferencesSlotWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListSlotDifferencesSlot handles the response to the ListSlotDifferencesSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListSlotDifferencesSlot(resp *http.Response) (result ListSlotDifferencesSlotOperationResponse, err error) { - type page struct { - Values []SlotDifference `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListSlotDifferencesSlotOperationResponse, err error) { - req, err := c.preparerForListSlotDifferencesSlotWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSlotDifferencesSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSlotDifferencesSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListSlotDifferencesSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSlotDifferencesSlot", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListSlotDifferencesSlotComplete retrieves all of the results into a single object -func (c WebAppsClient) ListSlotDifferencesSlotComplete(ctx context.Context, id SlotId, input CsmSlotEntity) (ListSlotDifferencesSlotCompleteResult, error) { - return c.ListSlotDifferencesSlotCompleteMatchingPredicate(ctx, id, input, SlotDifferenceOperationPredicate{}) -} - -// ListSlotDifferencesSlotCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListSlotDifferencesSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, input CsmSlotEntity, predicate SlotDifferenceOperationPredicate) (resp ListSlotDifferencesSlotCompleteResult, err error) { - items := make([]SlotDifference, 0) - - page, err := c.ListSlotDifferencesSlot(ctx, id, input) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListSlotDifferencesSlotCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listslots.go b/resource-manager/web/2022-09-01/webapps/method_listslots.go new file mode 100644 index 00000000000..d48d499d9e9 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listslots.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListSlotsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Site +} + +type ListSlotsCompleteResult struct { + Items []Site +} + +// ListSlots ... +func (c WebAppsClient) ListSlots(ctx context.Context, id SiteId) (result ListSlotsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/slots", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Site `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSlotsComplete retrieves all the results into a single object +func (c WebAppsClient) ListSlotsComplete(ctx context.Context, id SiteId) (ListSlotsCompleteResult, error) { + return c.ListSlotsCompleteMatchingPredicate(ctx, id, SiteOperationPredicate{}) +} + +// ListSlotsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListSlotsCompleteMatchingPredicate(ctx context.Context, id SiteId, predicate SiteOperationPredicate) (result ListSlotsCompleteResult, err error) { + items := make([]Site, 0) + + resp, err := c.ListSlots(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListSlotsCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listslots_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listslots_autorest.go deleted file mode 100644 index a5a768fb2fa..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listslots_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListSlotsOperationResponse struct { - HttpResponse *http.Response - Model *[]Site - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListSlotsOperationResponse, error) -} - -type ListSlotsCompleteResult struct { - Items []Site -} - -func (r ListSlotsOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListSlotsOperationResponse) LoadMore(ctx context.Context) (resp ListSlotsOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListSlots ... -func (c WebAppsClient) ListSlots(ctx context.Context, id SiteId) (resp ListSlotsOperationResponse, err error) { - req, err := c.preparerForListSlots(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSlots", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSlots", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListSlots(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSlots", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListSlots prepares the ListSlots request. -func (c WebAppsClient) preparerForListSlots(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/slots", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListSlotsWithNextLink prepares the ListSlots request with the given nextLink token. -func (c WebAppsClient) preparerForListSlotsWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListSlots handles the response to the ListSlots request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListSlots(resp *http.Response) (result ListSlotsOperationResponse, err error) { - type page struct { - Values []Site `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListSlotsOperationResponse, err error) { - req, err := c.preparerForListSlotsWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSlots", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSlots", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListSlots(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSlots", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListSlotsComplete retrieves all of the results into a single object -func (c WebAppsClient) ListSlotsComplete(ctx context.Context, id SiteId) (ListSlotsCompleteResult, error) { - return c.ListSlotsCompleteMatchingPredicate(ctx, id, SiteOperationPredicate{}) -} - -// ListSlotsCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListSlotsCompleteMatchingPredicate(ctx context.Context, id SiteId, predicate SiteOperationPredicate) (resp ListSlotsCompleteResult, err error) { - items := make([]Site, 0) - - page, err := c.ListSlots(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListSlotsCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listslotsitedeploymentstatusesslot.go b/resource-manager/web/2022-09-01/webapps/method_listslotsitedeploymentstatusesslot.go new file mode 100644 index 00000000000..c6a0228728e --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listslotsitedeploymentstatusesslot.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListSlotSiteDeploymentStatusesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CsmDeploymentStatus +} + +type ListSlotSiteDeploymentStatusesSlotCompleteResult struct { + Items []CsmDeploymentStatus +} + +// ListSlotSiteDeploymentStatusesSlot ... +func (c WebAppsClient) ListSlotSiteDeploymentStatusesSlot(ctx context.Context, id SlotId) (result ListSlotSiteDeploymentStatusesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/deploymentStatus", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]CsmDeploymentStatus `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSlotSiteDeploymentStatusesSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListSlotSiteDeploymentStatusesSlotComplete(ctx context.Context, id SlotId) (ListSlotSiteDeploymentStatusesSlotCompleteResult, error) { + return c.ListSlotSiteDeploymentStatusesSlotCompleteMatchingPredicate(ctx, id, CsmDeploymentStatusOperationPredicate{}) +} + +// ListSlotSiteDeploymentStatusesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListSlotSiteDeploymentStatusesSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate CsmDeploymentStatusOperationPredicate) (result ListSlotSiteDeploymentStatusesSlotCompleteResult, err error) { + items := make([]CsmDeploymentStatus, 0) + + resp, err := c.ListSlotSiteDeploymentStatusesSlot(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListSlotSiteDeploymentStatusesSlotCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listslotsitedeploymentstatusesslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listslotsitedeploymentstatusesslot_autorest.go deleted file mode 100644 index c402f2feac7..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listslotsitedeploymentstatusesslot_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListSlotSiteDeploymentStatusesSlotOperationResponse struct { - HttpResponse *http.Response - Model *[]CsmDeploymentStatus - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListSlotSiteDeploymentStatusesSlotOperationResponse, error) -} - -type ListSlotSiteDeploymentStatusesSlotCompleteResult struct { - Items []CsmDeploymentStatus -} - -func (r ListSlotSiteDeploymentStatusesSlotOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListSlotSiteDeploymentStatusesSlotOperationResponse) LoadMore(ctx context.Context) (resp ListSlotSiteDeploymentStatusesSlotOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListSlotSiteDeploymentStatusesSlot ... -func (c WebAppsClient) ListSlotSiteDeploymentStatusesSlot(ctx context.Context, id SlotId) (resp ListSlotSiteDeploymentStatusesSlotOperationResponse, err error) { - req, err := c.preparerForListSlotSiteDeploymentStatusesSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSlotSiteDeploymentStatusesSlot", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSlotSiteDeploymentStatusesSlot", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListSlotSiteDeploymentStatusesSlot(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSlotSiteDeploymentStatusesSlot", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListSlotSiteDeploymentStatusesSlot prepares the ListSlotSiteDeploymentStatusesSlot request. -func (c WebAppsClient) preparerForListSlotSiteDeploymentStatusesSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/deploymentStatus", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListSlotSiteDeploymentStatusesSlotWithNextLink prepares the ListSlotSiteDeploymentStatusesSlot request with the given nextLink token. -func (c WebAppsClient) preparerForListSlotSiteDeploymentStatusesSlotWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListSlotSiteDeploymentStatusesSlot handles the response to the ListSlotSiteDeploymentStatusesSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListSlotSiteDeploymentStatusesSlot(resp *http.Response) (result ListSlotSiteDeploymentStatusesSlotOperationResponse, err error) { - type page struct { - Values []CsmDeploymentStatus `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListSlotSiteDeploymentStatusesSlotOperationResponse, err error) { - req, err := c.preparerForListSlotSiteDeploymentStatusesSlotWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSlotSiteDeploymentStatusesSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSlotSiteDeploymentStatusesSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListSlotSiteDeploymentStatusesSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSlotSiteDeploymentStatusesSlot", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListSlotSiteDeploymentStatusesSlotComplete retrieves all of the results into a single object -func (c WebAppsClient) ListSlotSiteDeploymentStatusesSlotComplete(ctx context.Context, id SlotId) (ListSlotSiteDeploymentStatusesSlotCompleteResult, error) { - return c.ListSlotSiteDeploymentStatusesSlotCompleteMatchingPredicate(ctx, id, CsmDeploymentStatusOperationPredicate{}) -} - -// ListSlotSiteDeploymentStatusesSlotCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListSlotSiteDeploymentStatusesSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate CsmDeploymentStatusOperationPredicate) (resp ListSlotSiteDeploymentStatusesSlotCompleteResult, err error) { - items := make([]CsmDeploymentStatus, 0) - - page, err := c.ListSlotSiteDeploymentStatusesSlot(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListSlotSiteDeploymentStatusesSlotCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listsnapshots.go b/resource-manager/web/2022-09-01/webapps/method_listsnapshots.go new file mode 100644 index 00000000000..8e22914bf4e --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listsnapshots.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListSnapshotsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Snapshot +} + +type ListSnapshotsCompleteResult struct { + Items []Snapshot +} + +// ListSnapshots ... +func (c WebAppsClient) ListSnapshots(ctx context.Context, id SiteId) (result ListSnapshotsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/snapshots", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Snapshot `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSnapshotsComplete retrieves all the results into a single object +func (c WebAppsClient) ListSnapshotsComplete(ctx context.Context, id SiteId) (ListSnapshotsCompleteResult, error) { + return c.ListSnapshotsCompleteMatchingPredicate(ctx, id, SnapshotOperationPredicate{}) +} + +// ListSnapshotsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListSnapshotsCompleteMatchingPredicate(ctx context.Context, id SiteId, predicate SnapshotOperationPredicate) (result ListSnapshotsCompleteResult, err error) { + items := make([]Snapshot, 0) + + resp, err := c.ListSnapshots(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListSnapshotsCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listsnapshots_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listsnapshots_autorest.go deleted file mode 100644 index 34a7dd398dc..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listsnapshots_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListSnapshotsOperationResponse struct { - HttpResponse *http.Response - Model *[]Snapshot - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListSnapshotsOperationResponse, error) -} - -type ListSnapshotsCompleteResult struct { - Items []Snapshot -} - -func (r ListSnapshotsOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListSnapshotsOperationResponse) LoadMore(ctx context.Context) (resp ListSnapshotsOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListSnapshots ... -func (c WebAppsClient) ListSnapshots(ctx context.Context, id SiteId) (resp ListSnapshotsOperationResponse, err error) { - req, err := c.preparerForListSnapshots(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSnapshots", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSnapshots", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListSnapshots(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSnapshots", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListSnapshots prepares the ListSnapshots request. -func (c WebAppsClient) preparerForListSnapshots(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/snapshots", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListSnapshotsWithNextLink prepares the ListSnapshots request with the given nextLink token. -func (c WebAppsClient) preparerForListSnapshotsWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListSnapshots handles the response to the ListSnapshots request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListSnapshots(resp *http.Response) (result ListSnapshotsOperationResponse, err error) { - type page struct { - Values []Snapshot `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListSnapshotsOperationResponse, err error) { - req, err := c.preparerForListSnapshotsWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSnapshots", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSnapshots", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListSnapshots(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSnapshots", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListSnapshotsComplete retrieves all of the results into a single object -func (c WebAppsClient) ListSnapshotsComplete(ctx context.Context, id SiteId) (ListSnapshotsCompleteResult, error) { - return c.ListSnapshotsCompleteMatchingPredicate(ctx, id, SnapshotOperationPredicate{}) -} - -// ListSnapshotsCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListSnapshotsCompleteMatchingPredicate(ctx context.Context, id SiteId, predicate SnapshotOperationPredicate) (resp ListSnapshotsCompleteResult, err error) { - items := make([]Snapshot, 0) - - page, err := c.ListSnapshots(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListSnapshotsCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listsnapshotsfromdrsecondary.go b/resource-manager/web/2022-09-01/webapps/method_listsnapshotsfromdrsecondary.go new file mode 100644 index 00000000000..a7a13c32dcd --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listsnapshotsfromdrsecondary.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListSnapshotsFromDRSecondaryOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Snapshot +} + +type ListSnapshotsFromDRSecondaryCompleteResult struct { + Items []Snapshot +} + +// ListSnapshotsFromDRSecondary ... +func (c WebAppsClient) ListSnapshotsFromDRSecondary(ctx context.Context, id SiteId) (result ListSnapshotsFromDRSecondaryOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/snapshotsdr", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Snapshot `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSnapshotsFromDRSecondaryComplete retrieves all the results into a single object +func (c WebAppsClient) ListSnapshotsFromDRSecondaryComplete(ctx context.Context, id SiteId) (ListSnapshotsFromDRSecondaryCompleteResult, error) { + return c.ListSnapshotsFromDRSecondaryCompleteMatchingPredicate(ctx, id, SnapshotOperationPredicate{}) +} + +// ListSnapshotsFromDRSecondaryCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListSnapshotsFromDRSecondaryCompleteMatchingPredicate(ctx context.Context, id SiteId, predicate SnapshotOperationPredicate) (result ListSnapshotsFromDRSecondaryCompleteResult, err error) { + items := make([]Snapshot, 0) + + resp, err := c.ListSnapshotsFromDRSecondary(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListSnapshotsFromDRSecondaryCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listsnapshotsfromdrsecondary_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listsnapshotsfromdrsecondary_autorest.go deleted file mode 100644 index d346babc337..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listsnapshotsfromdrsecondary_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListSnapshotsFromDRSecondaryOperationResponse struct { - HttpResponse *http.Response - Model *[]Snapshot - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListSnapshotsFromDRSecondaryOperationResponse, error) -} - -type ListSnapshotsFromDRSecondaryCompleteResult struct { - Items []Snapshot -} - -func (r ListSnapshotsFromDRSecondaryOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListSnapshotsFromDRSecondaryOperationResponse) LoadMore(ctx context.Context) (resp ListSnapshotsFromDRSecondaryOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListSnapshotsFromDRSecondary ... -func (c WebAppsClient) ListSnapshotsFromDRSecondary(ctx context.Context, id SiteId) (resp ListSnapshotsFromDRSecondaryOperationResponse, err error) { - req, err := c.preparerForListSnapshotsFromDRSecondary(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSnapshotsFromDRSecondary", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSnapshotsFromDRSecondary", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListSnapshotsFromDRSecondary(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSnapshotsFromDRSecondary", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListSnapshotsFromDRSecondary prepares the ListSnapshotsFromDRSecondary request. -func (c WebAppsClient) preparerForListSnapshotsFromDRSecondary(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/snapshotsdr", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListSnapshotsFromDRSecondaryWithNextLink prepares the ListSnapshotsFromDRSecondary request with the given nextLink token. -func (c WebAppsClient) preparerForListSnapshotsFromDRSecondaryWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListSnapshotsFromDRSecondary handles the response to the ListSnapshotsFromDRSecondary request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListSnapshotsFromDRSecondary(resp *http.Response) (result ListSnapshotsFromDRSecondaryOperationResponse, err error) { - type page struct { - Values []Snapshot `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListSnapshotsFromDRSecondaryOperationResponse, err error) { - req, err := c.preparerForListSnapshotsFromDRSecondaryWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSnapshotsFromDRSecondary", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSnapshotsFromDRSecondary", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListSnapshotsFromDRSecondary(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSnapshotsFromDRSecondary", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListSnapshotsFromDRSecondaryComplete retrieves all of the results into a single object -func (c WebAppsClient) ListSnapshotsFromDRSecondaryComplete(ctx context.Context, id SiteId) (ListSnapshotsFromDRSecondaryCompleteResult, error) { - return c.ListSnapshotsFromDRSecondaryCompleteMatchingPredicate(ctx, id, SnapshotOperationPredicate{}) -} - -// ListSnapshotsFromDRSecondaryCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListSnapshotsFromDRSecondaryCompleteMatchingPredicate(ctx context.Context, id SiteId, predicate SnapshotOperationPredicate) (resp ListSnapshotsFromDRSecondaryCompleteResult, err error) { - items := make([]Snapshot, 0) - - page, err := c.ListSnapshotsFromDRSecondary(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListSnapshotsFromDRSecondaryCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listsnapshotsfromdrsecondaryslot.go b/resource-manager/web/2022-09-01/webapps/method_listsnapshotsfromdrsecondaryslot.go new file mode 100644 index 00000000000..36b94e67025 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listsnapshotsfromdrsecondaryslot.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListSnapshotsFromDRSecondarySlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Snapshot +} + +type ListSnapshotsFromDRSecondarySlotCompleteResult struct { + Items []Snapshot +} + +// ListSnapshotsFromDRSecondarySlot ... +func (c WebAppsClient) ListSnapshotsFromDRSecondarySlot(ctx context.Context, id SlotId) (result ListSnapshotsFromDRSecondarySlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/snapshotsdr", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Snapshot `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSnapshotsFromDRSecondarySlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListSnapshotsFromDRSecondarySlotComplete(ctx context.Context, id SlotId) (ListSnapshotsFromDRSecondarySlotCompleteResult, error) { + return c.ListSnapshotsFromDRSecondarySlotCompleteMatchingPredicate(ctx, id, SnapshotOperationPredicate{}) +} + +// ListSnapshotsFromDRSecondarySlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListSnapshotsFromDRSecondarySlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate SnapshotOperationPredicate) (result ListSnapshotsFromDRSecondarySlotCompleteResult, err error) { + items := make([]Snapshot, 0) + + resp, err := c.ListSnapshotsFromDRSecondarySlot(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListSnapshotsFromDRSecondarySlotCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listsnapshotsfromdrsecondaryslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listsnapshotsfromdrsecondaryslot_autorest.go deleted file mode 100644 index 0ddb46e9c8b..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listsnapshotsfromdrsecondaryslot_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListSnapshotsFromDRSecondarySlotOperationResponse struct { - HttpResponse *http.Response - Model *[]Snapshot - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListSnapshotsFromDRSecondarySlotOperationResponse, error) -} - -type ListSnapshotsFromDRSecondarySlotCompleteResult struct { - Items []Snapshot -} - -func (r ListSnapshotsFromDRSecondarySlotOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListSnapshotsFromDRSecondarySlotOperationResponse) LoadMore(ctx context.Context) (resp ListSnapshotsFromDRSecondarySlotOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListSnapshotsFromDRSecondarySlot ... -func (c WebAppsClient) ListSnapshotsFromDRSecondarySlot(ctx context.Context, id SlotId) (resp ListSnapshotsFromDRSecondarySlotOperationResponse, err error) { - req, err := c.preparerForListSnapshotsFromDRSecondarySlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSnapshotsFromDRSecondarySlot", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSnapshotsFromDRSecondarySlot", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListSnapshotsFromDRSecondarySlot(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSnapshotsFromDRSecondarySlot", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListSnapshotsFromDRSecondarySlot prepares the ListSnapshotsFromDRSecondarySlot request. -func (c WebAppsClient) preparerForListSnapshotsFromDRSecondarySlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/snapshotsdr", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListSnapshotsFromDRSecondarySlotWithNextLink prepares the ListSnapshotsFromDRSecondarySlot request with the given nextLink token. -func (c WebAppsClient) preparerForListSnapshotsFromDRSecondarySlotWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListSnapshotsFromDRSecondarySlot handles the response to the ListSnapshotsFromDRSecondarySlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListSnapshotsFromDRSecondarySlot(resp *http.Response) (result ListSnapshotsFromDRSecondarySlotOperationResponse, err error) { - type page struct { - Values []Snapshot `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListSnapshotsFromDRSecondarySlotOperationResponse, err error) { - req, err := c.preparerForListSnapshotsFromDRSecondarySlotWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSnapshotsFromDRSecondarySlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSnapshotsFromDRSecondarySlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListSnapshotsFromDRSecondarySlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSnapshotsFromDRSecondarySlot", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListSnapshotsFromDRSecondarySlotComplete retrieves all of the results into a single object -func (c WebAppsClient) ListSnapshotsFromDRSecondarySlotComplete(ctx context.Context, id SlotId) (ListSnapshotsFromDRSecondarySlotCompleteResult, error) { - return c.ListSnapshotsFromDRSecondarySlotCompleteMatchingPredicate(ctx, id, SnapshotOperationPredicate{}) -} - -// ListSnapshotsFromDRSecondarySlotCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListSnapshotsFromDRSecondarySlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate SnapshotOperationPredicate) (resp ListSnapshotsFromDRSecondarySlotCompleteResult, err error) { - items := make([]Snapshot, 0) - - page, err := c.ListSnapshotsFromDRSecondarySlot(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListSnapshotsFromDRSecondarySlotCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listsnapshotsslot.go b/resource-manager/web/2022-09-01/webapps/method_listsnapshotsslot.go new file mode 100644 index 00000000000..78913d600d8 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listsnapshotsslot.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListSnapshotsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Snapshot +} + +type ListSnapshotsSlotCompleteResult struct { + Items []Snapshot +} + +// ListSnapshotsSlot ... +func (c WebAppsClient) ListSnapshotsSlot(ctx context.Context, id SlotId) (result ListSnapshotsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/snapshots", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Snapshot `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSnapshotsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListSnapshotsSlotComplete(ctx context.Context, id SlotId) (ListSnapshotsSlotCompleteResult, error) { + return c.ListSnapshotsSlotCompleteMatchingPredicate(ctx, id, SnapshotOperationPredicate{}) +} + +// ListSnapshotsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListSnapshotsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate SnapshotOperationPredicate) (result ListSnapshotsSlotCompleteResult, err error) { + items := make([]Snapshot, 0) + + resp, err := c.ListSnapshotsSlot(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListSnapshotsSlotCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listsnapshotsslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listsnapshotsslot_autorest.go deleted file mode 100644 index 60c7f13bd6c..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listsnapshotsslot_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListSnapshotsSlotOperationResponse struct { - HttpResponse *http.Response - Model *[]Snapshot - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListSnapshotsSlotOperationResponse, error) -} - -type ListSnapshotsSlotCompleteResult struct { - Items []Snapshot -} - -func (r ListSnapshotsSlotOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListSnapshotsSlotOperationResponse) LoadMore(ctx context.Context) (resp ListSnapshotsSlotOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListSnapshotsSlot ... -func (c WebAppsClient) ListSnapshotsSlot(ctx context.Context, id SlotId) (resp ListSnapshotsSlotOperationResponse, err error) { - req, err := c.preparerForListSnapshotsSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSnapshotsSlot", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSnapshotsSlot", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListSnapshotsSlot(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSnapshotsSlot", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListSnapshotsSlot prepares the ListSnapshotsSlot request. -func (c WebAppsClient) preparerForListSnapshotsSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/snapshots", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListSnapshotsSlotWithNextLink prepares the ListSnapshotsSlot request with the given nextLink token. -func (c WebAppsClient) preparerForListSnapshotsSlotWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListSnapshotsSlot handles the response to the ListSnapshotsSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListSnapshotsSlot(resp *http.Response) (result ListSnapshotsSlotOperationResponse, err error) { - type page struct { - Values []Snapshot `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListSnapshotsSlotOperationResponse, err error) { - req, err := c.preparerForListSnapshotsSlotWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSnapshotsSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSnapshotsSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListSnapshotsSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSnapshotsSlot", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListSnapshotsSlotComplete retrieves all of the results into a single object -func (c WebAppsClient) ListSnapshotsSlotComplete(ctx context.Context, id SlotId) (ListSnapshotsSlotCompleteResult, error) { - return c.ListSnapshotsSlotCompleteMatchingPredicate(ctx, id, SnapshotOperationPredicate{}) -} - -// ListSnapshotsSlotCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListSnapshotsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate SnapshotOperationPredicate) (resp ListSnapshotsSlotCompleteResult, err error) { - items := make([]Snapshot, 0) - - page, err := c.ListSnapshotsSlot(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListSnapshotsSlotCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listsyncfunctiontriggers.go b/resource-manager/web/2022-09-01/webapps/method_listsyncfunctiontriggers.go new file mode 100644 index 00000000000..3af3148eb73 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listsyncfunctiontriggers.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListSyncFunctionTriggersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *FunctionSecrets +} + +// ListSyncFunctionTriggers ... +func (c WebAppsClient) ListSyncFunctionTriggers(ctx context.Context, id SiteId) (result ListSyncFunctionTriggersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listsyncfunctiontriggerstatus", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listsyncfunctiontriggers_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listsyncfunctiontriggers_autorest.go deleted file mode 100644 index 232f3c9e112..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listsyncfunctiontriggers_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListSyncFunctionTriggersOperationResponse struct { - HttpResponse *http.Response - Model *FunctionSecrets -} - -// ListSyncFunctionTriggers ... -func (c WebAppsClient) ListSyncFunctionTriggers(ctx context.Context, id SiteId) (result ListSyncFunctionTriggersOperationResponse, err error) { - req, err := c.preparerForListSyncFunctionTriggers(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSyncFunctionTriggers", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSyncFunctionTriggers", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListSyncFunctionTriggers(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSyncFunctionTriggers", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListSyncFunctionTriggers prepares the ListSyncFunctionTriggers request. -func (c WebAppsClient) preparerForListSyncFunctionTriggers(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/listsyncfunctiontriggerstatus", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListSyncFunctionTriggers handles the response to the ListSyncFunctionTriggers request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListSyncFunctionTriggers(resp *http.Response) (result ListSyncFunctionTriggersOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listsyncfunctiontriggersslot.go b/resource-manager/web/2022-09-01/webapps/method_listsyncfunctiontriggersslot.go new file mode 100644 index 00000000000..dbf4ad796e9 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listsyncfunctiontriggersslot.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListSyncFunctionTriggersSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *FunctionSecrets +} + +// ListSyncFunctionTriggersSlot ... +func (c WebAppsClient) ListSyncFunctionTriggersSlot(ctx context.Context, id SlotId) (result ListSyncFunctionTriggersSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listsyncfunctiontriggerstatus", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listsyncfunctiontriggersslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listsyncfunctiontriggersslot_autorest.go deleted file mode 100644 index 83145ca77c4..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listsyncfunctiontriggersslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListSyncFunctionTriggersSlotOperationResponse struct { - HttpResponse *http.Response - Model *FunctionSecrets -} - -// ListSyncFunctionTriggersSlot ... -func (c WebAppsClient) ListSyncFunctionTriggersSlot(ctx context.Context, id SlotId) (result ListSyncFunctionTriggersSlotOperationResponse, err error) { - req, err := c.preparerForListSyncFunctionTriggersSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSyncFunctionTriggersSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSyncFunctionTriggersSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListSyncFunctionTriggersSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSyncFunctionTriggersSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListSyncFunctionTriggersSlot prepares the ListSyncFunctionTriggersSlot request. -func (c WebAppsClient) preparerForListSyncFunctionTriggersSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/listsyncfunctiontriggerstatus", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListSyncFunctionTriggersSlot handles the response to the ListSyncFunctionTriggersSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListSyncFunctionTriggersSlot(resp *http.Response) (result ListSyncFunctionTriggersSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listsyncstatus.go b/resource-manager/web/2022-09-01/webapps/method_listsyncstatus.go new file mode 100644 index 00000000000..6f98da652a2 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listsyncstatus.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListSyncStatusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ListSyncStatus ... +func (c WebAppsClient) ListSyncStatus(ctx context.Context, id SiteId) (result ListSyncStatusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/host/default/listsyncstatus", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listsyncstatus_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listsyncstatus_autorest.go deleted file mode 100644 index 0c81052428c..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listsyncstatus_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListSyncStatusOperationResponse struct { - HttpResponse *http.Response -} - -// ListSyncStatus ... -func (c WebAppsClient) ListSyncStatus(ctx context.Context, id SiteId) (result ListSyncStatusOperationResponse, err error) { - req, err := c.preparerForListSyncStatus(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSyncStatus", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSyncStatus", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListSyncStatus(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSyncStatus", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListSyncStatus prepares the ListSyncStatus request. -func (c WebAppsClient) preparerForListSyncStatus(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/host/default/listsyncstatus", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListSyncStatus handles the response to the ListSyncStatus request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListSyncStatus(resp *http.Response) (result ListSyncStatusOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listsyncstatusslot.go b/resource-manager/web/2022-09-01/webapps/method_listsyncstatusslot.go new file mode 100644 index 00000000000..58c90f62bff --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listsyncstatusslot.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListSyncStatusSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ListSyncStatusSlot ... +func (c WebAppsClient) ListSyncStatusSlot(ctx context.Context, id SlotId) (result ListSyncStatusSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/host/default/listsyncstatus", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listsyncstatusslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listsyncstatusslot_autorest.go deleted file mode 100644 index 1dbdc26dccd..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listsyncstatusslot_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListSyncStatusSlotOperationResponse struct { - HttpResponse *http.Response -} - -// ListSyncStatusSlot ... -func (c WebAppsClient) ListSyncStatusSlot(ctx context.Context, id SlotId) (result ListSyncStatusSlotOperationResponse, err error) { - req, err := c.preparerForListSyncStatusSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSyncStatusSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSyncStatusSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListSyncStatusSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListSyncStatusSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListSyncStatusSlot prepares the ListSyncStatusSlot request. -func (c WebAppsClient) preparerForListSyncStatusSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/host/default/listsyncstatus", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListSyncStatusSlot handles the response to the ListSyncStatusSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListSyncStatusSlot(resp *http.Response) (result ListSyncStatusSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listtriggeredwebjobhistory.go b/resource-manager/web/2022-09-01/webapps/method_listtriggeredwebjobhistory.go new file mode 100644 index 00000000000..ece1fde37e4 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listtriggeredwebjobhistory.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListTriggeredWebJobHistoryOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]TriggeredJobHistory +} + +type ListTriggeredWebJobHistoryCompleteResult struct { + Items []TriggeredJobHistory +} + +// ListTriggeredWebJobHistory ... +func (c WebAppsClient) ListTriggeredWebJobHistory(ctx context.Context, id TriggeredWebJobId) (result ListTriggeredWebJobHistoryOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/history", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]TriggeredJobHistory `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListTriggeredWebJobHistoryComplete retrieves all the results into a single object +func (c WebAppsClient) ListTriggeredWebJobHistoryComplete(ctx context.Context, id TriggeredWebJobId) (ListTriggeredWebJobHistoryCompleteResult, error) { + return c.ListTriggeredWebJobHistoryCompleteMatchingPredicate(ctx, id, TriggeredJobHistoryOperationPredicate{}) +} + +// ListTriggeredWebJobHistoryCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListTriggeredWebJobHistoryCompleteMatchingPredicate(ctx context.Context, id TriggeredWebJobId, predicate TriggeredJobHistoryOperationPredicate) (result ListTriggeredWebJobHistoryCompleteResult, err error) { + items := make([]TriggeredJobHistory, 0) + + resp, err := c.ListTriggeredWebJobHistory(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListTriggeredWebJobHistoryCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listtriggeredwebjobhistory_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listtriggeredwebjobhistory_autorest.go deleted file mode 100644 index fde6e39da18..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listtriggeredwebjobhistory_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListTriggeredWebJobHistoryOperationResponse struct { - HttpResponse *http.Response - Model *[]TriggeredJobHistory - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListTriggeredWebJobHistoryOperationResponse, error) -} - -type ListTriggeredWebJobHistoryCompleteResult struct { - Items []TriggeredJobHistory -} - -func (r ListTriggeredWebJobHistoryOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListTriggeredWebJobHistoryOperationResponse) LoadMore(ctx context.Context) (resp ListTriggeredWebJobHistoryOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListTriggeredWebJobHistory ... -func (c WebAppsClient) ListTriggeredWebJobHistory(ctx context.Context, id TriggeredWebJobId) (resp ListTriggeredWebJobHistoryOperationResponse, err error) { - req, err := c.preparerForListTriggeredWebJobHistory(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListTriggeredWebJobHistory", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListTriggeredWebJobHistory", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListTriggeredWebJobHistory(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListTriggeredWebJobHistory", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListTriggeredWebJobHistory prepares the ListTriggeredWebJobHistory request. -func (c WebAppsClient) preparerForListTriggeredWebJobHistory(ctx context.Context, id TriggeredWebJobId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/history", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListTriggeredWebJobHistoryWithNextLink prepares the ListTriggeredWebJobHistory request with the given nextLink token. -func (c WebAppsClient) preparerForListTriggeredWebJobHistoryWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListTriggeredWebJobHistory handles the response to the ListTriggeredWebJobHistory request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListTriggeredWebJobHistory(resp *http.Response) (result ListTriggeredWebJobHistoryOperationResponse, err error) { - type page struct { - Values []TriggeredJobHistory `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListTriggeredWebJobHistoryOperationResponse, err error) { - req, err := c.preparerForListTriggeredWebJobHistoryWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListTriggeredWebJobHistory", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListTriggeredWebJobHistory", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListTriggeredWebJobHistory(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListTriggeredWebJobHistory", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListTriggeredWebJobHistoryComplete retrieves all of the results into a single object -func (c WebAppsClient) ListTriggeredWebJobHistoryComplete(ctx context.Context, id TriggeredWebJobId) (ListTriggeredWebJobHistoryCompleteResult, error) { - return c.ListTriggeredWebJobHistoryCompleteMatchingPredicate(ctx, id, TriggeredJobHistoryOperationPredicate{}) -} - -// ListTriggeredWebJobHistoryCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListTriggeredWebJobHistoryCompleteMatchingPredicate(ctx context.Context, id TriggeredWebJobId, predicate TriggeredJobHistoryOperationPredicate) (resp ListTriggeredWebJobHistoryCompleteResult, err error) { - items := make([]TriggeredJobHistory, 0) - - page, err := c.ListTriggeredWebJobHistory(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListTriggeredWebJobHistoryCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listtriggeredwebjobhistoryslot.go b/resource-manager/web/2022-09-01/webapps/method_listtriggeredwebjobhistoryslot.go new file mode 100644 index 00000000000..18ca47a2da1 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listtriggeredwebjobhistoryslot.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListTriggeredWebJobHistorySlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]TriggeredJobHistory +} + +type ListTriggeredWebJobHistorySlotCompleteResult struct { + Items []TriggeredJobHistory +} + +// ListTriggeredWebJobHistorySlot ... +func (c WebAppsClient) ListTriggeredWebJobHistorySlot(ctx context.Context, id SlotTriggeredWebJobId) (result ListTriggeredWebJobHistorySlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/history", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]TriggeredJobHistory `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListTriggeredWebJobHistorySlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListTriggeredWebJobHistorySlotComplete(ctx context.Context, id SlotTriggeredWebJobId) (ListTriggeredWebJobHistorySlotCompleteResult, error) { + return c.ListTriggeredWebJobHistorySlotCompleteMatchingPredicate(ctx, id, TriggeredJobHistoryOperationPredicate{}) +} + +// ListTriggeredWebJobHistorySlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListTriggeredWebJobHistorySlotCompleteMatchingPredicate(ctx context.Context, id SlotTriggeredWebJobId, predicate TriggeredJobHistoryOperationPredicate) (result ListTriggeredWebJobHistorySlotCompleteResult, err error) { + items := make([]TriggeredJobHistory, 0) + + resp, err := c.ListTriggeredWebJobHistorySlot(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListTriggeredWebJobHistorySlotCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listtriggeredwebjobhistoryslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listtriggeredwebjobhistoryslot_autorest.go deleted file mode 100644 index 9334d4cb03b..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listtriggeredwebjobhistoryslot_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListTriggeredWebJobHistorySlotOperationResponse struct { - HttpResponse *http.Response - Model *[]TriggeredJobHistory - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListTriggeredWebJobHistorySlotOperationResponse, error) -} - -type ListTriggeredWebJobHistorySlotCompleteResult struct { - Items []TriggeredJobHistory -} - -func (r ListTriggeredWebJobHistorySlotOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListTriggeredWebJobHistorySlotOperationResponse) LoadMore(ctx context.Context) (resp ListTriggeredWebJobHistorySlotOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListTriggeredWebJobHistorySlot ... -func (c WebAppsClient) ListTriggeredWebJobHistorySlot(ctx context.Context, id SlotTriggeredWebJobId) (resp ListTriggeredWebJobHistorySlotOperationResponse, err error) { - req, err := c.preparerForListTriggeredWebJobHistorySlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListTriggeredWebJobHistorySlot", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListTriggeredWebJobHistorySlot", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListTriggeredWebJobHistorySlot(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListTriggeredWebJobHistorySlot", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListTriggeredWebJobHistorySlot prepares the ListTriggeredWebJobHistorySlot request. -func (c WebAppsClient) preparerForListTriggeredWebJobHistorySlot(ctx context.Context, id SlotTriggeredWebJobId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/history", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListTriggeredWebJobHistorySlotWithNextLink prepares the ListTriggeredWebJobHistorySlot request with the given nextLink token. -func (c WebAppsClient) preparerForListTriggeredWebJobHistorySlotWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListTriggeredWebJobHistorySlot handles the response to the ListTriggeredWebJobHistorySlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListTriggeredWebJobHistorySlot(resp *http.Response) (result ListTriggeredWebJobHistorySlotOperationResponse, err error) { - type page struct { - Values []TriggeredJobHistory `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListTriggeredWebJobHistorySlotOperationResponse, err error) { - req, err := c.preparerForListTriggeredWebJobHistorySlotWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListTriggeredWebJobHistorySlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListTriggeredWebJobHistorySlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListTriggeredWebJobHistorySlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListTriggeredWebJobHistorySlot", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListTriggeredWebJobHistorySlotComplete retrieves all of the results into a single object -func (c WebAppsClient) ListTriggeredWebJobHistorySlotComplete(ctx context.Context, id SlotTriggeredWebJobId) (ListTriggeredWebJobHistorySlotCompleteResult, error) { - return c.ListTriggeredWebJobHistorySlotCompleteMatchingPredicate(ctx, id, TriggeredJobHistoryOperationPredicate{}) -} - -// ListTriggeredWebJobHistorySlotCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListTriggeredWebJobHistorySlotCompleteMatchingPredicate(ctx context.Context, id SlotTriggeredWebJobId, predicate TriggeredJobHistoryOperationPredicate) (resp ListTriggeredWebJobHistorySlotCompleteResult, err error) { - items := make([]TriggeredJobHistory, 0) - - page, err := c.ListTriggeredWebJobHistorySlot(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListTriggeredWebJobHistorySlotCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listtriggeredwebjobs.go b/resource-manager/web/2022-09-01/webapps/method_listtriggeredwebjobs.go new file mode 100644 index 00000000000..28b29a70519 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listtriggeredwebjobs.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListTriggeredWebJobsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]TriggeredWebJob +} + +type ListTriggeredWebJobsCompleteResult struct { + Items []TriggeredWebJob +} + +// ListTriggeredWebJobs ... +func (c WebAppsClient) ListTriggeredWebJobs(ctx context.Context, id SiteId) (result ListTriggeredWebJobsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/triggeredWebJobs", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]TriggeredWebJob `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListTriggeredWebJobsComplete retrieves all the results into a single object +func (c WebAppsClient) ListTriggeredWebJobsComplete(ctx context.Context, id SiteId) (ListTriggeredWebJobsCompleteResult, error) { + return c.ListTriggeredWebJobsCompleteMatchingPredicate(ctx, id, TriggeredWebJobOperationPredicate{}) +} + +// ListTriggeredWebJobsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListTriggeredWebJobsCompleteMatchingPredicate(ctx context.Context, id SiteId, predicate TriggeredWebJobOperationPredicate) (result ListTriggeredWebJobsCompleteResult, err error) { + items := make([]TriggeredWebJob, 0) + + resp, err := c.ListTriggeredWebJobs(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListTriggeredWebJobsCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listtriggeredwebjobs_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listtriggeredwebjobs_autorest.go deleted file mode 100644 index 5dc07f01870..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listtriggeredwebjobs_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListTriggeredWebJobsOperationResponse struct { - HttpResponse *http.Response - Model *[]TriggeredWebJob - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListTriggeredWebJobsOperationResponse, error) -} - -type ListTriggeredWebJobsCompleteResult struct { - Items []TriggeredWebJob -} - -func (r ListTriggeredWebJobsOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListTriggeredWebJobsOperationResponse) LoadMore(ctx context.Context) (resp ListTriggeredWebJobsOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListTriggeredWebJobs ... -func (c WebAppsClient) ListTriggeredWebJobs(ctx context.Context, id SiteId) (resp ListTriggeredWebJobsOperationResponse, err error) { - req, err := c.preparerForListTriggeredWebJobs(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListTriggeredWebJobs", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListTriggeredWebJobs", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListTriggeredWebJobs(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListTriggeredWebJobs", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListTriggeredWebJobs prepares the ListTriggeredWebJobs request. -func (c WebAppsClient) preparerForListTriggeredWebJobs(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/triggeredWebJobs", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListTriggeredWebJobsWithNextLink prepares the ListTriggeredWebJobs request with the given nextLink token. -func (c WebAppsClient) preparerForListTriggeredWebJobsWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListTriggeredWebJobs handles the response to the ListTriggeredWebJobs request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListTriggeredWebJobs(resp *http.Response) (result ListTriggeredWebJobsOperationResponse, err error) { - type page struct { - Values []TriggeredWebJob `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListTriggeredWebJobsOperationResponse, err error) { - req, err := c.preparerForListTriggeredWebJobsWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListTriggeredWebJobs", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListTriggeredWebJobs", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListTriggeredWebJobs(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListTriggeredWebJobs", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListTriggeredWebJobsComplete retrieves all of the results into a single object -func (c WebAppsClient) ListTriggeredWebJobsComplete(ctx context.Context, id SiteId) (ListTriggeredWebJobsCompleteResult, error) { - return c.ListTriggeredWebJobsCompleteMatchingPredicate(ctx, id, TriggeredWebJobOperationPredicate{}) -} - -// ListTriggeredWebJobsCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListTriggeredWebJobsCompleteMatchingPredicate(ctx context.Context, id SiteId, predicate TriggeredWebJobOperationPredicate) (resp ListTriggeredWebJobsCompleteResult, err error) { - items := make([]TriggeredWebJob, 0) - - page, err := c.ListTriggeredWebJobs(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListTriggeredWebJobsCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listtriggeredwebjobsslot.go b/resource-manager/web/2022-09-01/webapps/method_listtriggeredwebjobsslot.go new file mode 100644 index 00000000000..f9f8bc266f8 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listtriggeredwebjobsslot.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListTriggeredWebJobsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]TriggeredWebJob +} + +type ListTriggeredWebJobsSlotCompleteResult struct { + Items []TriggeredWebJob +} + +// ListTriggeredWebJobsSlot ... +func (c WebAppsClient) ListTriggeredWebJobsSlot(ctx context.Context, id SlotId) (result ListTriggeredWebJobsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/triggeredWebJobs", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]TriggeredWebJob `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListTriggeredWebJobsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListTriggeredWebJobsSlotComplete(ctx context.Context, id SlotId) (ListTriggeredWebJobsSlotCompleteResult, error) { + return c.ListTriggeredWebJobsSlotCompleteMatchingPredicate(ctx, id, TriggeredWebJobOperationPredicate{}) +} + +// ListTriggeredWebJobsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListTriggeredWebJobsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate TriggeredWebJobOperationPredicate) (result ListTriggeredWebJobsSlotCompleteResult, err error) { + items := make([]TriggeredWebJob, 0) + + resp, err := c.ListTriggeredWebJobsSlot(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListTriggeredWebJobsSlotCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listtriggeredwebjobsslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listtriggeredwebjobsslot_autorest.go deleted file mode 100644 index 030a041f92e..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listtriggeredwebjobsslot_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListTriggeredWebJobsSlotOperationResponse struct { - HttpResponse *http.Response - Model *[]TriggeredWebJob - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListTriggeredWebJobsSlotOperationResponse, error) -} - -type ListTriggeredWebJobsSlotCompleteResult struct { - Items []TriggeredWebJob -} - -func (r ListTriggeredWebJobsSlotOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListTriggeredWebJobsSlotOperationResponse) LoadMore(ctx context.Context) (resp ListTriggeredWebJobsSlotOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListTriggeredWebJobsSlot ... -func (c WebAppsClient) ListTriggeredWebJobsSlot(ctx context.Context, id SlotId) (resp ListTriggeredWebJobsSlotOperationResponse, err error) { - req, err := c.preparerForListTriggeredWebJobsSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListTriggeredWebJobsSlot", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListTriggeredWebJobsSlot", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListTriggeredWebJobsSlot(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListTriggeredWebJobsSlot", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListTriggeredWebJobsSlot prepares the ListTriggeredWebJobsSlot request. -func (c WebAppsClient) preparerForListTriggeredWebJobsSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/triggeredWebJobs", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListTriggeredWebJobsSlotWithNextLink prepares the ListTriggeredWebJobsSlot request with the given nextLink token. -func (c WebAppsClient) preparerForListTriggeredWebJobsSlotWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListTriggeredWebJobsSlot handles the response to the ListTriggeredWebJobsSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListTriggeredWebJobsSlot(resp *http.Response) (result ListTriggeredWebJobsSlotOperationResponse, err error) { - type page struct { - Values []TriggeredWebJob `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListTriggeredWebJobsSlotOperationResponse, err error) { - req, err := c.preparerForListTriggeredWebJobsSlotWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListTriggeredWebJobsSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListTriggeredWebJobsSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListTriggeredWebJobsSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListTriggeredWebJobsSlot", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListTriggeredWebJobsSlotComplete retrieves all of the results into a single object -func (c WebAppsClient) ListTriggeredWebJobsSlotComplete(ctx context.Context, id SlotId) (ListTriggeredWebJobsSlotCompleteResult, error) { - return c.ListTriggeredWebJobsSlotCompleteMatchingPredicate(ctx, id, TriggeredWebJobOperationPredicate{}) -} - -// ListTriggeredWebJobsSlotCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListTriggeredWebJobsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate TriggeredWebJobOperationPredicate) (resp ListTriggeredWebJobsSlotCompleteResult, err error) { - items := make([]TriggeredWebJob, 0) - - page, err := c.ListTriggeredWebJobsSlot(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListTriggeredWebJobsSlotCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listusages.go b/resource-manager/web/2022-09-01/webapps/method_listusages.go new file mode 100644 index 00000000000..a572fadbd05 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listusages.go @@ -0,0 +1,117 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListUsagesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CsmUsageQuota +} + +type ListUsagesCompleteResult struct { + Items []CsmUsageQuota +} + +type ListUsagesOperationOptions struct { + Filter *string +} + +func DefaultListUsagesOperationOptions() ListUsagesOperationOptions { + return ListUsagesOperationOptions{} +} + +func (o ListUsagesOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListUsagesOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListUsagesOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +// ListUsages ... +func (c WebAppsClient) ListUsages(ctx context.Context, id SiteId, options ListUsagesOperationOptions) (result ListUsagesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/usages", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]CsmUsageQuota `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListUsagesComplete retrieves all the results into a single object +func (c WebAppsClient) ListUsagesComplete(ctx context.Context, id SiteId, options ListUsagesOperationOptions) (ListUsagesCompleteResult, error) { + return c.ListUsagesCompleteMatchingPredicate(ctx, id, options, CsmUsageQuotaOperationPredicate{}) +} + +// ListUsagesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListUsagesCompleteMatchingPredicate(ctx context.Context, id SiteId, options ListUsagesOperationOptions, predicate CsmUsageQuotaOperationPredicate) (result ListUsagesCompleteResult, err error) { + items := make([]CsmUsageQuota, 0) + + resp, err := c.ListUsages(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListUsagesCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listusages_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listusages_autorest.go deleted file mode 100644 index 0ebf4921206..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listusages_autorest.go +++ /dev/null @@ -1,215 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListUsagesOperationResponse struct { - HttpResponse *http.Response - Model *[]CsmUsageQuota - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListUsagesOperationResponse, error) -} - -type ListUsagesCompleteResult struct { - Items []CsmUsageQuota -} - -func (r ListUsagesOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListUsagesOperationResponse) LoadMore(ctx context.Context) (resp ListUsagesOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListUsagesOperationOptions struct { - Filter *string -} - -func DefaultListUsagesOperationOptions() ListUsagesOperationOptions { - return ListUsagesOperationOptions{} -} - -func (o ListUsagesOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListUsagesOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - return out -} - -// ListUsages ... -func (c WebAppsClient) ListUsages(ctx context.Context, id SiteId, options ListUsagesOperationOptions) (resp ListUsagesOperationResponse, err error) { - req, err := c.preparerForListUsages(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListUsages", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListUsages", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListUsages(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListUsages", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListUsages prepares the ListUsages request. -func (c WebAppsClient) preparerForListUsages(ctx context.Context, id SiteId, options ListUsagesOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/usages", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListUsagesWithNextLink prepares the ListUsages request with the given nextLink token. -func (c WebAppsClient) preparerForListUsagesWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListUsages handles the response to the ListUsages request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListUsages(resp *http.Response) (result ListUsagesOperationResponse, err error) { - type page struct { - Values []CsmUsageQuota `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListUsagesOperationResponse, err error) { - req, err := c.preparerForListUsagesWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListUsages", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListUsages", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListUsages(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListUsages", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListUsagesComplete retrieves all of the results into a single object -func (c WebAppsClient) ListUsagesComplete(ctx context.Context, id SiteId, options ListUsagesOperationOptions) (ListUsagesCompleteResult, error) { - return c.ListUsagesCompleteMatchingPredicate(ctx, id, options, CsmUsageQuotaOperationPredicate{}) -} - -// ListUsagesCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListUsagesCompleteMatchingPredicate(ctx context.Context, id SiteId, options ListUsagesOperationOptions, predicate CsmUsageQuotaOperationPredicate) (resp ListUsagesCompleteResult, err error) { - items := make([]CsmUsageQuota, 0) - - page, err := c.ListUsages(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListUsagesCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listusagesslot.go b/resource-manager/web/2022-09-01/webapps/method_listusagesslot.go new file mode 100644 index 00000000000..5229703bdf1 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listusagesslot.go @@ -0,0 +1,117 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListUsagesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CsmUsageQuota +} + +type ListUsagesSlotCompleteResult struct { + Items []CsmUsageQuota +} + +type ListUsagesSlotOperationOptions struct { + Filter *string +} + +func DefaultListUsagesSlotOperationOptions() ListUsagesSlotOperationOptions { + return ListUsagesSlotOperationOptions{} +} + +func (o ListUsagesSlotOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListUsagesSlotOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListUsagesSlotOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +// ListUsagesSlot ... +func (c WebAppsClient) ListUsagesSlot(ctx context.Context, id SlotId, options ListUsagesSlotOperationOptions) (result ListUsagesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/usages", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]CsmUsageQuota `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListUsagesSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListUsagesSlotComplete(ctx context.Context, id SlotId, options ListUsagesSlotOperationOptions) (ListUsagesSlotCompleteResult, error) { + return c.ListUsagesSlotCompleteMatchingPredicate(ctx, id, options, CsmUsageQuotaOperationPredicate{}) +} + +// ListUsagesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListUsagesSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, options ListUsagesSlotOperationOptions, predicate CsmUsageQuotaOperationPredicate) (result ListUsagesSlotCompleteResult, err error) { + items := make([]CsmUsageQuota, 0) + + resp, err := c.ListUsagesSlot(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListUsagesSlotCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listusagesslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listusagesslot_autorest.go deleted file mode 100644 index 3577f55df53..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listusagesslot_autorest.go +++ /dev/null @@ -1,215 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListUsagesSlotOperationResponse struct { - HttpResponse *http.Response - Model *[]CsmUsageQuota - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListUsagesSlotOperationResponse, error) -} - -type ListUsagesSlotCompleteResult struct { - Items []CsmUsageQuota -} - -func (r ListUsagesSlotOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListUsagesSlotOperationResponse) LoadMore(ctx context.Context) (resp ListUsagesSlotOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListUsagesSlotOperationOptions struct { - Filter *string -} - -func DefaultListUsagesSlotOperationOptions() ListUsagesSlotOperationOptions { - return ListUsagesSlotOperationOptions{} -} - -func (o ListUsagesSlotOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListUsagesSlotOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - return out -} - -// ListUsagesSlot ... -func (c WebAppsClient) ListUsagesSlot(ctx context.Context, id SlotId, options ListUsagesSlotOperationOptions) (resp ListUsagesSlotOperationResponse, err error) { - req, err := c.preparerForListUsagesSlot(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListUsagesSlot", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListUsagesSlot", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListUsagesSlot(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListUsagesSlot", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListUsagesSlot prepares the ListUsagesSlot request. -func (c WebAppsClient) preparerForListUsagesSlot(ctx context.Context, id SlotId, options ListUsagesSlotOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/usages", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListUsagesSlotWithNextLink prepares the ListUsagesSlot request with the given nextLink token. -func (c WebAppsClient) preparerForListUsagesSlotWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListUsagesSlot handles the response to the ListUsagesSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListUsagesSlot(resp *http.Response) (result ListUsagesSlotOperationResponse, err error) { - type page struct { - Values []CsmUsageQuota `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListUsagesSlotOperationResponse, err error) { - req, err := c.preparerForListUsagesSlotWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListUsagesSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListUsagesSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListUsagesSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListUsagesSlot", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListUsagesSlotComplete retrieves all of the results into a single object -func (c WebAppsClient) ListUsagesSlotComplete(ctx context.Context, id SlotId, options ListUsagesSlotOperationOptions) (ListUsagesSlotCompleteResult, error) { - return c.ListUsagesSlotCompleteMatchingPredicate(ctx, id, options, CsmUsageQuotaOperationPredicate{}) -} - -// ListUsagesSlotCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListUsagesSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, options ListUsagesSlotOperationOptions, predicate CsmUsageQuotaOperationPredicate) (resp ListUsagesSlotCompleteResult, err error) { - items := make([]CsmUsageQuota, 0) - - page, err := c.ListUsagesSlot(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListUsagesSlotCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listvnetconnections.go b/resource-manager/web/2022-09-01/webapps/method_listvnetconnections.go new file mode 100644 index 00000000000..6775c846d26 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listvnetconnections.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListVnetConnectionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VnetInfoResource +} + +// ListVnetConnections ... +func (c WebAppsClient) ListVnetConnections(ctx context.Context, id SiteId) (result ListVnetConnectionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/virtualNetworkConnections", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listvnetconnections_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listvnetconnections_autorest.go deleted file mode 100644 index fdc0bea5ce4..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listvnetconnections_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListVnetConnectionsOperationResponse struct { - HttpResponse *http.Response - Model *[]VnetInfoResource -} - -// ListVnetConnections ... -func (c WebAppsClient) ListVnetConnections(ctx context.Context, id SiteId) (result ListVnetConnectionsOperationResponse, err error) { - req, err := c.preparerForListVnetConnections(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListVnetConnections", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListVnetConnections", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListVnetConnections(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListVnetConnections", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListVnetConnections prepares the ListVnetConnections request. -func (c WebAppsClient) preparerForListVnetConnections(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/virtualNetworkConnections", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListVnetConnections handles the response to the ListVnetConnections request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListVnetConnections(resp *http.Response) (result ListVnetConnectionsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listvnetconnectionsslot.go b/resource-manager/web/2022-09-01/webapps/method_listvnetconnectionsslot.go new file mode 100644 index 00000000000..d202288a385 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listvnetconnectionsslot.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListVnetConnectionsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VnetInfoResource +} + +// ListVnetConnectionsSlot ... +func (c WebAppsClient) ListVnetConnectionsSlot(ctx context.Context, id SlotId) (result ListVnetConnectionsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/virtualNetworkConnections", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listvnetconnectionsslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listvnetconnectionsslot_autorest.go deleted file mode 100644 index f0026317a80..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listvnetconnectionsslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListVnetConnectionsSlotOperationResponse struct { - HttpResponse *http.Response - Model *[]VnetInfoResource -} - -// ListVnetConnectionsSlot ... -func (c WebAppsClient) ListVnetConnectionsSlot(ctx context.Context, id SlotId) (result ListVnetConnectionsSlotOperationResponse, err error) { - req, err := c.preparerForListVnetConnectionsSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListVnetConnectionsSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListVnetConnectionsSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListVnetConnectionsSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListVnetConnectionsSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListVnetConnectionsSlot prepares the ListVnetConnectionsSlot request. -func (c WebAppsClient) preparerForListVnetConnectionsSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/virtualNetworkConnections", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListVnetConnectionsSlot handles the response to the ListVnetConnectionsSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListVnetConnectionsSlot(resp *http.Response) (result ListVnetConnectionsSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listwebjobs.go b/resource-manager/web/2022-09-01/webapps/method_listwebjobs.go new file mode 100644 index 00000000000..75b789439cd --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listwebjobs.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListWebJobsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WebJob +} + +type ListWebJobsCompleteResult struct { + Items []WebJob +} + +// ListWebJobs ... +func (c WebAppsClient) ListWebJobs(ctx context.Context, id SiteId) (result ListWebJobsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/webJobs", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]WebJob `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListWebJobsComplete retrieves all the results into a single object +func (c WebAppsClient) ListWebJobsComplete(ctx context.Context, id SiteId) (ListWebJobsCompleteResult, error) { + return c.ListWebJobsCompleteMatchingPredicate(ctx, id, WebJobOperationPredicate{}) +} + +// ListWebJobsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListWebJobsCompleteMatchingPredicate(ctx context.Context, id SiteId, predicate WebJobOperationPredicate) (result ListWebJobsCompleteResult, err error) { + items := make([]WebJob, 0) + + resp, err := c.ListWebJobs(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListWebJobsCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listwebjobs_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listwebjobs_autorest.go deleted file mode 100644 index 952cf68041e..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listwebjobs_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListWebJobsOperationResponse struct { - HttpResponse *http.Response - Model *[]WebJob - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListWebJobsOperationResponse, error) -} - -type ListWebJobsCompleteResult struct { - Items []WebJob -} - -func (r ListWebJobsOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListWebJobsOperationResponse) LoadMore(ctx context.Context) (resp ListWebJobsOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListWebJobs ... -func (c WebAppsClient) ListWebJobs(ctx context.Context, id SiteId) (resp ListWebJobsOperationResponse, err error) { - req, err := c.preparerForListWebJobs(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListWebJobs", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListWebJobs", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListWebJobs(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListWebJobs", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListWebJobs prepares the ListWebJobs request. -func (c WebAppsClient) preparerForListWebJobs(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/webJobs", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWebJobsWithNextLink prepares the ListWebJobs request with the given nextLink token. -func (c WebAppsClient) preparerForListWebJobsWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListWebJobs handles the response to the ListWebJobs request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListWebJobs(resp *http.Response) (result ListWebJobsOperationResponse, err error) { - type page struct { - Values []WebJob `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListWebJobsOperationResponse, err error) { - req, err := c.preparerForListWebJobsWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListWebJobs", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListWebJobs", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListWebJobs(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListWebJobs", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListWebJobsComplete retrieves all of the results into a single object -func (c WebAppsClient) ListWebJobsComplete(ctx context.Context, id SiteId) (ListWebJobsCompleteResult, error) { - return c.ListWebJobsCompleteMatchingPredicate(ctx, id, WebJobOperationPredicate{}) -} - -// ListWebJobsCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListWebJobsCompleteMatchingPredicate(ctx context.Context, id SiteId, predicate WebJobOperationPredicate) (resp ListWebJobsCompleteResult, err error) { - items := make([]WebJob, 0) - - page, err := c.ListWebJobs(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListWebJobsCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listwebjobsslot.go b/resource-manager/web/2022-09-01/webapps/method_listwebjobsslot.go new file mode 100644 index 00000000000..df3d1d49f56 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listwebjobsslot.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListWebJobsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WebJob +} + +type ListWebJobsSlotCompleteResult struct { + Items []WebJob +} + +// ListWebJobsSlot ... +func (c WebAppsClient) ListWebJobsSlot(ctx context.Context, id SlotId) (result ListWebJobsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/webJobs", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]WebJob `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListWebJobsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListWebJobsSlotComplete(ctx context.Context, id SlotId) (ListWebJobsSlotCompleteResult, error) { + return c.ListWebJobsSlotCompleteMatchingPredicate(ctx, id, WebJobOperationPredicate{}) +} + +// ListWebJobsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListWebJobsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate WebJobOperationPredicate) (result ListWebJobsSlotCompleteResult, err error) { + items := make([]WebJob, 0) + + resp, err := c.ListWebJobsSlot(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListWebJobsSlotCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listwebjobsslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listwebjobsslot_autorest.go deleted file mode 100644 index b51eeba6967..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listwebjobsslot_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListWebJobsSlotOperationResponse struct { - HttpResponse *http.Response - Model *[]WebJob - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListWebJobsSlotOperationResponse, error) -} - -type ListWebJobsSlotCompleteResult struct { - Items []WebJob -} - -func (r ListWebJobsSlotOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListWebJobsSlotOperationResponse) LoadMore(ctx context.Context) (resp ListWebJobsSlotOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListWebJobsSlot ... -func (c WebAppsClient) ListWebJobsSlot(ctx context.Context, id SlotId) (resp ListWebJobsSlotOperationResponse, err error) { - req, err := c.preparerForListWebJobsSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListWebJobsSlot", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListWebJobsSlot", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListWebJobsSlot(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListWebJobsSlot", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListWebJobsSlot prepares the ListWebJobsSlot request. -func (c WebAppsClient) preparerForListWebJobsSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/webJobs", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWebJobsSlotWithNextLink prepares the ListWebJobsSlot request with the given nextLink token. -func (c WebAppsClient) preparerForListWebJobsSlotWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListWebJobsSlot handles the response to the ListWebJobsSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListWebJobsSlot(resp *http.Response) (result ListWebJobsSlotOperationResponse, err error) { - type page struct { - Values []WebJob `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListWebJobsSlotOperationResponse, err error) { - req, err := c.preparerForListWebJobsSlotWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListWebJobsSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListWebJobsSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListWebJobsSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListWebJobsSlot", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListWebJobsSlotComplete retrieves all of the results into a single object -func (c WebAppsClient) ListWebJobsSlotComplete(ctx context.Context, id SlotId) (ListWebJobsSlotCompleteResult, error) { - return c.ListWebJobsSlotCompleteMatchingPredicate(ctx, id, WebJobOperationPredicate{}) -} - -// ListWebJobsSlotCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListWebJobsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate WebJobOperationPredicate) (resp ListWebJobsSlotCompleteResult, err error) { - items := make([]WebJob, 0) - - page, err := c.ListWebJobsSlot(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListWebJobsSlotCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listworkflows.go b/resource-manager/web/2022-09-01/webapps/method_listworkflows.go new file mode 100644 index 00000000000..5ea46e3fbe9 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listworkflows.go @@ -0,0 +1,89 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListWorkflowsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WorkflowEnvelope +} + +type ListWorkflowsCompleteResult struct { + Items []WorkflowEnvelope +} + +// ListWorkflows ... +func (c WebAppsClient) ListWorkflows(ctx context.Context, id SiteId) (result ListWorkflowsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/workflows", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]WorkflowEnvelope `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListWorkflowsComplete retrieves all the results into a single object +func (c WebAppsClient) ListWorkflowsComplete(ctx context.Context, id SiteId) (ListWorkflowsCompleteResult, error) { + return c.ListWorkflowsCompleteMatchingPredicate(ctx, id, WorkflowEnvelopeOperationPredicate{}) +} + +// ListWorkflowsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListWorkflowsCompleteMatchingPredicate(ctx context.Context, id SiteId, predicate WorkflowEnvelopeOperationPredicate) (result ListWorkflowsCompleteResult, err error) { + items := make([]WorkflowEnvelope, 0) + + resp, err := c.ListWorkflows(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListWorkflowsCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listworkflows_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listworkflows_autorest.go deleted file mode 100644 index 1e3e32a9326..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listworkflows_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListWorkflowsOperationResponse struct { - HttpResponse *http.Response - Model *[]WorkflowEnvelope - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListWorkflowsOperationResponse, error) -} - -type ListWorkflowsCompleteResult struct { - Items []WorkflowEnvelope -} - -func (r ListWorkflowsOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListWorkflowsOperationResponse) LoadMore(ctx context.Context) (resp ListWorkflowsOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListWorkflows ... -func (c WebAppsClient) ListWorkflows(ctx context.Context, id SiteId) (resp ListWorkflowsOperationResponse, err error) { - req, err := c.preparerForListWorkflows(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListWorkflows", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListWorkflows", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListWorkflows(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListWorkflows", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListWorkflows prepares the ListWorkflows request. -func (c WebAppsClient) preparerForListWorkflows(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/workflows", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWorkflowsWithNextLink prepares the ListWorkflows request with the given nextLink token. -func (c WebAppsClient) preparerForListWorkflowsWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListWorkflows handles the response to the ListWorkflows request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListWorkflows(resp *http.Response) (result ListWorkflowsOperationResponse, err error) { - type page struct { - Values []WorkflowEnvelope `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListWorkflowsOperationResponse, err error) { - req, err := c.preparerForListWorkflowsWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListWorkflows", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListWorkflows", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListWorkflows(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListWorkflows", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListWorkflowsComplete retrieves all of the results into a single object -func (c WebAppsClient) ListWorkflowsComplete(ctx context.Context, id SiteId) (ListWorkflowsCompleteResult, error) { - return c.ListWorkflowsCompleteMatchingPredicate(ctx, id, WorkflowEnvelopeOperationPredicate{}) -} - -// ListWorkflowsCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WebAppsClient) ListWorkflowsCompleteMatchingPredicate(ctx context.Context, id SiteId, predicate WorkflowEnvelopeOperationPredicate) (resp ListWorkflowsCompleteResult, err error) { - items := make([]WorkflowEnvelope, 0) - - page, err := c.ListWorkflows(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListWorkflowsCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listworkflowsconnections.go b/resource-manager/web/2022-09-01/webapps/method_listworkflowsconnections.go new file mode 100644 index 00000000000..d0e743381e3 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listworkflowsconnections.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListWorkflowsConnectionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkflowEnvelope +} + +// ListWorkflowsConnections ... +func (c WebAppsClient) ListWorkflowsConnections(ctx context.Context, id SiteId) (result ListWorkflowsConnectionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listWorkflowsConnections", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listworkflowsconnections_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listworkflowsconnections_autorest.go deleted file mode 100644 index e86f0deb77d..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listworkflowsconnections_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListWorkflowsConnectionsOperationResponse struct { - HttpResponse *http.Response - Model *WorkflowEnvelope -} - -// ListWorkflowsConnections ... -func (c WebAppsClient) ListWorkflowsConnections(ctx context.Context, id SiteId) (result ListWorkflowsConnectionsOperationResponse, err error) { - req, err := c.preparerForListWorkflowsConnections(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListWorkflowsConnections", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListWorkflowsConnections", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListWorkflowsConnections(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListWorkflowsConnections", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListWorkflowsConnections prepares the ListWorkflowsConnections request. -func (c WebAppsClient) preparerForListWorkflowsConnections(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/listWorkflowsConnections", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListWorkflowsConnections handles the response to the ListWorkflowsConnections request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListWorkflowsConnections(resp *http.Response) (result ListWorkflowsConnectionsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_listworkflowsconnectionsslot.go b/resource-manager/web/2022-09-01/webapps/method_listworkflowsconnectionsslot.go new file mode 100644 index 00000000000..e2515d67be3 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_listworkflowsconnectionsslot.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "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 ListWorkflowsConnectionsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkflowEnvelope +} + +// ListWorkflowsConnectionsSlot ... +func (c WebAppsClient) ListWorkflowsConnectionsSlot(ctx context.Context, id SlotId) (result ListWorkflowsConnectionsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listWorkflowsConnections", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_listworkflowsconnectionsslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_listworkflowsconnectionsslot_autorest.go deleted file mode 100644 index 341e051a8a6..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_listworkflowsconnectionsslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListWorkflowsConnectionsSlotOperationResponse struct { - HttpResponse *http.Response - Model *WorkflowEnvelope -} - -// ListWorkflowsConnectionsSlot ... -func (c WebAppsClient) ListWorkflowsConnectionsSlot(ctx context.Context, id SlotId) (result ListWorkflowsConnectionsSlotOperationResponse, err error) { - req, err := c.preparerForListWorkflowsConnectionsSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListWorkflowsConnectionsSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListWorkflowsConnectionsSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListWorkflowsConnectionsSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ListWorkflowsConnectionsSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListWorkflowsConnectionsSlot prepares the ListWorkflowsConnectionsSlot request. -func (c WebAppsClient) preparerForListWorkflowsConnectionsSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/listWorkflowsConnections", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListWorkflowsConnectionsSlot handles the response to the ListWorkflowsConnectionsSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForListWorkflowsConnectionsSlot(resp *http.Response) (result ListWorkflowsConnectionsSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_migratemysql.go b/resource-manager/web/2022-09-01/webapps/method_migratemysql.go new file mode 100644 index 00000000000..d565441d9d6 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_migratemysql.go @@ -0,0 +1,73 @@ +package webapps + +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 MigrateMySqlOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// MigrateMySql ... +func (c WebAppsClient) MigrateMySql(ctx context.Context, id SiteId, input MigrateMySqlRequest) (result MigrateMySqlOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/migrateMySql", 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 +} + +// MigrateMySqlThenPoll performs MigrateMySql then polls until it's completed +func (c WebAppsClient) MigrateMySqlThenPoll(ctx context.Context, id SiteId, input MigrateMySqlRequest) error { + result, err := c.MigrateMySql(ctx, id, input) + if err != nil { + return fmt.Errorf("performing MigrateMySql: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after MigrateMySql: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/webapps/method_migratemysql_autorest.go b/resource-manager/web/2022-09-01/webapps/method_migratemysql_autorest.go deleted file mode 100644 index 2766a8708a1..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_migratemysql_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type MigrateMySqlOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// MigrateMySql ... -func (c WebAppsClient) MigrateMySql(ctx context.Context, id SiteId, input MigrateMySqlRequest) (result MigrateMySqlOperationResponse, err error) { - req, err := c.preparerForMigrateMySql(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "MigrateMySql", nil, "Failure preparing request") - return - } - - result, err = c.senderForMigrateMySql(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "MigrateMySql", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// MigrateMySqlThenPoll performs MigrateMySql then polls until it's completed -func (c WebAppsClient) MigrateMySqlThenPoll(ctx context.Context, id SiteId, input MigrateMySqlRequest) error { - result, err := c.MigrateMySql(ctx, id, input) - if err != nil { - return fmt.Errorf("performing MigrateMySql: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after MigrateMySql: %+v", err) - } - - return nil -} - -// preparerForMigrateMySql prepares the MigrateMySql request. -func (c WebAppsClient) preparerForMigrateMySql(ctx context.Context, id SiteId, input MigrateMySqlRequest) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/migrateMySql", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForMigrateMySql sends the MigrateMySql request. The method will close the -// http.Response Body if it receives an error. -func (c WebAppsClient) senderForMigrateMySql(ctx context.Context, req *http.Request) (future MigrateMySqlOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_migratestorage.go b/resource-manager/web/2022-09-01/webapps/method_migratestorage.go new file mode 100644 index 00000000000..714b2de5ebe --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_migratestorage.go @@ -0,0 +1,101 @@ +package webapps + +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 MigrateStorageOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +type MigrateStorageOperationOptions struct { + SubscriptionName *string +} + +func DefaultMigrateStorageOperationOptions() MigrateStorageOperationOptions { + return MigrateStorageOperationOptions{} +} + +func (o MigrateStorageOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o MigrateStorageOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o MigrateStorageOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.SubscriptionName != nil { + out.Append("subscriptionName", fmt.Sprintf("%v", *o.SubscriptionName)) + } + return &out +} + +// MigrateStorage ... +func (c WebAppsClient) MigrateStorage(ctx context.Context, id SiteId, input StorageMigrationOptions, options MigrateStorageOperationOptions) (result MigrateStorageOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/migrate", 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 +} + +// MigrateStorageThenPoll performs MigrateStorage then polls until it's completed +func (c WebAppsClient) MigrateStorageThenPoll(ctx context.Context, id SiteId, input StorageMigrationOptions, options MigrateStorageOperationOptions) error { + result, err := c.MigrateStorage(ctx, id, input, options) + if err != nil { + return fmt.Errorf("performing MigrateStorage: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after MigrateStorage: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/webapps/method_migratestorage_autorest.go b/resource-manager/web/2022-09-01/webapps/method_migratestorage_autorest.go deleted file mode 100644 index 1a7b699bc21..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_migratestorage_autorest.go +++ /dev/null @@ -1,108 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type MigrateStorageOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -type MigrateStorageOperationOptions struct { - SubscriptionName *string -} - -func DefaultMigrateStorageOperationOptions() MigrateStorageOperationOptions { - return MigrateStorageOperationOptions{} -} - -func (o MigrateStorageOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o MigrateStorageOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.SubscriptionName != nil { - out["subscriptionName"] = *o.SubscriptionName - } - - return out -} - -// MigrateStorage ... -func (c WebAppsClient) MigrateStorage(ctx context.Context, id SiteId, input StorageMigrationOptions, options MigrateStorageOperationOptions) (result MigrateStorageOperationResponse, err error) { - req, err := c.preparerForMigrateStorage(ctx, id, input, options) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "MigrateStorage", nil, "Failure preparing request") - return - } - - result, err = c.senderForMigrateStorage(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "MigrateStorage", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// MigrateStorageThenPoll performs MigrateStorage then polls until it's completed -func (c WebAppsClient) MigrateStorageThenPoll(ctx context.Context, id SiteId, input StorageMigrationOptions, options MigrateStorageOperationOptions) error { - result, err := c.MigrateStorage(ctx, id, input, options) - if err != nil { - return fmt.Errorf("performing MigrateStorage: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after MigrateStorage: %+v", err) - } - - return nil -} - -// preparerForMigrateStorage prepares the MigrateStorage request. -func (c WebAppsClient) preparerForMigrateStorage(ctx context.Context, id SiteId, input StorageMigrationOptions, options MigrateStorageOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/migrate", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForMigrateStorage sends the MigrateStorage request. The method will close the -// http.Response Body if it receives an error. -func (c WebAppsClient) senderForMigrateStorage(ctx context.Context, req *http.Request) (future MigrateStorageOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_putprivateaccessvnet.go b/resource-manager/web/2022-09-01/webapps/method_putprivateaccessvnet.go new file mode 100644 index 00000000000..548413bc36c --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_putprivateaccessvnet.go @@ -0,0 +1,56 @@ +package webapps + +import ( + "context" + "fmt" + "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 PutPrivateAccessVnetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateAccess +} + +// PutPrivateAccessVnet ... +func (c WebAppsClient) PutPrivateAccessVnet(ctx context.Context, id SiteId, input PrivateAccess) (result PutPrivateAccessVnetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/privateAccess/virtualNetworks", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_putprivateaccessvnet_autorest.go b/resource-manager/web/2022-09-01/webapps/method_putprivateaccessvnet_autorest.go deleted file mode 100644 index ae9c8019f83..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_putprivateaccessvnet_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PutPrivateAccessVnetOperationResponse struct { - HttpResponse *http.Response - Model *PrivateAccess -} - -// PutPrivateAccessVnet ... -func (c WebAppsClient) PutPrivateAccessVnet(ctx context.Context, id SiteId, input PrivateAccess) (result PutPrivateAccessVnetOperationResponse, err error) { - req, err := c.preparerForPutPrivateAccessVnet(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "PutPrivateAccessVnet", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "PutPrivateAccessVnet", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForPutPrivateAccessVnet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "PutPrivateAccessVnet", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForPutPrivateAccessVnet prepares the PutPrivateAccessVnet request. -func (c WebAppsClient) preparerForPutPrivateAccessVnet(ctx context.Context, id SiteId, input PrivateAccess) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/privateAccess/virtualNetworks", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForPutPrivateAccessVnet handles the response to the PutPrivateAccessVnet request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForPutPrivateAccessVnet(resp *http.Response) (result PutPrivateAccessVnetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_putprivateaccessvnetslot.go b/resource-manager/web/2022-09-01/webapps/method_putprivateaccessvnetslot.go new file mode 100644 index 00000000000..273b130405d --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_putprivateaccessvnetslot.go @@ -0,0 +1,56 @@ +package webapps + +import ( + "context" + "fmt" + "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 PutPrivateAccessVnetSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateAccess +} + +// PutPrivateAccessVnetSlot ... +func (c WebAppsClient) PutPrivateAccessVnetSlot(ctx context.Context, id SlotId, input PrivateAccess) (result PutPrivateAccessVnetSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/privateAccess/virtualNetworks", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_putprivateaccessvnetslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_putprivateaccessvnetslot_autorest.go deleted file mode 100644 index 54246cde172..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_putprivateaccessvnetslot_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type PutPrivateAccessVnetSlotOperationResponse struct { - HttpResponse *http.Response - Model *PrivateAccess -} - -// PutPrivateAccessVnetSlot ... -func (c WebAppsClient) PutPrivateAccessVnetSlot(ctx context.Context, id SlotId, input PrivateAccess) (result PutPrivateAccessVnetSlotOperationResponse, err error) { - req, err := c.preparerForPutPrivateAccessVnetSlot(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "PutPrivateAccessVnetSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "PutPrivateAccessVnetSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForPutPrivateAccessVnetSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "PutPrivateAccessVnetSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForPutPrivateAccessVnetSlot prepares the PutPrivateAccessVnetSlot request. -func (c WebAppsClient) preparerForPutPrivateAccessVnetSlot(ctx context.Context, id SlotId, input PrivateAccess) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/privateAccess/virtualNetworks", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForPutPrivateAccessVnetSlot handles the response to the PutPrivateAccessVnetSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForPutPrivateAccessVnetSlot(resp *http.Response) (result PutPrivateAccessVnetSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_recoversiteconfigurationsnapshot.go b/resource-manager/web/2022-09-01/webapps/method_recoversiteconfigurationsnapshot.go new file mode 100644 index 00000000000..efe6fafba22 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_recoversiteconfigurationsnapshot.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "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 RecoverSiteConfigurationSnapshotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// RecoverSiteConfigurationSnapshot ... +func (c WebAppsClient) RecoverSiteConfigurationSnapshot(ctx context.Context, id SnapshotId) (result RecoverSiteConfigurationSnapshotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/recover", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_recoversiteconfigurationsnapshot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_recoversiteconfigurationsnapshot_autorest.go deleted file mode 100644 index 2a0e5e3cf9c..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_recoversiteconfigurationsnapshot_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type RecoverSiteConfigurationSnapshotOperationResponse struct { - HttpResponse *http.Response -} - -// RecoverSiteConfigurationSnapshot ... -func (c WebAppsClient) RecoverSiteConfigurationSnapshot(ctx context.Context, id SnapshotId) (result RecoverSiteConfigurationSnapshotOperationResponse, err error) { - req, err := c.preparerForRecoverSiteConfigurationSnapshot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "RecoverSiteConfigurationSnapshot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "RecoverSiteConfigurationSnapshot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForRecoverSiteConfigurationSnapshot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "RecoverSiteConfigurationSnapshot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForRecoverSiteConfigurationSnapshot prepares the RecoverSiteConfigurationSnapshot request. -func (c WebAppsClient) preparerForRecoverSiteConfigurationSnapshot(ctx context.Context, id SnapshotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/recover", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForRecoverSiteConfigurationSnapshot handles the response to the RecoverSiteConfigurationSnapshot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForRecoverSiteConfigurationSnapshot(resp *http.Response) (result RecoverSiteConfigurationSnapshotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_recoversiteconfigurationsnapshotslot.go b/resource-manager/web/2022-09-01/webapps/method_recoversiteconfigurationsnapshotslot.go new file mode 100644 index 00000000000..d6cd5a64784 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_recoversiteconfigurationsnapshotslot.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "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 RecoverSiteConfigurationSnapshotSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// RecoverSiteConfigurationSnapshotSlot ... +func (c WebAppsClient) RecoverSiteConfigurationSnapshotSlot(ctx context.Context, id WebSnapshotId) (result RecoverSiteConfigurationSnapshotSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/recover", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_recoversiteconfigurationsnapshotslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_recoversiteconfigurationsnapshotslot_autorest.go deleted file mode 100644 index bd1a36bf952..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_recoversiteconfigurationsnapshotslot_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type RecoverSiteConfigurationSnapshotSlotOperationResponse struct { - HttpResponse *http.Response -} - -// RecoverSiteConfigurationSnapshotSlot ... -func (c WebAppsClient) RecoverSiteConfigurationSnapshotSlot(ctx context.Context, id WebSnapshotId) (result RecoverSiteConfigurationSnapshotSlotOperationResponse, err error) { - req, err := c.preparerForRecoverSiteConfigurationSnapshotSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "RecoverSiteConfigurationSnapshotSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "RecoverSiteConfigurationSnapshotSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForRecoverSiteConfigurationSnapshotSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "RecoverSiteConfigurationSnapshotSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForRecoverSiteConfigurationSnapshotSlot prepares the RecoverSiteConfigurationSnapshotSlot request. -func (c WebAppsClient) preparerForRecoverSiteConfigurationSnapshotSlot(ctx context.Context, id WebSnapshotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/recover", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForRecoverSiteConfigurationSnapshotSlot handles the response to the RecoverSiteConfigurationSnapshotSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForRecoverSiteConfigurationSnapshotSlot(resp *http.Response) (result RecoverSiteConfigurationSnapshotSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_resetproductionslotconfig.go b/resource-manager/web/2022-09-01/webapps/method_resetproductionslotconfig.go new file mode 100644 index 00000000000..6afc8841629 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_resetproductionslotconfig.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "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 ResetProductionSlotConfigOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ResetProductionSlotConfig ... +func (c WebAppsClient) ResetProductionSlotConfig(ctx context.Context, id SiteId) (result ResetProductionSlotConfigOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resetSlotConfig", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_resetproductionslotconfig_autorest.go b/resource-manager/web/2022-09-01/webapps/method_resetproductionslotconfig_autorest.go deleted file mode 100644 index cbad5e2f55b..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_resetproductionslotconfig_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ResetProductionSlotConfigOperationResponse struct { - HttpResponse *http.Response -} - -// ResetProductionSlotConfig ... -func (c WebAppsClient) ResetProductionSlotConfig(ctx context.Context, id SiteId) (result ResetProductionSlotConfigOperationResponse, err error) { - req, err := c.preparerForResetProductionSlotConfig(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ResetProductionSlotConfig", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ResetProductionSlotConfig", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForResetProductionSlotConfig(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ResetProductionSlotConfig", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForResetProductionSlotConfig prepares the ResetProductionSlotConfig request. -func (c WebAppsClient) preparerForResetProductionSlotConfig(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/resetSlotConfig", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForResetProductionSlotConfig handles the response to the ResetProductionSlotConfig request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForResetProductionSlotConfig(resp *http.Response) (result ResetProductionSlotConfigOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_resetslotconfigurationslot.go b/resource-manager/web/2022-09-01/webapps/method_resetslotconfigurationslot.go new file mode 100644 index 00000000000..5fc1adcb6c5 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_resetslotconfigurationslot.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "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 ResetSlotConfigurationSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ResetSlotConfigurationSlot ... +func (c WebAppsClient) ResetSlotConfigurationSlot(ctx context.Context, id SlotId) (result ResetSlotConfigurationSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resetSlotConfig", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_resetslotconfigurationslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_resetslotconfigurationslot_autorest.go deleted file mode 100644 index c018894a3f9..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_resetslotconfigurationslot_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ResetSlotConfigurationSlotOperationResponse struct { - HttpResponse *http.Response -} - -// ResetSlotConfigurationSlot ... -func (c WebAppsClient) ResetSlotConfigurationSlot(ctx context.Context, id SlotId) (result ResetSlotConfigurationSlotOperationResponse, err error) { - req, err := c.preparerForResetSlotConfigurationSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ResetSlotConfigurationSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ResetSlotConfigurationSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForResetSlotConfigurationSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "ResetSlotConfigurationSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForResetSlotConfigurationSlot prepares the ResetSlotConfigurationSlot request. -func (c WebAppsClient) preparerForResetSlotConfigurationSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/resetSlotConfig", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForResetSlotConfigurationSlot handles the response to the ResetSlotConfigurationSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForResetSlotConfigurationSlot(resp *http.Response) (result ResetSlotConfigurationSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_restart.go b/resource-manager/web/2022-09-01/webapps/method_restart.go new file mode 100644 index 00000000000..702c8eb53fa --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_restart.go @@ -0,0 +1,79 @@ +package webapps + +import ( + "context" + "fmt" + "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 RestartOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type RestartOperationOptions struct { + SoftRestart *bool + Synchronous *bool +} + +func DefaultRestartOperationOptions() RestartOperationOptions { + return RestartOperationOptions{} +} + +func (o RestartOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o RestartOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o RestartOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.SoftRestart != nil { + out.Append("softRestart", fmt.Sprintf("%v", *o.SoftRestart)) + } + if o.Synchronous != nil { + out.Append("synchronous", fmt.Sprintf("%v", *o.Synchronous)) + } + return &out +} + +// Restart ... +func (c WebAppsClient) Restart(ctx context.Context, id SiteId, options RestartOperationOptions) (result RestartOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restart", id.ID()), + OptionsObject: options, + } + + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_restart_autorest.go b/resource-manager/web/2022-09-01/webapps/method_restart_autorest.go deleted file mode 100644 index 0ac04ac0643..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_restart_autorest.go +++ /dev/null @@ -1,101 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type RestartOperationResponse struct { - HttpResponse *http.Response -} - -type RestartOperationOptions struct { - SoftRestart *bool - Synchronous *bool -} - -func DefaultRestartOperationOptions() RestartOperationOptions { - return RestartOperationOptions{} -} - -func (o RestartOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o RestartOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.SoftRestart != nil { - out["softRestart"] = *o.SoftRestart - } - - if o.Synchronous != nil { - out["synchronous"] = *o.Synchronous - } - - return out -} - -// Restart ... -func (c WebAppsClient) Restart(ctx context.Context, id SiteId, options RestartOperationOptions) (result RestartOperationResponse, err error) { - req, err := c.preparerForRestart(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "Restart", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "Restart", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForRestart(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "Restart", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForRestart prepares the Restart request. -func (c WebAppsClient) preparerForRestart(ctx context.Context, id SiteId, options RestartOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/restart", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForRestart handles the response to the Restart request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForRestart(resp *http.Response) (result RestartOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_restartslot.go b/resource-manager/web/2022-09-01/webapps/method_restartslot.go new file mode 100644 index 00000000000..9ba732ed8ed --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_restartslot.go @@ -0,0 +1,79 @@ +package webapps + +import ( + "context" + "fmt" + "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 RestartSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type RestartSlotOperationOptions struct { + SoftRestart *bool + Synchronous *bool +} + +func DefaultRestartSlotOperationOptions() RestartSlotOperationOptions { + return RestartSlotOperationOptions{} +} + +func (o RestartSlotOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o RestartSlotOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o RestartSlotOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.SoftRestart != nil { + out.Append("softRestart", fmt.Sprintf("%v", *o.SoftRestart)) + } + if o.Synchronous != nil { + out.Append("synchronous", fmt.Sprintf("%v", *o.Synchronous)) + } + return &out +} + +// RestartSlot ... +func (c WebAppsClient) RestartSlot(ctx context.Context, id SlotId, options RestartSlotOperationOptions) (result RestartSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restart", id.ID()), + OptionsObject: options, + } + + 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_restartslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_restartslot_autorest.go deleted file mode 100644 index 49526dcb24d..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_restartslot_autorest.go +++ /dev/null @@ -1,101 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type RestartSlotOperationResponse struct { - HttpResponse *http.Response -} - -type RestartSlotOperationOptions struct { - SoftRestart *bool - Synchronous *bool -} - -func DefaultRestartSlotOperationOptions() RestartSlotOperationOptions { - return RestartSlotOperationOptions{} -} - -func (o RestartSlotOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o RestartSlotOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.SoftRestart != nil { - out["softRestart"] = *o.SoftRestart - } - - if o.Synchronous != nil { - out["synchronous"] = *o.Synchronous - } - - return out -} - -// RestartSlot ... -func (c WebAppsClient) RestartSlot(ctx context.Context, id SlotId, options RestartSlotOperationOptions) (result RestartSlotOperationResponse, err error) { - req, err := c.preparerForRestartSlot(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "RestartSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "RestartSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForRestartSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "RestartSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForRestartSlot prepares the RestartSlot request. -func (c WebAppsClient) preparerForRestartSlot(ctx context.Context, id SlotId, options RestartSlotOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/restart", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForRestartSlot handles the response to the RestartSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForRestartSlot(resp *http.Response) (result RestartSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_restore.go b/resource-manager/web/2022-09-01/webapps/method_restore.go new file mode 100644 index 00000000000..7466a5735c4 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_restore.go @@ -0,0 +1,74 @@ +package webapps + +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 RestoreOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Restore ... +func (c WebAppsClient) Restore(ctx context.Context, id BackupId, input RestoreRequest) (result RestoreOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restore", 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 +} + +// RestoreThenPoll performs Restore then polls until it's completed +func (c WebAppsClient) RestoreThenPoll(ctx context.Context, id BackupId, input RestoreRequest) error { + result, err := c.Restore(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Restore: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Restore: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/webapps/method_restore_autorest.go b/resource-manager/web/2022-09-01/webapps/method_restore_autorest.go deleted file mode 100644 index 4a6c7b33c5b..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_restore_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type RestoreOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Restore ... -func (c WebAppsClient) Restore(ctx context.Context, id BackupId, input RestoreRequest) (result RestoreOperationResponse, err error) { - req, err := c.preparerForRestore(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "Restore", nil, "Failure preparing request") - return - } - - result, err = c.senderForRestore(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "Restore", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// RestoreThenPoll performs Restore then polls until it's completed -func (c WebAppsClient) RestoreThenPoll(ctx context.Context, id BackupId, input RestoreRequest) error { - result, err := c.Restore(ctx, id, input) - if err != nil { - return fmt.Errorf("performing Restore: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Restore: %+v", err) - } - - return nil -} - -// preparerForRestore prepares the Restore request. -func (c WebAppsClient) preparerForRestore(ctx context.Context, id BackupId, input RestoreRequest) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/restore", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForRestore sends the Restore request. The method will close the -// http.Response Body if it receives an error. -func (c WebAppsClient) senderForRestore(ctx context.Context, req *http.Request) (future RestoreOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_restorefrombackupblob.go b/resource-manager/web/2022-09-01/webapps/method_restorefrombackupblob.go new file mode 100644 index 00000000000..aab693695fe --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_restorefrombackupblob.go @@ -0,0 +1,74 @@ +package webapps + +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 RestoreFromBackupBlobOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RestoreFromBackupBlob ... +func (c WebAppsClient) RestoreFromBackupBlob(ctx context.Context, id SiteId, input RestoreRequest) (result RestoreFromBackupBlobOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restoreFromBackupBlob", 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 +} + +// RestoreFromBackupBlobThenPoll performs RestoreFromBackupBlob then polls until it's completed +func (c WebAppsClient) RestoreFromBackupBlobThenPoll(ctx context.Context, id SiteId, input RestoreRequest) error { + result, err := c.RestoreFromBackupBlob(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RestoreFromBackupBlob: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RestoreFromBackupBlob: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/webapps/method_restorefrombackupblob_autorest.go b/resource-manager/web/2022-09-01/webapps/method_restorefrombackupblob_autorest.go deleted file mode 100644 index e7bd5f6174c..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_restorefrombackupblob_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type RestoreFromBackupBlobOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// RestoreFromBackupBlob ... -func (c WebAppsClient) RestoreFromBackupBlob(ctx context.Context, id SiteId, input RestoreRequest) (result RestoreFromBackupBlobOperationResponse, err error) { - req, err := c.preparerForRestoreFromBackupBlob(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "RestoreFromBackupBlob", nil, "Failure preparing request") - return - } - - result, err = c.senderForRestoreFromBackupBlob(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "RestoreFromBackupBlob", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// RestoreFromBackupBlobThenPoll performs RestoreFromBackupBlob then polls until it's completed -func (c WebAppsClient) RestoreFromBackupBlobThenPoll(ctx context.Context, id SiteId, input RestoreRequest) error { - result, err := c.RestoreFromBackupBlob(ctx, id, input) - if err != nil { - return fmt.Errorf("performing RestoreFromBackupBlob: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after RestoreFromBackupBlob: %+v", err) - } - - return nil -} - -// preparerForRestoreFromBackupBlob prepares the RestoreFromBackupBlob request. -func (c WebAppsClient) preparerForRestoreFromBackupBlob(ctx context.Context, id SiteId, input RestoreRequest) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/restoreFromBackupBlob", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForRestoreFromBackupBlob sends the RestoreFromBackupBlob request. The method will close the -// http.Response Body if it receives an error. -func (c WebAppsClient) senderForRestoreFromBackupBlob(ctx context.Context, req *http.Request) (future RestoreFromBackupBlobOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_restorefrombackupblobslot.go b/resource-manager/web/2022-09-01/webapps/method_restorefrombackupblobslot.go new file mode 100644 index 00000000000..de12d6b3f76 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_restorefrombackupblobslot.go @@ -0,0 +1,74 @@ +package webapps + +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 RestoreFromBackupBlobSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RestoreFromBackupBlobSlot ... +func (c WebAppsClient) RestoreFromBackupBlobSlot(ctx context.Context, id SlotId, input RestoreRequest) (result RestoreFromBackupBlobSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restoreFromBackupBlob", 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 +} + +// RestoreFromBackupBlobSlotThenPoll performs RestoreFromBackupBlobSlot then polls until it's completed +func (c WebAppsClient) RestoreFromBackupBlobSlotThenPoll(ctx context.Context, id SlotId, input RestoreRequest) error { + result, err := c.RestoreFromBackupBlobSlot(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RestoreFromBackupBlobSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RestoreFromBackupBlobSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/webapps/method_restorefrombackupblobslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_restorefrombackupblobslot_autorest.go deleted file mode 100644 index 691d38a1228..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_restorefrombackupblobslot_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type RestoreFromBackupBlobSlotOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// RestoreFromBackupBlobSlot ... -func (c WebAppsClient) RestoreFromBackupBlobSlot(ctx context.Context, id SlotId, input RestoreRequest) (result RestoreFromBackupBlobSlotOperationResponse, err error) { - req, err := c.preparerForRestoreFromBackupBlobSlot(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "RestoreFromBackupBlobSlot", nil, "Failure preparing request") - return - } - - result, err = c.senderForRestoreFromBackupBlobSlot(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "RestoreFromBackupBlobSlot", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// RestoreFromBackupBlobSlotThenPoll performs RestoreFromBackupBlobSlot then polls until it's completed -func (c WebAppsClient) RestoreFromBackupBlobSlotThenPoll(ctx context.Context, id SlotId, input RestoreRequest) error { - result, err := c.RestoreFromBackupBlobSlot(ctx, id, input) - if err != nil { - return fmt.Errorf("performing RestoreFromBackupBlobSlot: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after RestoreFromBackupBlobSlot: %+v", err) - } - - return nil -} - -// preparerForRestoreFromBackupBlobSlot prepares the RestoreFromBackupBlobSlot request. -func (c WebAppsClient) preparerForRestoreFromBackupBlobSlot(ctx context.Context, id SlotId, input RestoreRequest) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/restoreFromBackupBlob", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForRestoreFromBackupBlobSlot sends the RestoreFromBackupBlobSlot request. The method will close the -// http.Response Body if it receives an error. -func (c WebAppsClient) senderForRestoreFromBackupBlobSlot(ctx context.Context, req *http.Request) (future RestoreFromBackupBlobSlotOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_restorefromdeletedapp.go b/resource-manager/web/2022-09-01/webapps/method_restorefromdeletedapp.go new file mode 100644 index 00000000000..805c5716164 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_restorefromdeletedapp.go @@ -0,0 +1,74 @@ +package webapps + +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 RestoreFromDeletedAppOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RestoreFromDeletedApp ... +func (c WebAppsClient) RestoreFromDeletedApp(ctx context.Context, id SiteId, input DeletedAppRestoreRequest) (result RestoreFromDeletedAppOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restoreFromDeletedApp", 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 +} + +// RestoreFromDeletedAppThenPoll performs RestoreFromDeletedApp then polls until it's completed +func (c WebAppsClient) RestoreFromDeletedAppThenPoll(ctx context.Context, id SiteId, input DeletedAppRestoreRequest) error { + result, err := c.RestoreFromDeletedApp(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RestoreFromDeletedApp: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RestoreFromDeletedApp: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/webapps/method_restorefromdeletedapp_autorest.go b/resource-manager/web/2022-09-01/webapps/method_restorefromdeletedapp_autorest.go deleted file mode 100644 index 0e84633d09c..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_restorefromdeletedapp_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type RestoreFromDeletedAppOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// RestoreFromDeletedApp ... -func (c WebAppsClient) RestoreFromDeletedApp(ctx context.Context, id SiteId, input DeletedAppRestoreRequest) (result RestoreFromDeletedAppOperationResponse, err error) { - req, err := c.preparerForRestoreFromDeletedApp(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "RestoreFromDeletedApp", nil, "Failure preparing request") - return - } - - result, err = c.senderForRestoreFromDeletedApp(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "RestoreFromDeletedApp", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// RestoreFromDeletedAppThenPoll performs RestoreFromDeletedApp then polls until it's completed -func (c WebAppsClient) RestoreFromDeletedAppThenPoll(ctx context.Context, id SiteId, input DeletedAppRestoreRequest) error { - result, err := c.RestoreFromDeletedApp(ctx, id, input) - if err != nil { - return fmt.Errorf("performing RestoreFromDeletedApp: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after RestoreFromDeletedApp: %+v", err) - } - - return nil -} - -// preparerForRestoreFromDeletedApp prepares the RestoreFromDeletedApp request. -func (c WebAppsClient) preparerForRestoreFromDeletedApp(ctx context.Context, id SiteId, input DeletedAppRestoreRequest) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/restoreFromDeletedApp", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForRestoreFromDeletedApp sends the RestoreFromDeletedApp request. The method will close the -// http.Response Body if it receives an error. -func (c WebAppsClient) senderForRestoreFromDeletedApp(ctx context.Context, req *http.Request) (future RestoreFromDeletedAppOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_restorefromdeletedappslot.go b/resource-manager/web/2022-09-01/webapps/method_restorefromdeletedappslot.go new file mode 100644 index 00000000000..d91b8c9cfcc --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_restorefromdeletedappslot.go @@ -0,0 +1,74 @@ +package webapps + +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 RestoreFromDeletedAppSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RestoreFromDeletedAppSlot ... +func (c WebAppsClient) RestoreFromDeletedAppSlot(ctx context.Context, id SlotId, input DeletedAppRestoreRequest) (result RestoreFromDeletedAppSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restoreFromDeletedApp", 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 +} + +// RestoreFromDeletedAppSlotThenPoll performs RestoreFromDeletedAppSlot then polls until it's completed +func (c WebAppsClient) RestoreFromDeletedAppSlotThenPoll(ctx context.Context, id SlotId, input DeletedAppRestoreRequest) error { + result, err := c.RestoreFromDeletedAppSlot(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RestoreFromDeletedAppSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RestoreFromDeletedAppSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/webapps/method_restorefromdeletedappslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_restorefromdeletedappslot_autorest.go deleted file mode 100644 index dc8b5d1b9df..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_restorefromdeletedappslot_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type RestoreFromDeletedAppSlotOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// RestoreFromDeletedAppSlot ... -func (c WebAppsClient) RestoreFromDeletedAppSlot(ctx context.Context, id SlotId, input DeletedAppRestoreRequest) (result RestoreFromDeletedAppSlotOperationResponse, err error) { - req, err := c.preparerForRestoreFromDeletedAppSlot(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "RestoreFromDeletedAppSlot", nil, "Failure preparing request") - return - } - - result, err = c.senderForRestoreFromDeletedAppSlot(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "RestoreFromDeletedAppSlot", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// RestoreFromDeletedAppSlotThenPoll performs RestoreFromDeletedAppSlot then polls until it's completed -func (c WebAppsClient) RestoreFromDeletedAppSlotThenPoll(ctx context.Context, id SlotId, input DeletedAppRestoreRequest) error { - result, err := c.RestoreFromDeletedAppSlot(ctx, id, input) - if err != nil { - return fmt.Errorf("performing RestoreFromDeletedAppSlot: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after RestoreFromDeletedAppSlot: %+v", err) - } - - return nil -} - -// preparerForRestoreFromDeletedAppSlot prepares the RestoreFromDeletedAppSlot request. -func (c WebAppsClient) preparerForRestoreFromDeletedAppSlot(ctx context.Context, id SlotId, input DeletedAppRestoreRequest) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/restoreFromDeletedApp", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForRestoreFromDeletedAppSlot sends the RestoreFromDeletedAppSlot request. The method will close the -// http.Response Body if it receives an error. -func (c WebAppsClient) senderForRestoreFromDeletedAppSlot(ctx context.Context, req *http.Request) (future RestoreFromDeletedAppSlotOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_restoreslot.go b/resource-manager/web/2022-09-01/webapps/method_restoreslot.go new file mode 100644 index 00000000000..cab1f3f6d8c --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_restoreslot.go @@ -0,0 +1,74 @@ +package webapps + +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 RestoreSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RestoreSlot ... +func (c WebAppsClient) RestoreSlot(ctx context.Context, id SlotBackupId, input RestoreRequest) (result RestoreSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restore", 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 +} + +// RestoreSlotThenPoll performs RestoreSlot then polls until it's completed +func (c WebAppsClient) RestoreSlotThenPoll(ctx context.Context, id SlotBackupId, input RestoreRequest) error { + result, err := c.RestoreSlot(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RestoreSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RestoreSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/webapps/method_restoreslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_restoreslot_autorest.go deleted file mode 100644 index e3a2329b311..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_restoreslot_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type RestoreSlotOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// RestoreSlot ... -func (c WebAppsClient) RestoreSlot(ctx context.Context, id SlotBackupId, input RestoreRequest) (result RestoreSlotOperationResponse, err error) { - req, err := c.preparerForRestoreSlot(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "RestoreSlot", nil, "Failure preparing request") - return - } - - result, err = c.senderForRestoreSlot(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "RestoreSlot", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// RestoreSlotThenPoll performs RestoreSlot then polls until it's completed -func (c WebAppsClient) RestoreSlotThenPoll(ctx context.Context, id SlotBackupId, input RestoreRequest) error { - result, err := c.RestoreSlot(ctx, id, input) - if err != nil { - return fmt.Errorf("performing RestoreSlot: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after RestoreSlot: %+v", err) - } - - return nil -} - -// preparerForRestoreSlot prepares the RestoreSlot request. -func (c WebAppsClient) preparerForRestoreSlot(ctx context.Context, id SlotBackupId, input RestoreRequest) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/restore", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForRestoreSlot sends the RestoreSlot request. The method will close the -// http.Response Body if it receives an error. -func (c WebAppsClient) senderForRestoreSlot(ctx context.Context, req *http.Request) (future RestoreSlotOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_restoresnapshot.go b/resource-manager/web/2022-09-01/webapps/method_restoresnapshot.go new file mode 100644 index 00000000000..8478f9e2cb4 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_restoresnapshot.go @@ -0,0 +1,74 @@ +package webapps + +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 RestoreSnapshotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RestoreSnapshot ... +func (c WebAppsClient) RestoreSnapshot(ctx context.Context, id SiteId, input SnapshotRestoreRequest) (result RestoreSnapshotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restoreSnapshot", 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 +} + +// RestoreSnapshotThenPoll performs RestoreSnapshot then polls until it's completed +func (c WebAppsClient) RestoreSnapshotThenPoll(ctx context.Context, id SiteId, input SnapshotRestoreRequest) error { + result, err := c.RestoreSnapshot(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RestoreSnapshot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RestoreSnapshot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/webapps/method_restoresnapshot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_restoresnapshot_autorest.go deleted file mode 100644 index ec41d102e9e..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_restoresnapshot_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type RestoreSnapshotOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// RestoreSnapshot ... -func (c WebAppsClient) RestoreSnapshot(ctx context.Context, id SiteId, input SnapshotRestoreRequest) (result RestoreSnapshotOperationResponse, err error) { - req, err := c.preparerForRestoreSnapshot(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "RestoreSnapshot", nil, "Failure preparing request") - return - } - - result, err = c.senderForRestoreSnapshot(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "RestoreSnapshot", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// RestoreSnapshotThenPoll performs RestoreSnapshot then polls until it's completed -func (c WebAppsClient) RestoreSnapshotThenPoll(ctx context.Context, id SiteId, input SnapshotRestoreRequest) error { - result, err := c.RestoreSnapshot(ctx, id, input) - if err != nil { - return fmt.Errorf("performing RestoreSnapshot: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after RestoreSnapshot: %+v", err) - } - - return nil -} - -// preparerForRestoreSnapshot prepares the RestoreSnapshot request. -func (c WebAppsClient) preparerForRestoreSnapshot(ctx context.Context, id SiteId, input SnapshotRestoreRequest) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/restoreSnapshot", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForRestoreSnapshot sends the RestoreSnapshot request. The method will close the -// http.Response Body if it receives an error. -func (c WebAppsClient) senderForRestoreSnapshot(ctx context.Context, req *http.Request) (future RestoreSnapshotOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_restoresnapshotslot.go b/resource-manager/web/2022-09-01/webapps/method_restoresnapshotslot.go new file mode 100644 index 00000000000..5e559a80359 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_restoresnapshotslot.go @@ -0,0 +1,74 @@ +package webapps + +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 RestoreSnapshotSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RestoreSnapshotSlot ... +func (c WebAppsClient) RestoreSnapshotSlot(ctx context.Context, id SlotId, input SnapshotRestoreRequest) (result RestoreSnapshotSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restoreSnapshot", 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 +} + +// RestoreSnapshotSlotThenPoll performs RestoreSnapshotSlot then polls until it's completed +func (c WebAppsClient) RestoreSnapshotSlotThenPoll(ctx context.Context, id SlotId, input SnapshotRestoreRequest) error { + result, err := c.RestoreSnapshotSlot(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RestoreSnapshotSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RestoreSnapshotSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/webapps/method_restoresnapshotslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_restoresnapshotslot_autorest.go deleted file mode 100644 index 1be69f91179..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_restoresnapshotslot_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type RestoreSnapshotSlotOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// RestoreSnapshotSlot ... -func (c WebAppsClient) RestoreSnapshotSlot(ctx context.Context, id SlotId, input SnapshotRestoreRequest) (result RestoreSnapshotSlotOperationResponse, err error) { - req, err := c.preparerForRestoreSnapshotSlot(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "RestoreSnapshotSlot", nil, "Failure preparing request") - return - } - - result, err = c.senderForRestoreSnapshotSlot(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "RestoreSnapshotSlot", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// RestoreSnapshotSlotThenPoll performs RestoreSnapshotSlot then polls until it's completed -func (c WebAppsClient) RestoreSnapshotSlotThenPoll(ctx context.Context, id SlotId, input SnapshotRestoreRequest) error { - result, err := c.RestoreSnapshotSlot(ctx, id, input) - if err != nil { - return fmt.Errorf("performing RestoreSnapshotSlot: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after RestoreSnapshotSlot: %+v", err) - } - - return nil -} - -// preparerForRestoreSnapshotSlot prepares the RestoreSnapshotSlot request. -func (c WebAppsClient) preparerForRestoreSnapshotSlot(ctx context.Context, id SlotId, input SnapshotRestoreRequest) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/restoreSnapshot", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForRestoreSnapshotSlot sends the RestoreSnapshotSlot request. The method will close the -// http.Response Body if it receives an error. -func (c WebAppsClient) senderForRestoreSnapshotSlot(ctx context.Context, req *http.Request) (future RestoreSnapshotSlotOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_runtriggeredwebjob.go b/resource-manager/web/2022-09-01/webapps/method_runtriggeredwebjob.go new file mode 100644 index 00000000000..c7cb4df5f0a --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_runtriggeredwebjob.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "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 RunTriggeredWebJobOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// RunTriggeredWebJob ... +func (c WebAppsClient) RunTriggeredWebJob(ctx context.Context, id TriggeredWebJobId) (result RunTriggeredWebJobOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/run", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_runtriggeredwebjob_autorest.go b/resource-manager/web/2022-09-01/webapps/method_runtriggeredwebjob_autorest.go deleted file mode 100644 index 94a6f875a91..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_runtriggeredwebjob_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type RunTriggeredWebJobOperationResponse struct { - HttpResponse *http.Response -} - -// RunTriggeredWebJob ... -func (c WebAppsClient) RunTriggeredWebJob(ctx context.Context, id TriggeredWebJobId) (result RunTriggeredWebJobOperationResponse, err error) { - req, err := c.preparerForRunTriggeredWebJob(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "RunTriggeredWebJob", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "RunTriggeredWebJob", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForRunTriggeredWebJob(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "RunTriggeredWebJob", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForRunTriggeredWebJob prepares the RunTriggeredWebJob request. -func (c WebAppsClient) preparerForRunTriggeredWebJob(ctx context.Context, id TriggeredWebJobId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/run", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForRunTriggeredWebJob handles the response to the RunTriggeredWebJob request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForRunTriggeredWebJob(resp *http.Response) (result RunTriggeredWebJobOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_runtriggeredwebjobslot.go b/resource-manager/web/2022-09-01/webapps/method_runtriggeredwebjobslot.go new file mode 100644 index 00000000000..3958d7b60b4 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_runtriggeredwebjobslot.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "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 RunTriggeredWebJobSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// RunTriggeredWebJobSlot ... +func (c WebAppsClient) RunTriggeredWebJobSlot(ctx context.Context, id SlotTriggeredWebJobId) (result RunTriggeredWebJobSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/run", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_runtriggeredwebjobslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_runtriggeredwebjobslot_autorest.go deleted file mode 100644 index 7c6655c15d0..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_runtriggeredwebjobslot_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type RunTriggeredWebJobSlotOperationResponse struct { - HttpResponse *http.Response -} - -// RunTriggeredWebJobSlot ... -func (c WebAppsClient) RunTriggeredWebJobSlot(ctx context.Context, id SlotTriggeredWebJobId) (result RunTriggeredWebJobSlotOperationResponse, err error) { - req, err := c.preparerForRunTriggeredWebJobSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "RunTriggeredWebJobSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "RunTriggeredWebJobSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForRunTriggeredWebJobSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "RunTriggeredWebJobSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForRunTriggeredWebJobSlot prepares the RunTriggeredWebJobSlot request. -func (c WebAppsClient) preparerForRunTriggeredWebJobSlot(ctx context.Context, id SlotTriggeredWebJobId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/run", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForRunTriggeredWebJobSlot handles the response to the RunTriggeredWebJobSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForRunTriggeredWebJobSlot(resp *http.Response) (result RunTriggeredWebJobSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_start.go b/resource-manager/web/2022-09-01/webapps/method_start.go new file mode 100644 index 00000000000..6695e45a55e --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_start.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "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 StartOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Start ... +func (c WebAppsClient) Start(ctx context.Context, id SiteId) (result StartOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/start", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_start_autorest.go b/resource-manager/web/2022-09-01/webapps/method_start_autorest.go deleted file mode 100644 index a836a4d54d7..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_start_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type StartOperationResponse struct { - HttpResponse *http.Response -} - -// Start ... -func (c WebAppsClient) Start(ctx context.Context, id SiteId) (result StartOperationResponse, err error) { - req, err := c.preparerForStart(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "Start", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "Start", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForStart(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "Start", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForStart prepares the Start request. -func (c WebAppsClient) preparerForStart(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/start", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForStart handles the response to the Start request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForStart(resp *http.Response) (result StartOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_startcontinuouswebjob.go b/resource-manager/web/2022-09-01/webapps/method_startcontinuouswebjob.go new file mode 100644 index 00000000000..f70803909ea --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_startcontinuouswebjob.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "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 StartContinuousWebJobOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// StartContinuousWebJob ... +func (c WebAppsClient) StartContinuousWebJob(ctx context.Context, id ContinuousWebJobId) (result StartContinuousWebJobOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/start", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_startcontinuouswebjob_autorest.go b/resource-manager/web/2022-09-01/webapps/method_startcontinuouswebjob_autorest.go deleted file mode 100644 index 4c1762dfc55..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_startcontinuouswebjob_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type StartContinuousWebJobOperationResponse struct { - HttpResponse *http.Response -} - -// StartContinuousWebJob ... -func (c WebAppsClient) StartContinuousWebJob(ctx context.Context, id ContinuousWebJobId) (result StartContinuousWebJobOperationResponse, err error) { - req, err := c.preparerForStartContinuousWebJob(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "StartContinuousWebJob", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "StartContinuousWebJob", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForStartContinuousWebJob(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "StartContinuousWebJob", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForStartContinuousWebJob prepares the StartContinuousWebJob request. -func (c WebAppsClient) preparerForStartContinuousWebJob(ctx context.Context, id ContinuousWebJobId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/start", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForStartContinuousWebJob handles the response to the StartContinuousWebJob request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForStartContinuousWebJob(resp *http.Response) (result StartContinuousWebJobOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_startcontinuouswebjobslot.go b/resource-manager/web/2022-09-01/webapps/method_startcontinuouswebjobslot.go new file mode 100644 index 00000000000..8b6e63cb91f --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_startcontinuouswebjobslot.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "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 StartContinuousWebJobSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// StartContinuousWebJobSlot ... +func (c WebAppsClient) StartContinuousWebJobSlot(ctx context.Context, id SlotContinuousWebJobId) (result StartContinuousWebJobSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/start", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_startcontinuouswebjobslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_startcontinuouswebjobslot_autorest.go deleted file mode 100644 index 33f544fc847..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_startcontinuouswebjobslot_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type StartContinuousWebJobSlotOperationResponse struct { - HttpResponse *http.Response -} - -// StartContinuousWebJobSlot ... -func (c WebAppsClient) StartContinuousWebJobSlot(ctx context.Context, id SlotContinuousWebJobId) (result StartContinuousWebJobSlotOperationResponse, err error) { - req, err := c.preparerForStartContinuousWebJobSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "StartContinuousWebJobSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "StartContinuousWebJobSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForStartContinuousWebJobSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "StartContinuousWebJobSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForStartContinuousWebJobSlot prepares the StartContinuousWebJobSlot request. -func (c WebAppsClient) preparerForStartContinuousWebJobSlot(ctx context.Context, id SlotContinuousWebJobId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/start", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForStartContinuousWebJobSlot handles the response to the StartContinuousWebJobSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForStartContinuousWebJobSlot(resp *http.Response) (result StartContinuousWebJobSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_startnetworktrace.go b/resource-manager/web/2022-09-01/webapps/method_startnetworktrace.go new file mode 100644 index 00000000000..fee9fad92cb --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_startnetworktrace.go @@ -0,0 +1,106 @@ +package webapps + +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 StartNetworkTraceOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +type StartNetworkTraceOperationOptions struct { + DurationInSeconds *int64 + MaxFrameLength *int64 + SasUrl *string +} + +func DefaultStartNetworkTraceOperationOptions() StartNetworkTraceOperationOptions { + return StartNetworkTraceOperationOptions{} +} + +func (o StartNetworkTraceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o StartNetworkTraceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o StartNetworkTraceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.DurationInSeconds != nil { + out.Append("durationInSeconds", fmt.Sprintf("%v", *o.DurationInSeconds)) + } + if o.MaxFrameLength != nil { + out.Append("maxFrameLength", fmt.Sprintf("%v", *o.MaxFrameLength)) + } + if o.SasUrl != nil { + out.Append("sasUrl", fmt.Sprintf("%v", *o.SasUrl)) + } + return &out +} + +// StartNetworkTrace ... +func (c WebAppsClient) StartNetworkTrace(ctx context.Context, id SiteId, options StartNetworkTraceOperationOptions) (result StartNetworkTraceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/startNetworkTrace", id.ID()), + OptionsObject: options, + } + + 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 +} + +// StartNetworkTraceThenPoll performs StartNetworkTrace then polls until it's completed +func (c WebAppsClient) StartNetworkTraceThenPoll(ctx context.Context, id SiteId, options StartNetworkTraceOperationOptions) error { + result, err := c.StartNetworkTrace(ctx, id, options) + if err != nil { + return fmt.Errorf("performing StartNetworkTrace: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after StartNetworkTrace: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/webapps/method_startnetworktrace_autorest.go b/resource-manager/web/2022-09-01/webapps/method_startnetworktrace_autorest.go deleted file mode 100644 index eb87df66ebf..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_startnetworktrace_autorest.go +++ /dev/null @@ -1,117 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type StartNetworkTraceOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -type StartNetworkTraceOperationOptions struct { - DurationInSeconds *int64 - MaxFrameLength *int64 - SasUrl *string -} - -func DefaultStartNetworkTraceOperationOptions() StartNetworkTraceOperationOptions { - return StartNetworkTraceOperationOptions{} -} - -func (o StartNetworkTraceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o StartNetworkTraceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.DurationInSeconds != nil { - out["durationInSeconds"] = *o.DurationInSeconds - } - - if o.MaxFrameLength != nil { - out["maxFrameLength"] = *o.MaxFrameLength - } - - if o.SasUrl != nil { - out["sasUrl"] = *o.SasUrl - } - - return out -} - -// StartNetworkTrace ... -func (c WebAppsClient) StartNetworkTrace(ctx context.Context, id SiteId, options StartNetworkTraceOperationOptions) (result StartNetworkTraceOperationResponse, err error) { - req, err := c.preparerForStartNetworkTrace(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "StartNetworkTrace", nil, "Failure preparing request") - return - } - - result, err = c.senderForStartNetworkTrace(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "StartNetworkTrace", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// StartNetworkTraceThenPoll performs StartNetworkTrace then polls until it's completed -func (c WebAppsClient) StartNetworkTraceThenPoll(ctx context.Context, id SiteId, options StartNetworkTraceOperationOptions) error { - result, err := c.StartNetworkTrace(ctx, id, options) - if err != nil { - return fmt.Errorf("performing StartNetworkTrace: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after StartNetworkTrace: %+v", err) - } - - return nil -} - -// preparerForStartNetworkTrace prepares the StartNetworkTrace request. -func (c WebAppsClient) preparerForStartNetworkTrace(ctx context.Context, id SiteId, options StartNetworkTraceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/startNetworkTrace", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForStartNetworkTrace sends the StartNetworkTrace request. The method will close the -// http.Response Body if it receives an error. -func (c WebAppsClient) senderForStartNetworkTrace(ctx context.Context, req *http.Request) (future StartNetworkTraceOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_startnetworktraceslot.go b/resource-manager/web/2022-09-01/webapps/method_startnetworktraceslot.go new file mode 100644 index 00000000000..25a21c569d6 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_startnetworktraceslot.go @@ -0,0 +1,106 @@ +package webapps + +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 StartNetworkTraceSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +type StartNetworkTraceSlotOperationOptions struct { + DurationInSeconds *int64 + MaxFrameLength *int64 + SasUrl *string +} + +func DefaultStartNetworkTraceSlotOperationOptions() StartNetworkTraceSlotOperationOptions { + return StartNetworkTraceSlotOperationOptions{} +} + +func (o StartNetworkTraceSlotOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o StartNetworkTraceSlotOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o StartNetworkTraceSlotOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.DurationInSeconds != nil { + out.Append("durationInSeconds", fmt.Sprintf("%v", *o.DurationInSeconds)) + } + if o.MaxFrameLength != nil { + out.Append("maxFrameLength", fmt.Sprintf("%v", *o.MaxFrameLength)) + } + if o.SasUrl != nil { + out.Append("sasUrl", fmt.Sprintf("%v", *o.SasUrl)) + } + return &out +} + +// StartNetworkTraceSlot ... +func (c WebAppsClient) StartNetworkTraceSlot(ctx context.Context, id SlotId, options StartNetworkTraceSlotOperationOptions) (result StartNetworkTraceSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/startNetworkTrace", id.ID()), + OptionsObject: options, + } + + 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 +} + +// StartNetworkTraceSlotThenPoll performs StartNetworkTraceSlot then polls until it's completed +func (c WebAppsClient) StartNetworkTraceSlotThenPoll(ctx context.Context, id SlotId, options StartNetworkTraceSlotOperationOptions) error { + result, err := c.StartNetworkTraceSlot(ctx, id, options) + if err != nil { + return fmt.Errorf("performing StartNetworkTraceSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after StartNetworkTraceSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/webapps/method_startnetworktraceslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_startnetworktraceslot_autorest.go deleted file mode 100644 index 50032e7024e..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_startnetworktraceslot_autorest.go +++ /dev/null @@ -1,117 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type StartNetworkTraceSlotOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -type StartNetworkTraceSlotOperationOptions struct { - DurationInSeconds *int64 - MaxFrameLength *int64 - SasUrl *string -} - -func DefaultStartNetworkTraceSlotOperationOptions() StartNetworkTraceSlotOperationOptions { - return StartNetworkTraceSlotOperationOptions{} -} - -func (o StartNetworkTraceSlotOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o StartNetworkTraceSlotOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.DurationInSeconds != nil { - out["durationInSeconds"] = *o.DurationInSeconds - } - - if o.MaxFrameLength != nil { - out["maxFrameLength"] = *o.MaxFrameLength - } - - if o.SasUrl != nil { - out["sasUrl"] = *o.SasUrl - } - - return out -} - -// StartNetworkTraceSlot ... -func (c WebAppsClient) StartNetworkTraceSlot(ctx context.Context, id SlotId, options StartNetworkTraceSlotOperationOptions) (result StartNetworkTraceSlotOperationResponse, err error) { - req, err := c.preparerForStartNetworkTraceSlot(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "StartNetworkTraceSlot", nil, "Failure preparing request") - return - } - - result, err = c.senderForStartNetworkTraceSlot(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "StartNetworkTraceSlot", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// StartNetworkTraceSlotThenPoll performs StartNetworkTraceSlot then polls until it's completed -func (c WebAppsClient) StartNetworkTraceSlotThenPoll(ctx context.Context, id SlotId, options StartNetworkTraceSlotOperationOptions) error { - result, err := c.StartNetworkTraceSlot(ctx, id, options) - if err != nil { - return fmt.Errorf("performing StartNetworkTraceSlot: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after StartNetworkTraceSlot: %+v", err) - } - - return nil -} - -// preparerForStartNetworkTraceSlot prepares the StartNetworkTraceSlot request. -func (c WebAppsClient) preparerForStartNetworkTraceSlot(ctx context.Context, id SlotId, options StartNetworkTraceSlotOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/startNetworkTrace", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForStartNetworkTraceSlot sends the StartNetworkTraceSlot request. The method will close the -// http.Response Body if it receives an error. -func (c WebAppsClient) senderForStartNetworkTraceSlot(ctx context.Context, req *http.Request) (future StartNetworkTraceSlotOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_startslot.go b/resource-manager/web/2022-09-01/webapps/method_startslot.go new file mode 100644 index 00000000000..a656170f07e --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_startslot.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "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 StartSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// StartSlot ... +func (c WebAppsClient) StartSlot(ctx context.Context, id SlotId) (result StartSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/start", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_startslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_startslot_autorest.go deleted file mode 100644 index fab28cf0d09..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_startslot_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type StartSlotOperationResponse struct { - HttpResponse *http.Response -} - -// StartSlot ... -func (c WebAppsClient) StartSlot(ctx context.Context, id SlotId) (result StartSlotOperationResponse, err error) { - req, err := c.preparerForStartSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "StartSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "StartSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForStartSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "StartSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForStartSlot prepares the StartSlot request. -func (c WebAppsClient) preparerForStartSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/start", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForStartSlot handles the response to the StartSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForStartSlot(resp *http.Response) (result StartSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_startwebsitenetworktrace.go b/resource-manager/web/2022-09-01/webapps/method_startwebsitenetworktrace.go new file mode 100644 index 00000000000..a0236cab68a --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_startwebsitenetworktrace.go @@ -0,0 +1,88 @@ +package webapps + +import ( + "context" + "fmt" + "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 StartWebSiteNetworkTraceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *string +} + +type StartWebSiteNetworkTraceOperationOptions struct { + DurationInSeconds *int64 + MaxFrameLength *int64 + SasUrl *string +} + +func DefaultStartWebSiteNetworkTraceOperationOptions() StartWebSiteNetworkTraceOperationOptions { + return StartWebSiteNetworkTraceOperationOptions{} +} + +func (o StartWebSiteNetworkTraceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o StartWebSiteNetworkTraceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o StartWebSiteNetworkTraceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.DurationInSeconds != nil { + out.Append("durationInSeconds", fmt.Sprintf("%v", *o.DurationInSeconds)) + } + if o.MaxFrameLength != nil { + out.Append("maxFrameLength", fmt.Sprintf("%v", *o.MaxFrameLength)) + } + if o.SasUrl != nil { + out.Append("sasUrl", fmt.Sprintf("%v", *o.SasUrl)) + } + return &out +} + +// StartWebSiteNetworkTrace ... +func (c WebAppsClient) StartWebSiteNetworkTrace(ctx context.Context, id SiteId, options StartWebSiteNetworkTraceOperationOptions) (result StartWebSiteNetworkTraceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/networkTrace/start", id.ID()), + OptionsObject: options, + } + + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_startwebsitenetworktrace_autorest.go b/resource-manager/web/2022-09-01/webapps/method_startwebsitenetworktrace_autorest.go deleted file mode 100644 index c3a8ced7d1c..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_startwebsitenetworktrace_autorest.go +++ /dev/null @@ -1,108 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type StartWebSiteNetworkTraceOperationResponse struct { - HttpResponse *http.Response - Model *string -} - -type StartWebSiteNetworkTraceOperationOptions struct { - DurationInSeconds *int64 - MaxFrameLength *int64 - SasUrl *string -} - -func DefaultStartWebSiteNetworkTraceOperationOptions() StartWebSiteNetworkTraceOperationOptions { - return StartWebSiteNetworkTraceOperationOptions{} -} - -func (o StartWebSiteNetworkTraceOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o StartWebSiteNetworkTraceOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.DurationInSeconds != nil { - out["durationInSeconds"] = *o.DurationInSeconds - } - - if o.MaxFrameLength != nil { - out["maxFrameLength"] = *o.MaxFrameLength - } - - if o.SasUrl != nil { - out["sasUrl"] = *o.SasUrl - } - - return out -} - -// StartWebSiteNetworkTrace ... -func (c WebAppsClient) StartWebSiteNetworkTrace(ctx context.Context, id SiteId, options StartWebSiteNetworkTraceOperationOptions) (result StartWebSiteNetworkTraceOperationResponse, err error) { - req, err := c.preparerForStartWebSiteNetworkTrace(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "StartWebSiteNetworkTrace", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "StartWebSiteNetworkTrace", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForStartWebSiteNetworkTrace(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "StartWebSiteNetworkTrace", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForStartWebSiteNetworkTrace prepares the StartWebSiteNetworkTrace request. -func (c WebAppsClient) preparerForStartWebSiteNetworkTrace(ctx context.Context, id SiteId, options StartWebSiteNetworkTraceOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/networkTrace/start", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForStartWebSiteNetworkTrace handles the response to the StartWebSiteNetworkTrace request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForStartWebSiteNetworkTrace(resp *http.Response) (result StartWebSiteNetworkTraceOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_startwebsitenetworktraceoperation.go b/resource-manager/web/2022-09-01/webapps/method_startwebsitenetworktraceoperation.go new file mode 100644 index 00000000000..1a0a5766865 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_startwebsitenetworktraceoperation.go @@ -0,0 +1,106 @@ +package webapps + +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 StartWebSiteNetworkTraceOperationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +type StartWebSiteNetworkTraceOperationOperationOptions struct { + DurationInSeconds *int64 + MaxFrameLength *int64 + SasUrl *string +} + +func DefaultStartWebSiteNetworkTraceOperationOperationOptions() StartWebSiteNetworkTraceOperationOperationOptions { + return StartWebSiteNetworkTraceOperationOperationOptions{} +} + +func (o StartWebSiteNetworkTraceOperationOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o StartWebSiteNetworkTraceOperationOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o StartWebSiteNetworkTraceOperationOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.DurationInSeconds != nil { + out.Append("durationInSeconds", fmt.Sprintf("%v", *o.DurationInSeconds)) + } + if o.MaxFrameLength != nil { + out.Append("maxFrameLength", fmt.Sprintf("%v", *o.MaxFrameLength)) + } + if o.SasUrl != nil { + out.Append("sasUrl", fmt.Sprintf("%v", *o.SasUrl)) + } + return &out +} + +// StartWebSiteNetworkTraceOperation ... +func (c WebAppsClient) StartWebSiteNetworkTraceOperation(ctx context.Context, id SiteId, options StartWebSiteNetworkTraceOperationOperationOptions) (result StartWebSiteNetworkTraceOperationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/networkTrace/startOperation", id.ID()), + OptionsObject: options, + } + + 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 +} + +// StartWebSiteNetworkTraceOperationThenPoll performs StartWebSiteNetworkTraceOperation then polls until it's completed +func (c WebAppsClient) StartWebSiteNetworkTraceOperationThenPoll(ctx context.Context, id SiteId, options StartWebSiteNetworkTraceOperationOperationOptions) error { + result, err := c.StartWebSiteNetworkTraceOperation(ctx, id, options) + if err != nil { + return fmt.Errorf("performing StartWebSiteNetworkTraceOperation: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after StartWebSiteNetworkTraceOperation: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/webapps/method_startwebsitenetworktraceoperation_autorest.go b/resource-manager/web/2022-09-01/webapps/method_startwebsitenetworktraceoperation_autorest.go deleted file mode 100644 index 6dee65ba648..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_startwebsitenetworktraceoperation_autorest.go +++ /dev/null @@ -1,117 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type StartWebSiteNetworkTraceOperationOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -type StartWebSiteNetworkTraceOperationOperationOptions struct { - DurationInSeconds *int64 - MaxFrameLength *int64 - SasUrl *string -} - -func DefaultStartWebSiteNetworkTraceOperationOperationOptions() StartWebSiteNetworkTraceOperationOperationOptions { - return StartWebSiteNetworkTraceOperationOperationOptions{} -} - -func (o StartWebSiteNetworkTraceOperationOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o StartWebSiteNetworkTraceOperationOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.DurationInSeconds != nil { - out["durationInSeconds"] = *o.DurationInSeconds - } - - if o.MaxFrameLength != nil { - out["maxFrameLength"] = *o.MaxFrameLength - } - - if o.SasUrl != nil { - out["sasUrl"] = *o.SasUrl - } - - return out -} - -// StartWebSiteNetworkTraceOperation ... -func (c WebAppsClient) StartWebSiteNetworkTraceOperation(ctx context.Context, id SiteId, options StartWebSiteNetworkTraceOperationOperationOptions) (result StartWebSiteNetworkTraceOperationOperationResponse, err error) { - req, err := c.preparerForStartWebSiteNetworkTraceOperation(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "StartWebSiteNetworkTraceOperation", nil, "Failure preparing request") - return - } - - result, err = c.senderForStartWebSiteNetworkTraceOperation(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "StartWebSiteNetworkTraceOperation", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// StartWebSiteNetworkTraceOperationThenPoll performs StartWebSiteNetworkTraceOperation then polls until it's completed -func (c WebAppsClient) StartWebSiteNetworkTraceOperationThenPoll(ctx context.Context, id SiteId, options StartWebSiteNetworkTraceOperationOperationOptions) error { - result, err := c.StartWebSiteNetworkTraceOperation(ctx, id, options) - if err != nil { - return fmt.Errorf("performing StartWebSiteNetworkTraceOperation: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after StartWebSiteNetworkTraceOperation: %+v", err) - } - - return nil -} - -// preparerForStartWebSiteNetworkTraceOperation prepares the StartWebSiteNetworkTraceOperation request. -func (c WebAppsClient) preparerForStartWebSiteNetworkTraceOperation(ctx context.Context, id SiteId, options StartWebSiteNetworkTraceOperationOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/networkTrace/startOperation", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForStartWebSiteNetworkTraceOperation sends the StartWebSiteNetworkTraceOperation request. The method will close the -// http.Response Body if it receives an error. -func (c WebAppsClient) senderForStartWebSiteNetworkTraceOperation(ctx context.Context, req *http.Request) (future StartWebSiteNetworkTraceOperationOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_startwebsitenetworktraceoperationslot.go b/resource-manager/web/2022-09-01/webapps/method_startwebsitenetworktraceoperationslot.go new file mode 100644 index 00000000000..08d7305ad7a --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_startwebsitenetworktraceoperationslot.go @@ -0,0 +1,106 @@ +package webapps + +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 StartWebSiteNetworkTraceOperationSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +type StartWebSiteNetworkTraceOperationSlotOperationOptions struct { + DurationInSeconds *int64 + MaxFrameLength *int64 + SasUrl *string +} + +func DefaultStartWebSiteNetworkTraceOperationSlotOperationOptions() StartWebSiteNetworkTraceOperationSlotOperationOptions { + return StartWebSiteNetworkTraceOperationSlotOperationOptions{} +} + +func (o StartWebSiteNetworkTraceOperationSlotOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o StartWebSiteNetworkTraceOperationSlotOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o StartWebSiteNetworkTraceOperationSlotOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.DurationInSeconds != nil { + out.Append("durationInSeconds", fmt.Sprintf("%v", *o.DurationInSeconds)) + } + if o.MaxFrameLength != nil { + out.Append("maxFrameLength", fmt.Sprintf("%v", *o.MaxFrameLength)) + } + if o.SasUrl != nil { + out.Append("sasUrl", fmt.Sprintf("%v", *o.SasUrl)) + } + return &out +} + +// StartWebSiteNetworkTraceOperationSlot ... +func (c WebAppsClient) StartWebSiteNetworkTraceOperationSlot(ctx context.Context, id SlotId, options StartWebSiteNetworkTraceOperationSlotOperationOptions) (result StartWebSiteNetworkTraceOperationSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/networkTrace/startOperation", id.ID()), + OptionsObject: options, + } + + 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 +} + +// StartWebSiteNetworkTraceOperationSlotThenPoll performs StartWebSiteNetworkTraceOperationSlot then polls until it's completed +func (c WebAppsClient) StartWebSiteNetworkTraceOperationSlotThenPoll(ctx context.Context, id SlotId, options StartWebSiteNetworkTraceOperationSlotOperationOptions) error { + result, err := c.StartWebSiteNetworkTraceOperationSlot(ctx, id, options) + if err != nil { + return fmt.Errorf("performing StartWebSiteNetworkTraceOperationSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after StartWebSiteNetworkTraceOperationSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/webapps/method_startwebsitenetworktraceoperationslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_startwebsitenetworktraceoperationslot_autorest.go deleted file mode 100644 index 8171bcd20a8..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_startwebsitenetworktraceoperationslot_autorest.go +++ /dev/null @@ -1,117 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type StartWebSiteNetworkTraceOperationSlotOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -type StartWebSiteNetworkTraceOperationSlotOperationOptions struct { - DurationInSeconds *int64 - MaxFrameLength *int64 - SasUrl *string -} - -func DefaultStartWebSiteNetworkTraceOperationSlotOperationOptions() StartWebSiteNetworkTraceOperationSlotOperationOptions { - return StartWebSiteNetworkTraceOperationSlotOperationOptions{} -} - -func (o StartWebSiteNetworkTraceOperationSlotOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o StartWebSiteNetworkTraceOperationSlotOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.DurationInSeconds != nil { - out["durationInSeconds"] = *o.DurationInSeconds - } - - if o.MaxFrameLength != nil { - out["maxFrameLength"] = *o.MaxFrameLength - } - - if o.SasUrl != nil { - out["sasUrl"] = *o.SasUrl - } - - return out -} - -// StartWebSiteNetworkTraceOperationSlot ... -func (c WebAppsClient) StartWebSiteNetworkTraceOperationSlot(ctx context.Context, id SlotId, options StartWebSiteNetworkTraceOperationSlotOperationOptions) (result StartWebSiteNetworkTraceOperationSlotOperationResponse, err error) { - req, err := c.preparerForStartWebSiteNetworkTraceOperationSlot(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "StartWebSiteNetworkTraceOperationSlot", nil, "Failure preparing request") - return - } - - result, err = c.senderForStartWebSiteNetworkTraceOperationSlot(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "StartWebSiteNetworkTraceOperationSlot", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// StartWebSiteNetworkTraceOperationSlotThenPoll performs StartWebSiteNetworkTraceOperationSlot then polls until it's completed -func (c WebAppsClient) StartWebSiteNetworkTraceOperationSlotThenPoll(ctx context.Context, id SlotId, options StartWebSiteNetworkTraceOperationSlotOperationOptions) error { - result, err := c.StartWebSiteNetworkTraceOperationSlot(ctx, id, options) - if err != nil { - return fmt.Errorf("performing StartWebSiteNetworkTraceOperationSlot: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after StartWebSiteNetworkTraceOperationSlot: %+v", err) - } - - return nil -} - -// preparerForStartWebSiteNetworkTraceOperationSlot prepares the StartWebSiteNetworkTraceOperationSlot request. -func (c WebAppsClient) preparerForStartWebSiteNetworkTraceOperationSlot(ctx context.Context, id SlotId, options StartWebSiteNetworkTraceOperationSlotOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/networkTrace/startOperation", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForStartWebSiteNetworkTraceOperationSlot sends the StartWebSiteNetworkTraceOperationSlot request. The method will close the -// http.Response Body if it receives an error. -func (c WebAppsClient) senderForStartWebSiteNetworkTraceOperationSlot(ctx context.Context, req *http.Request) (future StartWebSiteNetworkTraceOperationSlotOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_startwebsitenetworktraceslot.go b/resource-manager/web/2022-09-01/webapps/method_startwebsitenetworktraceslot.go new file mode 100644 index 00000000000..a4a9e01e2d3 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_startwebsitenetworktraceslot.go @@ -0,0 +1,88 @@ +package webapps + +import ( + "context" + "fmt" + "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 StartWebSiteNetworkTraceSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *string +} + +type StartWebSiteNetworkTraceSlotOperationOptions struct { + DurationInSeconds *int64 + MaxFrameLength *int64 + SasUrl *string +} + +func DefaultStartWebSiteNetworkTraceSlotOperationOptions() StartWebSiteNetworkTraceSlotOperationOptions { + return StartWebSiteNetworkTraceSlotOperationOptions{} +} + +func (o StartWebSiteNetworkTraceSlotOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o StartWebSiteNetworkTraceSlotOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o StartWebSiteNetworkTraceSlotOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.DurationInSeconds != nil { + out.Append("durationInSeconds", fmt.Sprintf("%v", *o.DurationInSeconds)) + } + if o.MaxFrameLength != nil { + out.Append("maxFrameLength", fmt.Sprintf("%v", *o.MaxFrameLength)) + } + if o.SasUrl != nil { + out.Append("sasUrl", fmt.Sprintf("%v", *o.SasUrl)) + } + return &out +} + +// StartWebSiteNetworkTraceSlot ... +func (c WebAppsClient) StartWebSiteNetworkTraceSlot(ctx context.Context, id SlotId, options StartWebSiteNetworkTraceSlotOperationOptions) (result StartWebSiteNetworkTraceSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/networkTrace/start", id.ID()), + OptionsObject: options, + } + + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_startwebsitenetworktraceslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_startwebsitenetworktraceslot_autorest.go deleted file mode 100644 index ff9424b82ef..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_startwebsitenetworktraceslot_autorest.go +++ /dev/null @@ -1,108 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type StartWebSiteNetworkTraceSlotOperationResponse struct { - HttpResponse *http.Response - Model *string -} - -type StartWebSiteNetworkTraceSlotOperationOptions struct { - DurationInSeconds *int64 - MaxFrameLength *int64 - SasUrl *string -} - -func DefaultStartWebSiteNetworkTraceSlotOperationOptions() StartWebSiteNetworkTraceSlotOperationOptions { - return StartWebSiteNetworkTraceSlotOperationOptions{} -} - -func (o StartWebSiteNetworkTraceSlotOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o StartWebSiteNetworkTraceSlotOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.DurationInSeconds != nil { - out["durationInSeconds"] = *o.DurationInSeconds - } - - if o.MaxFrameLength != nil { - out["maxFrameLength"] = *o.MaxFrameLength - } - - if o.SasUrl != nil { - out["sasUrl"] = *o.SasUrl - } - - return out -} - -// StartWebSiteNetworkTraceSlot ... -func (c WebAppsClient) StartWebSiteNetworkTraceSlot(ctx context.Context, id SlotId, options StartWebSiteNetworkTraceSlotOperationOptions) (result StartWebSiteNetworkTraceSlotOperationResponse, err error) { - req, err := c.preparerForStartWebSiteNetworkTraceSlot(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "StartWebSiteNetworkTraceSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "StartWebSiteNetworkTraceSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForStartWebSiteNetworkTraceSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "StartWebSiteNetworkTraceSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForStartWebSiteNetworkTraceSlot prepares the StartWebSiteNetworkTraceSlot request. -func (c WebAppsClient) preparerForStartWebSiteNetworkTraceSlot(ctx context.Context, id SlotId, options StartWebSiteNetworkTraceSlotOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/networkTrace/start", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForStartWebSiteNetworkTraceSlot handles the response to the StartWebSiteNetworkTraceSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForStartWebSiteNetworkTraceSlot(resp *http.Response) (result StartWebSiteNetworkTraceSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_stop.go b/resource-manager/web/2022-09-01/webapps/method_stop.go new file mode 100644 index 00000000000..bff3d9badd0 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_stop.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "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 StopOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Stop ... +func (c WebAppsClient) Stop(ctx context.Context, id SiteId) (result StopOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/stop", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_stop_autorest.go b/resource-manager/web/2022-09-01/webapps/method_stop_autorest.go deleted file mode 100644 index f2a28d5c5c4..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_stop_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type StopOperationResponse struct { - HttpResponse *http.Response -} - -// Stop ... -func (c WebAppsClient) Stop(ctx context.Context, id SiteId) (result StopOperationResponse, err error) { - req, err := c.preparerForStop(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "Stop", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "Stop", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForStop(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "Stop", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForStop prepares the Stop request. -func (c WebAppsClient) preparerForStop(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/stop", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForStop handles the response to the Stop request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForStop(resp *http.Response) (result StopOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_stopcontinuouswebjob.go b/resource-manager/web/2022-09-01/webapps/method_stopcontinuouswebjob.go new file mode 100644 index 00000000000..1b88d2d1f1c --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_stopcontinuouswebjob.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "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 StopContinuousWebJobOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// StopContinuousWebJob ... +func (c WebAppsClient) StopContinuousWebJob(ctx context.Context, id ContinuousWebJobId) (result StopContinuousWebJobOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/stop", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_stopcontinuouswebjob_autorest.go b/resource-manager/web/2022-09-01/webapps/method_stopcontinuouswebjob_autorest.go deleted file mode 100644 index 0df4e8315ed..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_stopcontinuouswebjob_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type StopContinuousWebJobOperationResponse struct { - HttpResponse *http.Response -} - -// StopContinuousWebJob ... -func (c WebAppsClient) StopContinuousWebJob(ctx context.Context, id ContinuousWebJobId) (result StopContinuousWebJobOperationResponse, err error) { - req, err := c.preparerForStopContinuousWebJob(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "StopContinuousWebJob", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "StopContinuousWebJob", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForStopContinuousWebJob(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "StopContinuousWebJob", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForStopContinuousWebJob prepares the StopContinuousWebJob request. -func (c WebAppsClient) preparerForStopContinuousWebJob(ctx context.Context, id ContinuousWebJobId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/stop", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForStopContinuousWebJob handles the response to the StopContinuousWebJob request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForStopContinuousWebJob(resp *http.Response) (result StopContinuousWebJobOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_stopcontinuouswebjobslot.go b/resource-manager/web/2022-09-01/webapps/method_stopcontinuouswebjobslot.go new file mode 100644 index 00000000000..0dfd9c75045 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_stopcontinuouswebjobslot.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "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 StopContinuousWebJobSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// StopContinuousWebJobSlot ... +func (c WebAppsClient) StopContinuousWebJobSlot(ctx context.Context, id SlotContinuousWebJobId) (result StopContinuousWebJobSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/stop", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_stopcontinuouswebjobslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_stopcontinuouswebjobslot_autorest.go deleted file mode 100644 index b45037c8559..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_stopcontinuouswebjobslot_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type StopContinuousWebJobSlotOperationResponse struct { - HttpResponse *http.Response -} - -// StopContinuousWebJobSlot ... -func (c WebAppsClient) StopContinuousWebJobSlot(ctx context.Context, id SlotContinuousWebJobId) (result StopContinuousWebJobSlotOperationResponse, err error) { - req, err := c.preparerForStopContinuousWebJobSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "StopContinuousWebJobSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "StopContinuousWebJobSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForStopContinuousWebJobSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "StopContinuousWebJobSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForStopContinuousWebJobSlot prepares the StopContinuousWebJobSlot request. -func (c WebAppsClient) preparerForStopContinuousWebJobSlot(ctx context.Context, id SlotContinuousWebJobId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/stop", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForStopContinuousWebJobSlot handles the response to the StopContinuousWebJobSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForStopContinuousWebJobSlot(resp *http.Response) (result StopContinuousWebJobSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_stopnetworktrace.go b/resource-manager/web/2022-09-01/webapps/method_stopnetworktrace.go new file mode 100644 index 00000000000..bdba6b5f14f --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_stopnetworktrace.go @@ -0,0 +1,48 @@ +package webapps + +import ( + "context" + "fmt" + "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 StopNetworkTraceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// StopNetworkTrace ... +func (c WebAppsClient) StopNetworkTrace(ctx context.Context, id SiteId) (result StopNetworkTraceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/stopNetworkTrace", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_stopnetworktrace_autorest.go b/resource-manager/web/2022-09-01/webapps/method_stopnetworktrace_autorest.go deleted file mode 100644 index 4d0c53d8fb8..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_stopnetworktrace_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type StopNetworkTraceOperationResponse struct { - HttpResponse *http.Response -} - -// StopNetworkTrace ... -func (c WebAppsClient) StopNetworkTrace(ctx context.Context, id SiteId) (result StopNetworkTraceOperationResponse, err error) { - req, err := c.preparerForStopNetworkTrace(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "StopNetworkTrace", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "StopNetworkTrace", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForStopNetworkTrace(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "StopNetworkTrace", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForStopNetworkTrace prepares the StopNetworkTrace request. -func (c WebAppsClient) preparerForStopNetworkTrace(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/stopNetworkTrace", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForStopNetworkTrace handles the response to the StopNetworkTrace request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForStopNetworkTrace(resp *http.Response) (result StopNetworkTraceOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_stopnetworktraceslot.go b/resource-manager/web/2022-09-01/webapps/method_stopnetworktraceslot.go new file mode 100644 index 00000000000..7ec90d71db9 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_stopnetworktraceslot.go @@ -0,0 +1,48 @@ +package webapps + +import ( + "context" + "fmt" + "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 StopNetworkTraceSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// StopNetworkTraceSlot ... +func (c WebAppsClient) StopNetworkTraceSlot(ctx context.Context, id SlotId) (result StopNetworkTraceSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/stopNetworkTrace", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_stopnetworktraceslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_stopnetworktraceslot_autorest.go deleted file mode 100644 index 5ce78d087b2..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_stopnetworktraceslot_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type StopNetworkTraceSlotOperationResponse struct { - HttpResponse *http.Response -} - -// StopNetworkTraceSlot ... -func (c WebAppsClient) StopNetworkTraceSlot(ctx context.Context, id SlotId) (result StopNetworkTraceSlotOperationResponse, err error) { - req, err := c.preparerForStopNetworkTraceSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "StopNetworkTraceSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "StopNetworkTraceSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForStopNetworkTraceSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "StopNetworkTraceSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForStopNetworkTraceSlot prepares the StopNetworkTraceSlot request. -func (c WebAppsClient) preparerForStopNetworkTraceSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/stopNetworkTrace", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForStopNetworkTraceSlot handles the response to the StopNetworkTraceSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForStopNetworkTraceSlot(resp *http.Response) (result StopNetworkTraceSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_stopslot.go b/resource-manager/web/2022-09-01/webapps/method_stopslot.go new file mode 100644 index 00000000000..23522df8af8 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_stopslot.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "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 StopSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// StopSlot ... +func (c WebAppsClient) StopSlot(ctx context.Context, id SlotId) (result StopSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/stop", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_stopslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_stopslot_autorest.go deleted file mode 100644 index ba89cb7fcd2..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_stopslot_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type StopSlotOperationResponse struct { - HttpResponse *http.Response -} - -// StopSlot ... -func (c WebAppsClient) StopSlot(ctx context.Context, id SlotId) (result StopSlotOperationResponse, err error) { - req, err := c.preparerForStopSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "StopSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "StopSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForStopSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "StopSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForStopSlot prepares the StopSlot request. -func (c WebAppsClient) preparerForStopSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/stop", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForStopSlot handles the response to the StopSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForStopSlot(resp *http.Response) (result StopSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_stopwebsitenetworktrace.go b/resource-manager/web/2022-09-01/webapps/method_stopwebsitenetworktrace.go new file mode 100644 index 00000000000..53f895a0ab9 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_stopwebsitenetworktrace.go @@ -0,0 +1,48 @@ +package webapps + +import ( + "context" + "fmt" + "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 StopWebSiteNetworkTraceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// StopWebSiteNetworkTrace ... +func (c WebAppsClient) StopWebSiteNetworkTrace(ctx context.Context, id SiteId) (result StopWebSiteNetworkTraceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/networkTrace/stop", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_stopwebsitenetworktrace_autorest.go b/resource-manager/web/2022-09-01/webapps/method_stopwebsitenetworktrace_autorest.go deleted file mode 100644 index db63f9ad746..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_stopwebsitenetworktrace_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type StopWebSiteNetworkTraceOperationResponse struct { - HttpResponse *http.Response -} - -// StopWebSiteNetworkTrace ... -func (c WebAppsClient) StopWebSiteNetworkTrace(ctx context.Context, id SiteId) (result StopWebSiteNetworkTraceOperationResponse, err error) { - req, err := c.preparerForStopWebSiteNetworkTrace(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "StopWebSiteNetworkTrace", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "StopWebSiteNetworkTrace", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForStopWebSiteNetworkTrace(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "StopWebSiteNetworkTrace", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForStopWebSiteNetworkTrace prepares the StopWebSiteNetworkTrace request. -func (c WebAppsClient) preparerForStopWebSiteNetworkTrace(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/networkTrace/stop", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForStopWebSiteNetworkTrace handles the response to the StopWebSiteNetworkTrace request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForStopWebSiteNetworkTrace(resp *http.Response) (result StopWebSiteNetworkTraceOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_stopwebsitenetworktraceslot.go b/resource-manager/web/2022-09-01/webapps/method_stopwebsitenetworktraceslot.go new file mode 100644 index 00000000000..d7d811a9a25 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_stopwebsitenetworktraceslot.go @@ -0,0 +1,48 @@ +package webapps + +import ( + "context" + "fmt" + "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 StopWebSiteNetworkTraceSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// StopWebSiteNetworkTraceSlot ... +func (c WebAppsClient) StopWebSiteNetworkTraceSlot(ctx context.Context, id SlotId) (result StopWebSiteNetworkTraceSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/networkTrace/stop", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_stopwebsitenetworktraceslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_stopwebsitenetworktraceslot_autorest.go deleted file mode 100644 index f30be2a95c1..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_stopwebsitenetworktraceslot_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type StopWebSiteNetworkTraceSlotOperationResponse struct { - HttpResponse *http.Response -} - -// StopWebSiteNetworkTraceSlot ... -func (c WebAppsClient) StopWebSiteNetworkTraceSlot(ctx context.Context, id SlotId) (result StopWebSiteNetworkTraceSlotOperationResponse, err error) { - req, err := c.preparerForStopWebSiteNetworkTraceSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "StopWebSiteNetworkTraceSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "StopWebSiteNetworkTraceSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForStopWebSiteNetworkTraceSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "StopWebSiteNetworkTraceSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForStopWebSiteNetworkTraceSlot prepares the StopWebSiteNetworkTraceSlot request. -func (c WebAppsClient) preparerForStopWebSiteNetworkTraceSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/networkTrace/stop", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForStopWebSiteNetworkTraceSlot handles the response to the StopWebSiteNetworkTraceSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForStopWebSiteNetworkTraceSlot(resp *http.Response) (result StopWebSiteNetworkTraceSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_swapslotslot.go b/resource-manager/web/2022-09-01/webapps/method_swapslotslot.go new file mode 100644 index 00000000000..d6fa180a605 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_swapslotslot.go @@ -0,0 +1,74 @@ +package webapps + +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 SwapSlotSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// SwapSlotSlot ... +func (c WebAppsClient) SwapSlotSlot(ctx context.Context, id SlotId, input CsmSlotEntity) (result SwapSlotSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/slotsswap", 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 +} + +// SwapSlotSlotThenPoll performs SwapSlotSlot then polls until it's completed +func (c WebAppsClient) SwapSlotSlotThenPoll(ctx context.Context, id SlotId, input CsmSlotEntity) error { + result, err := c.SwapSlotSlot(ctx, id, input) + if err != nil { + return fmt.Errorf("performing SwapSlotSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SwapSlotSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/webapps/method_swapslotslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_swapslotslot_autorest.go deleted file mode 100644 index 9e9c4e61f28..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_swapslotslot_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type SwapSlotSlotOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// SwapSlotSlot ... -func (c WebAppsClient) SwapSlotSlot(ctx context.Context, id SlotId, input CsmSlotEntity) (result SwapSlotSlotOperationResponse, err error) { - req, err := c.preparerForSwapSlotSlot(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "SwapSlotSlot", nil, "Failure preparing request") - return - } - - result, err = c.senderForSwapSlotSlot(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "SwapSlotSlot", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// SwapSlotSlotThenPoll performs SwapSlotSlot then polls until it's completed -func (c WebAppsClient) SwapSlotSlotThenPoll(ctx context.Context, id SlotId, input CsmSlotEntity) error { - result, err := c.SwapSlotSlot(ctx, id, input) - if err != nil { - return fmt.Errorf("performing SwapSlotSlot: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after SwapSlotSlot: %+v", err) - } - - return nil -} - -// preparerForSwapSlotSlot prepares the SwapSlotSlot request. -func (c WebAppsClient) preparerForSwapSlotSlot(ctx context.Context, id SlotId, input CsmSlotEntity) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/slotsswap", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForSwapSlotSlot sends the SwapSlotSlot request. The method will close the -// http.Response Body if it receives an error. -func (c WebAppsClient) senderForSwapSlotSlot(ctx context.Context, req *http.Request) (future SwapSlotSlotOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_swapslotwithproduction.go b/resource-manager/web/2022-09-01/webapps/method_swapslotwithproduction.go new file mode 100644 index 00000000000..466ffecd900 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_swapslotwithproduction.go @@ -0,0 +1,74 @@ +package webapps + +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 SwapSlotWithProductionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// SwapSlotWithProduction ... +func (c WebAppsClient) SwapSlotWithProduction(ctx context.Context, id SiteId, input CsmSlotEntity) (result SwapSlotWithProductionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/slotsswap", 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 +} + +// SwapSlotWithProductionThenPoll performs SwapSlotWithProduction then polls until it's completed +func (c WebAppsClient) SwapSlotWithProductionThenPoll(ctx context.Context, id SiteId, input CsmSlotEntity) error { + result, err := c.SwapSlotWithProduction(ctx, id, input) + if err != nil { + return fmt.Errorf("performing SwapSlotWithProduction: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SwapSlotWithProduction: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/webapps/method_swapslotwithproduction_autorest.go b/resource-manager/web/2022-09-01/webapps/method_swapslotwithproduction_autorest.go deleted file mode 100644 index 27a626ab43a..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_swapslotwithproduction_autorest.go +++ /dev/null @@ -1,79 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type SwapSlotWithProductionOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// SwapSlotWithProduction ... -func (c WebAppsClient) SwapSlotWithProduction(ctx context.Context, id SiteId, input CsmSlotEntity) (result SwapSlotWithProductionOperationResponse, err error) { - req, err := c.preparerForSwapSlotWithProduction(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "SwapSlotWithProduction", nil, "Failure preparing request") - return - } - - result, err = c.senderForSwapSlotWithProduction(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "SwapSlotWithProduction", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// SwapSlotWithProductionThenPoll performs SwapSlotWithProduction then polls until it's completed -func (c WebAppsClient) SwapSlotWithProductionThenPoll(ctx context.Context, id SiteId, input CsmSlotEntity) error { - result, err := c.SwapSlotWithProduction(ctx, id, input) - if err != nil { - return fmt.Errorf("performing SwapSlotWithProduction: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after SwapSlotWithProduction: %+v", err) - } - - return nil -} - -// preparerForSwapSlotWithProduction prepares the SwapSlotWithProduction request. -func (c WebAppsClient) preparerForSwapSlotWithProduction(ctx context.Context, id SiteId, input CsmSlotEntity) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/slotsswap", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForSwapSlotWithProduction sends the SwapSlotWithProduction request. The method will close the -// http.Response Body if it receives an error. -func (c WebAppsClient) senderForSwapSlotWithProduction(ctx context.Context, req *http.Request) (future SwapSlotWithProductionOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_syncfunctions.go b/resource-manager/web/2022-09-01/webapps/method_syncfunctions.go new file mode 100644 index 00000000000..e36b77a32a8 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_syncfunctions.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "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 SyncFunctionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// SyncFunctions ... +func (c WebAppsClient) SyncFunctions(ctx context.Context, id SiteId) (result SyncFunctionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/host/default/sync", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_syncfunctions_autorest.go b/resource-manager/web/2022-09-01/webapps/method_syncfunctions_autorest.go deleted file mode 100644 index 2f374bb0ee3..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_syncfunctions_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type SyncFunctionsOperationResponse struct { - HttpResponse *http.Response -} - -// SyncFunctions ... -func (c WebAppsClient) SyncFunctions(ctx context.Context, id SiteId) (result SyncFunctionsOperationResponse, err error) { - req, err := c.preparerForSyncFunctions(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "SyncFunctions", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "SyncFunctions", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForSyncFunctions(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "SyncFunctions", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForSyncFunctions prepares the SyncFunctions request. -func (c WebAppsClient) preparerForSyncFunctions(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/host/default/sync", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForSyncFunctions handles the response to the SyncFunctions request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForSyncFunctions(resp *http.Response) (result SyncFunctionsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_syncfunctionsslot.go b/resource-manager/web/2022-09-01/webapps/method_syncfunctionsslot.go new file mode 100644 index 00000000000..84b6664a58a --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_syncfunctionsslot.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "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 SyncFunctionsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// SyncFunctionsSlot ... +func (c WebAppsClient) SyncFunctionsSlot(ctx context.Context, id SlotId) (result SyncFunctionsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/host/default/sync", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_syncfunctionsslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_syncfunctionsslot_autorest.go deleted file mode 100644 index 1282c57276c..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_syncfunctionsslot_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type SyncFunctionsSlotOperationResponse struct { - HttpResponse *http.Response -} - -// SyncFunctionsSlot ... -func (c WebAppsClient) SyncFunctionsSlot(ctx context.Context, id SlotId) (result SyncFunctionsSlotOperationResponse, err error) { - req, err := c.preparerForSyncFunctionsSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "SyncFunctionsSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "SyncFunctionsSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForSyncFunctionsSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "SyncFunctionsSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForSyncFunctionsSlot prepares the SyncFunctionsSlot request. -func (c WebAppsClient) preparerForSyncFunctionsSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/host/default/sync", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForSyncFunctionsSlot handles the response to the SyncFunctionsSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForSyncFunctionsSlot(resp *http.Response) (result SyncFunctionsSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_syncfunctiontriggers.go b/resource-manager/web/2022-09-01/webapps/method_syncfunctiontriggers.go new file mode 100644 index 00000000000..56f03e96318 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_syncfunctiontriggers.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "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 SyncFunctionTriggersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// SyncFunctionTriggers ... +func (c WebAppsClient) SyncFunctionTriggers(ctx context.Context, id SiteId) (result SyncFunctionTriggersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/syncfunctiontriggers", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_syncfunctiontriggers_autorest.go b/resource-manager/web/2022-09-01/webapps/method_syncfunctiontriggers_autorest.go deleted file mode 100644 index 45bb507ebd0..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_syncfunctiontriggers_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type SyncFunctionTriggersOperationResponse struct { - HttpResponse *http.Response -} - -// SyncFunctionTriggers ... -func (c WebAppsClient) SyncFunctionTriggers(ctx context.Context, id SiteId) (result SyncFunctionTriggersOperationResponse, err error) { - req, err := c.preparerForSyncFunctionTriggers(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "SyncFunctionTriggers", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "SyncFunctionTriggers", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForSyncFunctionTriggers(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "SyncFunctionTriggers", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForSyncFunctionTriggers prepares the SyncFunctionTriggers request. -func (c WebAppsClient) preparerForSyncFunctionTriggers(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/syncfunctiontriggers", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForSyncFunctionTriggers handles the response to the SyncFunctionTriggers request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForSyncFunctionTriggers(resp *http.Response) (result SyncFunctionTriggersOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_syncfunctiontriggersslot.go b/resource-manager/web/2022-09-01/webapps/method_syncfunctiontriggersslot.go new file mode 100644 index 00000000000..92b3ab00183 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_syncfunctiontriggersslot.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "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 SyncFunctionTriggersSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// SyncFunctionTriggersSlot ... +func (c WebAppsClient) SyncFunctionTriggersSlot(ctx context.Context, id SlotId) (result SyncFunctionTriggersSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/syncfunctiontriggers", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_syncfunctiontriggersslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_syncfunctiontriggersslot_autorest.go deleted file mode 100644 index 60a19f00fb7..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_syncfunctiontriggersslot_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type SyncFunctionTriggersSlotOperationResponse struct { - HttpResponse *http.Response -} - -// SyncFunctionTriggersSlot ... -func (c WebAppsClient) SyncFunctionTriggersSlot(ctx context.Context, id SlotId) (result SyncFunctionTriggersSlotOperationResponse, err error) { - req, err := c.preparerForSyncFunctionTriggersSlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "SyncFunctionTriggersSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "SyncFunctionTriggersSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForSyncFunctionTriggersSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "SyncFunctionTriggersSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForSyncFunctionTriggersSlot prepares the SyncFunctionTriggersSlot request. -func (c WebAppsClient) preparerForSyncFunctionTriggersSlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/syncfunctiontriggers", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForSyncFunctionTriggersSlot handles the response to the SyncFunctionTriggersSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForSyncFunctionTriggersSlot(resp *http.Response) (result SyncFunctionTriggersSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_syncrepository.go b/resource-manager/web/2022-09-01/webapps/method_syncrepository.go new file mode 100644 index 00000000000..1fe9ffacd08 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_syncrepository.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "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 SyncRepositoryOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// SyncRepository ... +func (c WebAppsClient) SyncRepository(ctx context.Context, id SiteId) (result SyncRepositoryOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/sync", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_syncrepository_autorest.go b/resource-manager/web/2022-09-01/webapps/method_syncrepository_autorest.go deleted file mode 100644 index 1047fe6af9a..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_syncrepository_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type SyncRepositoryOperationResponse struct { - HttpResponse *http.Response -} - -// SyncRepository ... -func (c WebAppsClient) SyncRepository(ctx context.Context, id SiteId) (result SyncRepositoryOperationResponse, err error) { - req, err := c.preparerForSyncRepository(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "SyncRepository", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "SyncRepository", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForSyncRepository(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "SyncRepository", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForSyncRepository prepares the SyncRepository request. -func (c WebAppsClient) preparerForSyncRepository(ctx context.Context, id SiteId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/sync", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForSyncRepository handles the response to the SyncRepository request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForSyncRepository(resp *http.Response) (result SyncRepositoryOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_syncrepositoryslot.go b/resource-manager/web/2022-09-01/webapps/method_syncrepositoryslot.go new file mode 100644 index 00000000000..a7182d25f96 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_syncrepositoryslot.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "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 SyncRepositorySlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// SyncRepositorySlot ... +func (c WebAppsClient) SyncRepositorySlot(ctx context.Context, id SlotId) (result SyncRepositorySlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/sync", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/webapps/method_syncrepositoryslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_syncrepositoryslot_autorest.go deleted file mode 100644 index 007fa214e70..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_syncrepositoryslot_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type SyncRepositorySlotOperationResponse struct { - HttpResponse *http.Response -} - -// SyncRepositorySlot ... -func (c WebAppsClient) SyncRepositorySlot(ctx context.Context, id SlotId) (result SyncRepositorySlotOperationResponse, err error) { - req, err := c.preparerForSyncRepositorySlot(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "SyncRepositorySlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "SyncRepositorySlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForSyncRepositorySlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "SyncRepositorySlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForSyncRepositorySlot prepares the SyncRepositorySlot request. -func (c WebAppsClient) preparerForSyncRepositorySlot(ctx context.Context, id SlotId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/sync", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForSyncRepositorySlot handles the response to the SyncRepositorySlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForSyncRepositorySlot(resp *http.Response) (result SyncRepositorySlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_update.go b/resource-manager/web/2022-09-01/webapps/method_update.go new file mode 100644 index 00000000000..5969ff41770 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_update.go @@ -0,0 +1,56 @@ +package webapps + +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 UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Site +} + +// Update ... +func (c WebAppsClient) Update(ctx context.Context, id SiteId, input SitePatchResource) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_update_autorest.go b/resource-manager/web/2022-09-01/webapps/method_update_autorest.go deleted file mode 100644 index 8d42458d695..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_update_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateOperationResponse struct { - HttpResponse *http.Response - Model *Site -} - -// Update ... -func (c WebAppsClient) Update(ctx context.Context, id SiteId, input SitePatchResource) (result UpdateOperationResponse, err error) { - req, err := c.preparerForUpdate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "Update", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "Update", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "Update", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdate prepares the Update request. -func (c WebAppsClient) preparerForUpdate(ctx context.Context, id SiteId, input SitePatchResource) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdate handles the response to the Update request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForUpdate(resp *http.Response) (result UpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_updateapplicationsettings.go b/resource-manager/web/2022-09-01/webapps/method_updateapplicationsettings.go new file mode 100644 index 00000000000..9ae8ff576b5 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_updateapplicationsettings.go @@ -0,0 +1,56 @@ +package webapps + +import ( + "context" + "fmt" + "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 UpdateApplicationSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// UpdateApplicationSettings ... +func (c WebAppsClient) UpdateApplicationSettings(ctx context.Context, id SiteId, input StringDictionary) (result UpdateApplicationSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/appSettings", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_updateapplicationsettings_autorest.go b/resource-manager/web/2022-09-01/webapps/method_updateapplicationsettings_autorest.go deleted file mode 100644 index d7b257d2a98..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_updateapplicationsettings_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateApplicationSettingsOperationResponse struct { - HttpResponse *http.Response - Model *StringDictionary -} - -// UpdateApplicationSettings ... -func (c WebAppsClient) UpdateApplicationSettings(ctx context.Context, id SiteId, input StringDictionary) (result UpdateApplicationSettingsOperationResponse, err error) { - req, err := c.preparerForUpdateApplicationSettings(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateApplicationSettings", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateApplicationSettings", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateApplicationSettings(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateApplicationSettings", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateApplicationSettings prepares the UpdateApplicationSettings request. -func (c WebAppsClient) preparerForUpdateApplicationSettings(ctx context.Context, id SiteId, input StringDictionary) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/appSettings", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateApplicationSettings handles the response to the UpdateApplicationSettings request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForUpdateApplicationSettings(resp *http.Response) (result UpdateApplicationSettingsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_updateapplicationsettingsslot.go b/resource-manager/web/2022-09-01/webapps/method_updateapplicationsettingsslot.go new file mode 100644 index 00000000000..8848a7383a5 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_updateapplicationsettingsslot.go @@ -0,0 +1,56 @@ +package webapps + +import ( + "context" + "fmt" + "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 UpdateApplicationSettingsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// UpdateApplicationSettingsSlot ... +func (c WebAppsClient) UpdateApplicationSettingsSlot(ctx context.Context, id SlotId, input StringDictionary) (result UpdateApplicationSettingsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/appSettings", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_updateapplicationsettingsslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_updateapplicationsettingsslot_autorest.go deleted file mode 100644 index 0189f937d2a..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_updateapplicationsettingsslot_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateApplicationSettingsSlotOperationResponse struct { - HttpResponse *http.Response - Model *StringDictionary -} - -// UpdateApplicationSettingsSlot ... -func (c WebAppsClient) UpdateApplicationSettingsSlot(ctx context.Context, id SlotId, input StringDictionary) (result UpdateApplicationSettingsSlotOperationResponse, err error) { - req, err := c.preparerForUpdateApplicationSettingsSlot(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateApplicationSettingsSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateApplicationSettingsSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateApplicationSettingsSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateApplicationSettingsSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateApplicationSettingsSlot prepares the UpdateApplicationSettingsSlot request. -func (c WebAppsClient) preparerForUpdateApplicationSettingsSlot(ctx context.Context, id SlotId, input StringDictionary) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/appSettings", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateApplicationSettingsSlot handles the response to the UpdateApplicationSettingsSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForUpdateApplicationSettingsSlot(resp *http.Response) (result UpdateApplicationSettingsSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_updateauthsettings.go b/resource-manager/web/2022-09-01/webapps/method_updateauthsettings.go new file mode 100644 index 00000000000..62d3bdb5ca4 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_updateauthsettings.go @@ -0,0 +1,56 @@ +package webapps + +import ( + "context" + "fmt" + "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 UpdateAuthSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteAuthSettings +} + +// UpdateAuthSettings ... +func (c WebAppsClient) UpdateAuthSettings(ctx context.Context, id SiteId, input SiteAuthSettings) (result UpdateAuthSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/authsettings", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_updateauthsettings_autorest.go b/resource-manager/web/2022-09-01/webapps/method_updateauthsettings_autorest.go deleted file mode 100644 index 30399c9cc30..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_updateauthsettings_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateAuthSettingsOperationResponse struct { - HttpResponse *http.Response - Model *SiteAuthSettings -} - -// UpdateAuthSettings ... -func (c WebAppsClient) UpdateAuthSettings(ctx context.Context, id SiteId, input SiteAuthSettings) (result UpdateAuthSettingsOperationResponse, err error) { - req, err := c.preparerForUpdateAuthSettings(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateAuthSettings", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateAuthSettings", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateAuthSettings(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateAuthSettings", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateAuthSettings prepares the UpdateAuthSettings request. -func (c WebAppsClient) preparerForUpdateAuthSettings(ctx context.Context, id SiteId, input SiteAuthSettings) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/authsettings", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateAuthSettings handles the response to the UpdateAuthSettings request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForUpdateAuthSettings(resp *http.Response) (result UpdateAuthSettingsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_updateauthsettingsslot.go b/resource-manager/web/2022-09-01/webapps/method_updateauthsettingsslot.go new file mode 100644 index 00000000000..dece652d764 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_updateauthsettingsslot.go @@ -0,0 +1,56 @@ +package webapps + +import ( + "context" + "fmt" + "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 UpdateAuthSettingsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteAuthSettings +} + +// UpdateAuthSettingsSlot ... +func (c WebAppsClient) UpdateAuthSettingsSlot(ctx context.Context, id SlotId, input SiteAuthSettings) (result UpdateAuthSettingsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/authsettings", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_updateauthsettingsslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_updateauthsettingsslot_autorest.go deleted file mode 100644 index 5f58726e903..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_updateauthsettingsslot_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateAuthSettingsSlotOperationResponse struct { - HttpResponse *http.Response - Model *SiteAuthSettings -} - -// UpdateAuthSettingsSlot ... -func (c WebAppsClient) UpdateAuthSettingsSlot(ctx context.Context, id SlotId, input SiteAuthSettings) (result UpdateAuthSettingsSlotOperationResponse, err error) { - req, err := c.preparerForUpdateAuthSettingsSlot(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateAuthSettingsSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateAuthSettingsSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateAuthSettingsSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateAuthSettingsSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateAuthSettingsSlot prepares the UpdateAuthSettingsSlot request. -func (c WebAppsClient) preparerForUpdateAuthSettingsSlot(ctx context.Context, id SlotId, input SiteAuthSettings) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/authsettings", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateAuthSettingsSlot handles the response to the UpdateAuthSettingsSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForUpdateAuthSettingsSlot(resp *http.Response) (result UpdateAuthSettingsSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_updateauthsettingsv2.go b/resource-manager/web/2022-09-01/webapps/method_updateauthsettingsv2.go new file mode 100644 index 00000000000..a1182eedf14 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_updateauthsettingsv2.go @@ -0,0 +1,56 @@ +package webapps + +import ( + "context" + "fmt" + "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 UpdateAuthSettingsV2OperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteAuthSettingsV2 +} + +// UpdateAuthSettingsV2 ... +func (c WebAppsClient) UpdateAuthSettingsV2(ctx context.Context, id SiteId, input SiteAuthSettingsV2) (result UpdateAuthSettingsV2OperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/authsettingsV2", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_updateauthsettingsv2_autorest.go b/resource-manager/web/2022-09-01/webapps/method_updateauthsettingsv2_autorest.go deleted file mode 100644 index 126e5b8b1a4..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_updateauthsettingsv2_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateAuthSettingsV2OperationResponse struct { - HttpResponse *http.Response - Model *SiteAuthSettingsV2 -} - -// UpdateAuthSettingsV2 ... -func (c WebAppsClient) UpdateAuthSettingsV2(ctx context.Context, id SiteId, input SiteAuthSettingsV2) (result UpdateAuthSettingsV2OperationResponse, err error) { - req, err := c.preparerForUpdateAuthSettingsV2(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateAuthSettingsV2", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateAuthSettingsV2", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateAuthSettingsV2(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateAuthSettingsV2", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateAuthSettingsV2 prepares the UpdateAuthSettingsV2 request. -func (c WebAppsClient) preparerForUpdateAuthSettingsV2(ctx context.Context, id SiteId, input SiteAuthSettingsV2) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/authsettingsV2", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateAuthSettingsV2 handles the response to the UpdateAuthSettingsV2 request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForUpdateAuthSettingsV2(resp *http.Response) (result UpdateAuthSettingsV2OperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_updateauthsettingsv2slot.go b/resource-manager/web/2022-09-01/webapps/method_updateauthsettingsv2slot.go new file mode 100644 index 00000000000..b1b9d38df68 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_updateauthsettingsv2slot.go @@ -0,0 +1,56 @@ +package webapps + +import ( + "context" + "fmt" + "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 UpdateAuthSettingsV2SlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteAuthSettingsV2 +} + +// UpdateAuthSettingsV2Slot ... +func (c WebAppsClient) UpdateAuthSettingsV2Slot(ctx context.Context, id SlotId, input SiteAuthSettingsV2) (result UpdateAuthSettingsV2SlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/authsettingsV2", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_updateauthsettingsv2slot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_updateauthsettingsv2slot_autorest.go deleted file mode 100644 index 003acca64b1..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_updateauthsettingsv2slot_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateAuthSettingsV2SlotOperationResponse struct { - HttpResponse *http.Response - Model *SiteAuthSettingsV2 -} - -// UpdateAuthSettingsV2Slot ... -func (c WebAppsClient) UpdateAuthSettingsV2Slot(ctx context.Context, id SlotId, input SiteAuthSettingsV2) (result UpdateAuthSettingsV2SlotOperationResponse, err error) { - req, err := c.preparerForUpdateAuthSettingsV2Slot(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateAuthSettingsV2Slot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateAuthSettingsV2Slot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateAuthSettingsV2Slot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateAuthSettingsV2Slot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateAuthSettingsV2Slot prepares the UpdateAuthSettingsV2Slot request. -func (c WebAppsClient) preparerForUpdateAuthSettingsV2Slot(ctx context.Context, id SlotId, input SiteAuthSettingsV2) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/authsettingsV2", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateAuthSettingsV2Slot handles the response to the UpdateAuthSettingsV2Slot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForUpdateAuthSettingsV2Slot(resp *http.Response) (result UpdateAuthSettingsV2SlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_updateazurestorageaccounts.go b/resource-manager/web/2022-09-01/webapps/method_updateazurestorageaccounts.go new file mode 100644 index 00000000000..9f0a435c92a --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_updateazurestorageaccounts.go @@ -0,0 +1,56 @@ +package webapps + +import ( + "context" + "fmt" + "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 UpdateAzureStorageAccountsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AzureStoragePropertyDictionaryResource +} + +// UpdateAzureStorageAccounts ... +func (c WebAppsClient) UpdateAzureStorageAccounts(ctx context.Context, id SiteId, input AzureStoragePropertyDictionaryResource) (result UpdateAzureStorageAccountsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/azurestorageaccounts", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_updateazurestorageaccounts_autorest.go b/resource-manager/web/2022-09-01/webapps/method_updateazurestorageaccounts_autorest.go deleted file mode 100644 index 768294d21af..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_updateazurestorageaccounts_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateAzureStorageAccountsOperationResponse struct { - HttpResponse *http.Response - Model *AzureStoragePropertyDictionaryResource -} - -// UpdateAzureStorageAccounts ... -func (c WebAppsClient) UpdateAzureStorageAccounts(ctx context.Context, id SiteId, input AzureStoragePropertyDictionaryResource) (result UpdateAzureStorageAccountsOperationResponse, err error) { - req, err := c.preparerForUpdateAzureStorageAccounts(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateAzureStorageAccounts", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateAzureStorageAccounts", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateAzureStorageAccounts(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateAzureStorageAccounts", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateAzureStorageAccounts prepares the UpdateAzureStorageAccounts request. -func (c WebAppsClient) preparerForUpdateAzureStorageAccounts(ctx context.Context, id SiteId, input AzureStoragePropertyDictionaryResource) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/azurestorageaccounts", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateAzureStorageAccounts handles the response to the UpdateAzureStorageAccounts request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForUpdateAzureStorageAccounts(resp *http.Response) (result UpdateAzureStorageAccountsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_updateazurestorageaccountsslot.go b/resource-manager/web/2022-09-01/webapps/method_updateazurestorageaccountsslot.go new file mode 100644 index 00000000000..865042eff1d --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_updateazurestorageaccountsslot.go @@ -0,0 +1,56 @@ +package webapps + +import ( + "context" + "fmt" + "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 UpdateAzureStorageAccountsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AzureStoragePropertyDictionaryResource +} + +// UpdateAzureStorageAccountsSlot ... +func (c WebAppsClient) UpdateAzureStorageAccountsSlot(ctx context.Context, id SlotId, input AzureStoragePropertyDictionaryResource) (result UpdateAzureStorageAccountsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/azurestorageaccounts", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_updateazurestorageaccountsslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_updateazurestorageaccountsslot_autorest.go deleted file mode 100644 index 36c21d7bd10..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_updateazurestorageaccountsslot_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateAzureStorageAccountsSlotOperationResponse struct { - HttpResponse *http.Response - Model *AzureStoragePropertyDictionaryResource -} - -// UpdateAzureStorageAccountsSlot ... -func (c WebAppsClient) UpdateAzureStorageAccountsSlot(ctx context.Context, id SlotId, input AzureStoragePropertyDictionaryResource) (result UpdateAzureStorageAccountsSlotOperationResponse, err error) { - req, err := c.preparerForUpdateAzureStorageAccountsSlot(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateAzureStorageAccountsSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateAzureStorageAccountsSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateAzureStorageAccountsSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateAzureStorageAccountsSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateAzureStorageAccountsSlot prepares the UpdateAzureStorageAccountsSlot request. -func (c WebAppsClient) preparerForUpdateAzureStorageAccountsSlot(ctx context.Context, id SlotId, input AzureStoragePropertyDictionaryResource) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/azurestorageaccounts", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateAzureStorageAccountsSlot handles the response to the UpdateAzureStorageAccountsSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForUpdateAzureStorageAccountsSlot(resp *http.Response) (result UpdateAzureStorageAccountsSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_updatebackupconfiguration.go b/resource-manager/web/2022-09-01/webapps/method_updatebackupconfiguration.go new file mode 100644 index 00000000000..04670641204 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_updatebackupconfiguration.go @@ -0,0 +1,56 @@ +package webapps + +import ( + "context" + "fmt" + "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 UpdateBackupConfigurationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BackupRequest +} + +// UpdateBackupConfiguration ... +func (c WebAppsClient) UpdateBackupConfiguration(ctx context.Context, id SiteId, input BackupRequest) (result UpdateBackupConfigurationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/backup", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_updatebackupconfiguration_autorest.go b/resource-manager/web/2022-09-01/webapps/method_updatebackupconfiguration_autorest.go deleted file mode 100644 index 753bae13a2f..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_updatebackupconfiguration_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateBackupConfigurationOperationResponse struct { - HttpResponse *http.Response - Model *BackupRequest -} - -// UpdateBackupConfiguration ... -func (c WebAppsClient) UpdateBackupConfiguration(ctx context.Context, id SiteId, input BackupRequest) (result UpdateBackupConfigurationOperationResponse, err error) { - req, err := c.preparerForUpdateBackupConfiguration(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateBackupConfiguration", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateBackupConfiguration", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateBackupConfiguration(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateBackupConfiguration", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateBackupConfiguration prepares the UpdateBackupConfiguration request. -func (c WebAppsClient) preparerForUpdateBackupConfiguration(ctx context.Context, id SiteId, input BackupRequest) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/backup", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateBackupConfiguration handles the response to the UpdateBackupConfiguration request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForUpdateBackupConfiguration(resp *http.Response) (result UpdateBackupConfigurationOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_updatebackupconfigurationslot.go b/resource-manager/web/2022-09-01/webapps/method_updatebackupconfigurationslot.go new file mode 100644 index 00000000000..6d218d6e339 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_updatebackupconfigurationslot.go @@ -0,0 +1,56 @@ +package webapps + +import ( + "context" + "fmt" + "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 UpdateBackupConfigurationSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BackupRequest +} + +// UpdateBackupConfigurationSlot ... +func (c WebAppsClient) UpdateBackupConfigurationSlot(ctx context.Context, id SlotId, input BackupRequest) (result UpdateBackupConfigurationSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/backup", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_updatebackupconfigurationslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_updatebackupconfigurationslot_autorest.go deleted file mode 100644 index 2a3cc60c342..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_updatebackupconfigurationslot_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateBackupConfigurationSlotOperationResponse struct { - HttpResponse *http.Response - Model *BackupRequest -} - -// UpdateBackupConfigurationSlot ... -func (c WebAppsClient) UpdateBackupConfigurationSlot(ctx context.Context, id SlotId, input BackupRequest) (result UpdateBackupConfigurationSlotOperationResponse, err error) { - req, err := c.preparerForUpdateBackupConfigurationSlot(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateBackupConfigurationSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateBackupConfigurationSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateBackupConfigurationSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateBackupConfigurationSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateBackupConfigurationSlot prepares the UpdateBackupConfigurationSlot request. -func (c WebAppsClient) preparerForUpdateBackupConfigurationSlot(ctx context.Context, id SlotId, input BackupRequest) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/backup", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateBackupConfigurationSlot handles the response to the UpdateBackupConfigurationSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForUpdateBackupConfigurationSlot(resp *http.Response) (result UpdateBackupConfigurationSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_updateconfiguration.go b/resource-manager/web/2022-09-01/webapps/method_updateconfiguration.go new file mode 100644 index 00000000000..4f7d8e746f4 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_updateconfiguration.go @@ -0,0 +1,56 @@ +package webapps + +import ( + "context" + "fmt" + "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 UpdateConfigurationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteConfigResource +} + +// UpdateConfiguration ... +func (c WebAppsClient) UpdateConfiguration(ctx context.Context, id SiteId, input SiteConfigResource) (result UpdateConfigurationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: fmt.Sprintf("%s/config/web", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_updateconfiguration_autorest.go b/resource-manager/web/2022-09-01/webapps/method_updateconfiguration_autorest.go deleted file mode 100644 index 281b1b2b98f..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_updateconfiguration_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateConfigurationOperationResponse struct { - HttpResponse *http.Response - Model *SiteConfigResource -} - -// UpdateConfiguration ... -func (c WebAppsClient) UpdateConfiguration(ctx context.Context, id SiteId, input SiteConfigResource) (result UpdateConfigurationOperationResponse, err error) { - req, err := c.preparerForUpdateConfiguration(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateConfiguration", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateConfiguration", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateConfiguration(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateConfiguration", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateConfiguration prepares the UpdateConfiguration request. -func (c WebAppsClient) preparerForUpdateConfiguration(ctx context.Context, id SiteId, input SiteConfigResource) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/web", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateConfiguration handles the response to the UpdateConfiguration request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForUpdateConfiguration(resp *http.Response) (result UpdateConfigurationOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_updateconfigurationslot.go b/resource-manager/web/2022-09-01/webapps/method_updateconfigurationslot.go new file mode 100644 index 00000000000..aa460f14f05 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_updateconfigurationslot.go @@ -0,0 +1,56 @@ +package webapps + +import ( + "context" + "fmt" + "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 UpdateConfigurationSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteConfigResource +} + +// UpdateConfigurationSlot ... +func (c WebAppsClient) UpdateConfigurationSlot(ctx context.Context, id SlotId, input SiteConfigResource) (result UpdateConfigurationSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: fmt.Sprintf("%s/config/web", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_updateconfigurationslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_updateconfigurationslot_autorest.go deleted file mode 100644 index 38ef4cec8fa..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_updateconfigurationslot_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateConfigurationSlotOperationResponse struct { - HttpResponse *http.Response - Model *SiteConfigResource -} - -// UpdateConfigurationSlot ... -func (c WebAppsClient) UpdateConfigurationSlot(ctx context.Context, id SlotId, input SiteConfigResource) (result UpdateConfigurationSlotOperationResponse, err error) { - req, err := c.preparerForUpdateConfigurationSlot(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateConfigurationSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateConfigurationSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateConfigurationSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateConfigurationSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateConfigurationSlot prepares the UpdateConfigurationSlot request. -func (c WebAppsClient) preparerForUpdateConfigurationSlot(ctx context.Context, id SlotId, input SiteConfigResource) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/web", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateConfigurationSlot handles the response to the UpdateConfigurationSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForUpdateConfigurationSlot(resp *http.Response) (result UpdateConfigurationSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_updateconnectionstrings.go b/resource-manager/web/2022-09-01/webapps/method_updateconnectionstrings.go new file mode 100644 index 00000000000..25178649a5a --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_updateconnectionstrings.go @@ -0,0 +1,56 @@ +package webapps + +import ( + "context" + "fmt" + "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 UpdateConnectionStringsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ConnectionStringDictionary +} + +// UpdateConnectionStrings ... +func (c WebAppsClient) UpdateConnectionStrings(ctx context.Context, id SiteId, input ConnectionStringDictionary) (result UpdateConnectionStringsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/connectionStrings", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_updateconnectionstrings_autorest.go b/resource-manager/web/2022-09-01/webapps/method_updateconnectionstrings_autorest.go deleted file mode 100644 index d5bb67c10e2..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_updateconnectionstrings_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateConnectionStringsOperationResponse struct { - HttpResponse *http.Response - Model *ConnectionStringDictionary -} - -// UpdateConnectionStrings ... -func (c WebAppsClient) UpdateConnectionStrings(ctx context.Context, id SiteId, input ConnectionStringDictionary) (result UpdateConnectionStringsOperationResponse, err error) { - req, err := c.preparerForUpdateConnectionStrings(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateConnectionStrings", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateConnectionStrings", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateConnectionStrings(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateConnectionStrings", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateConnectionStrings prepares the UpdateConnectionStrings request. -func (c WebAppsClient) preparerForUpdateConnectionStrings(ctx context.Context, id SiteId, input ConnectionStringDictionary) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/connectionStrings", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateConnectionStrings handles the response to the UpdateConnectionStrings request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForUpdateConnectionStrings(resp *http.Response) (result UpdateConnectionStringsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_updateconnectionstringsslot.go b/resource-manager/web/2022-09-01/webapps/method_updateconnectionstringsslot.go new file mode 100644 index 00000000000..9070818799d --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_updateconnectionstringsslot.go @@ -0,0 +1,56 @@ +package webapps + +import ( + "context" + "fmt" + "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 UpdateConnectionStringsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ConnectionStringDictionary +} + +// UpdateConnectionStringsSlot ... +func (c WebAppsClient) UpdateConnectionStringsSlot(ctx context.Context, id SlotId, input ConnectionStringDictionary) (result UpdateConnectionStringsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/connectionStrings", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_updateconnectionstringsslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_updateconnectionstringsslot_autorest.go deleted file mode 100644 index a8d2c0f97a8..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_updateconnectionstringsslot_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateConnectionStringsSlotOperationResponse struct { - HttpResponse *http.Response - Model *ConnectionStringDictionary -} - -// UpdateConnectionStringsSlot ... -func (c WebAppsClient) UpdateConnectionStringsSlot(ctx context.Context, id SlotId, input ConnectionStringDictionary) (result UpdateConnectionStringsSlotOperationResponse, err error) { - req, err := c.preparerForUpdateConnectionStringsSlot(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateConnectionStringsSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateConnectionStringsSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateConnectionStringsSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateConnectionStringsSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateConnectionStringsSlot prepares the UpdateConnectionStringsSlot request. -func (c WebAppsClient) preparerForUpdateConnectionStringsSlot(ctx context.Context, id SlotId, input ConnectionStringDictionary) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/connectionStrings", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateConnectionStringsSlot handles the response to the UpdateConnectionStringsSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForUpdateConnectionStringsSlot(resp *http.Response) (result UpdateConnectionStringsSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_updatediagnosticlogsconfig.go b/resource-manager/web/2022-09-01/webapps/method_updatediagnosticlogsconfig.go new file mode 100644 index 00000000000..1086c6f5478 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_updatediagnosticlogsconfig.go @@ -0,0 +1,56 @@ +package webapps + +import ( + "context" + "fmt" + "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 UpdateDiagnosticLogsConfigOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteLogsConfig +} + +// UpdateDiagnosticLogsConfig ... +func (c WebAppsClient) UpdateDiagnosticLogsConfig(ctx context.Context, id SiteId, input SiteLogsConfig) (result UpdateDiagnosticLogsConfigOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/logs", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_updatediagnosticlogsconfig_autorest.go b/resource-manager/web/2022-09-01/webapps/method_updatediagnosticlogsconfig_autorest.go deleted file mode 100644 index 536a09aa30b..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_updatediagnosticlogsconfig_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateDiagnosticLogsConfigOperationResponse struct { - HttpResponse *http.Response - Model *SiteLogsConfig -} - -// UpdateDiagnosticLogsConfig ... -func (c WebAppsClient) UpdateDiagnosticLogsConfig(ctx context.Context, id SiteId, input SiteLogsConfig) (result UpdateDiagnosticLogsConfigOperationResponse, err error) { - req, err := c.preparerForUpdateDiagnosticLogsConfig(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateDiagnosticLogsConfig", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateDiagnosticLogsConfig", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateDiagnosticLogsConfig(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateDiagnosticLogsConfig", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateDiagnosticLogsConfig prepares the UpdateDiagnosticLogsConfig request. -func (c WebAppsClient) preparerForUpdateDiagnosticLogsConfig(ctx context.Context, id SiteId, input SiteLogsConfig) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/logs", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateDiagnosticLogsConfig handles the response to the UpdateDiagnosticLogsConfig request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForUpdateDiagnosticLogsConfig(resp *http.Response) (result UpdateDiagnosticLogsConfigOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_updatediagnosticlogsconfigslot.go b/resource-manager/web/2022-09-01/webapps/method_updatediagnosticlogsconfigslot.go new file mode 100644 index 00000000000..9d42ee06e2f --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_updatediagnosticlogsconfigslot.go @@ -0,0 +1,56 @@ +package webapps + +import ( + "context" + "fmt" + "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 UpdateDiagnosticLogsConfigSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteLogsConfig +} + +// UpdateDiagnosticLogsConfigSlot ... +func (c WebAppsClient) UpdateDiagnosticLogsConfigSlot(ctx context.Context, id SlotId, input SiteLogsConfig) (result UpdateDiagnosticLogsConfigSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/logs", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_updatediagnosticlogsconfigslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_updatediagnosticlogsconfigslot_autorest.go deleted file mode 100644 index 2e72d5367dd..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_updatediagnosticlogsconfigslot_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateDiagnosticLogsConfigSlotOperationResponse struct { - HttpResponse *http.Response - Model *SiteLogsConfig -} - -// UpdateDiagnosticLogsConfigSlot ... -func (c WebAppsClient) UpdateDiagnosticLogsConfigSlot(ctx context.Context, id SlotId, input SiteLogsConfig) (result UpdateDiagnosticLogsConfigSlotOperationResponse, err error) { - req, err := c.preparerForUpdateDiagnosticLogsConfigSlot(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateDiagnosticLogsConfigSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateDiagnosticLogsConfigSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateDiagnosticLogsConfigSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateDiagnosticLogsConfigSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateDiagnosticLogsConfigSlot prepares the UpdateDiagnosticLogsConfigSlot request. -func (c WebAppsClient) preparerForUpdateDiagnosticLogsConfigSlot(ctx context.Context, id SlotId, input SiteLogsConfig) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/logs", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateDiagnosticLogsConfigSlot handles the response to the UpdateDiagnosticLogsConfigSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForUpdateDiagnosticLogsConfigSlot(resp *http.Response) (result UpdateDiagnosticLogsConfigSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_updatedomainownershipidentifier.go b/resource-manager/web/2022-09-01/webapps/method_updatedomainownershipidentifier.go new file mode 100644 index 00000000000..4275d789c62 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_updatedomainownershipidentifier.go @@ -0,0 +1,55 @@ +package webapps + +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 UpdateDomainOwnershipIdentifierOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Identifier +} + +// UpdateDomainOwnershipIdentifier ... +func (c WebAppsClient) UpdateDomainOwnershipIdentifier(ctx context.Context, id DomainOwnershipIdentifierId, input Identifier) (result UpdateDomainOwnershipIdentifierOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_updatedomainownershipidentifier_autorest.go b/resource-manager/web/2022-09-01/webapps/method_updatedomainownershipidentifier_autorest.go deleted file mode 100644 index c0d7bee378b..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_updatedomainownershipidentifier_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateDomainOwnershipIdentifierOperationResponse struct { - HttpResponse *http.Response - Model *Identifier -} - -// UpdateDomainOwnershipIdentifier ... -func (c WebAppsClient) UpdateDomainOwnershipIdentifier(ctx context.Context, id DomainOwnershipIdentifierId, input Identifier) (result UpdateDomainOwnershipIdentifierOperationResponse, err error) { - req, err := c.preparerForUpdateDomainOwnershipIdentifier(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateDomainOwnershipIdentifier", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateDomainOwnershipIdentifier", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateDomainOwnershipIdentifier(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateDomainOwnershipIdentifier", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateDomainOwnershipIdentifier prepares the UpdateDomainOwnershipIdentifier request. -func (c WebAppsClient) preparerForUpdateDomainOwnershipIdentifier(ctx context.Context, id DomainOwnershipIdentifierId, input Identifier) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateDomainOwnershipIdentifier handles the response to the UpdateDomainOwnershipIdentifier request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForUpdateDomainOwnershipIdentifier(resp *http.Response) (result UpdateDomainOwnershipIdentifierOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_updatedomainownershipidentifierslot.go b/resource-manager/web/2022-09-01/webapps/method_updatedomainownershipidentifierslot.go new file mode 100644 index 00000000000..c51396e4832 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_updatedomainownershipidentifierslot.go @@ -0,0 +1,55 @@ +package webapps + +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 UpdateDomainOwnershipIdentifierSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Identifier +} + +// UpdateDomainOwnershipIdentifierSlot ... +func (c WebAppsClient) UpdateDomainOwnershipIdentifierSlot(ctx context.Context, id SlotDomainOwnershipIdentifierId, input Identifier) (result UpdateDomainOwnershipIdentifierSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_updatedomainownershipidentifierslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_updatedomainownershipidentifierslot_autorest.go deleted file mode 100644 index 8734c65e7be..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_updatedomainownershipidentifierslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateDomainOwnershipIdentifierSlotOperationResponse struct { - HttpResponse *http.Response - Model *Identifier -} - -// UpdateDomainOwnershipIdentifierSlot ... -func (c WebAppsClient) UpdateDomainOwnershipIdentifierSlot(ctx context.Context, id SlotDomainOwnershipIdentifierId, input Identifier) (result UpdateDomainOwnershipIdentifierSlotOperationResponse, err error) { - req, err := c.preparerForUpdateDomainOwnershipIdentifierSlot(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateDomainOwnershipIdentifierSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateDomainOwnershipIdentifierSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateDomainOwnershipIdentifierSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateDomainOwnershipIdentifierSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateDomainOwnershipIdentifierSlot prepares the UpdateDomainOwnershipIdentifierSlot request. -func (c WebAppsClient) preparerForUpdateDomainOwnershipIdentifierSlot(ctx context.Context, id SlotDomainOwnershipIdentifierId, input Identifier) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateDomainOwnershipIdentifierSlot handles the response to the UpdateDomainOwnershipIdentifierSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForUpdateDomainOwnershipIdentifierSlot(resp *http.Response) (result UpdateDomainOwnershipIdentifierSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_updateftpallowed.go b/resource-manager/web/2022-09-01/webapps/method_updateftpallowed.go new file mode 100644 index 00000000000..c75f62ad2ef --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_updateftpallowed.go @@ -0,0 +1,56 @@ +package webapps + +import ( + "context" + "fmt" + "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 UpdateFtpAllowedOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CsmPublishingCredentialsPoliciesEntity +} + +// UpdateFtpAllowed ... +func (c WebAppsClient) UpdateFtpAllowed(ctx context.Context, id SiteId, input CsmPublishingCredentialsPoliciesEntity) (result UpdateFtpAllowedOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/basicPublishingCredentialsPolicies/ftp", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_updateftpallowed_autorest.go b/resource-manager/web/2022-09-01/webapps/method_updateftpallowed_autorest.go deleted file mode 100644 index aad023af4ff..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_updateftpallowed_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateFtpAllowedOperationResponse struct { - HttpResponse *http.Response - Model *CsmPublishingCredentialsPoliciesEntity -} - -// UpdateFtpAllowed ... -func (c WebAppsClient) UpdateFtpAllowed(ctx context.Context, id SiteId, input CsmPublishingCredentialsPoliciesEntity) (result UpdateFtpAllowedOperationResponse, err error) { - req, err := c.preparerForUpdateFtpAllowed(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateFtpAllowed", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateFtpAllowed", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateFtpAllowed(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateFtpAllowed", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateFtpAllowed prepares the UpdateFtpAllowed request. -func (c WebAppsClient) preparerForUpdateFtpAllowed(ctx context.Context, id SiteId, input CsmPublishingCredentialsPoliciesEntity) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/basicPublishingCredentialsPolicies/ftp", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateFtpAllowed handles the response to the UpdateFtpAllowed request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForUpdateFtpAllowed(resp *http.Response) (result UpdateFtpAllowedOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_updateftpallowedslot.go b/resource-manager/web/2022-09-01/webapps/method_updateftpallowedslot.go new file mode 100644 index 00000000000..ae4826e5777 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_updateftpallowedslot.go @@ -0,0 +1,56 @@ +package webapps + +import ( + "context" + "fmt" + "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 UpdateFtpAllowedSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CsmPublishingCredentialsPoliciesEntity +} + +// UpdateFtpAllowedSlot ... +func (c WebAppsClient) UpdateFtpAllowedSlot(ctx context.Context, id SlotId, input CsmPublishingCredentialsPoliciesEntity) (result UpdateFtpAllowedSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/basicPublishingCredentialsPolicies/ftp", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_updateftpallowedslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_updateftpallowedslot_autorest.go deleted file mode 100644 index 0b4d9c03de4..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_updateftpallowedslot_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateFtpAllowedSlotOperationResponse struct { - HttpResponse *http.Response - Model *CsmPublishingCredentialsPoliciesEntity -} - -// UpdateFtpAllowedSlot ... -func (c WebAppsClient) UpdateFtpAllowedSlot(ctx context.Context, id SlotId, input CsmPublishingCredentialsPoliciesEntity) (result UpdateFtpAllowedSlotOperationResponse, err error) { - req, err := c.preparerForUpdateFtpAllowedSlot(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateFtpAllowedSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateFtpAllowedSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateFtpAllowedSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateFtpAllowedSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateFtpAllowedSlot prepares the UpdateFtpAllowedSlot request. -func (c WebAppsClient) preparerForUpdateFtpAllowedSlot(ctx context.Context, id SlotId, input CsmPublishingCredentialsPoliciesEntity) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/basicPublishingCredentialsPolicies/ftp", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateFtpAllowedSlot handles the response to the UpdateFtpAllowedSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForUpdateFtpAllowedSlot(resp *http.Response) (result UpdateFtpAllowedSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_updatehybridconnection.go b/resource-manager/web/2022-09-01/webapps/method_updatehybridconnection.go new file mode 100644 index 00000000000..a6ec4c2c53c --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_updatehybridconnection.go @@ -0,0 +1,55 @@ +package webapps + +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 UpdateHybridConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HybridConnection +} + +// UpdateHybridConnection ... +func (c WebAppsClient) UpdateHybridConnection(ctx context.Context, id RelayId, input HybridConnection) (result UpdateHybridConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_updatehybridconnection_autorest.go b/resource-manager/web/2022-09-01/webapps/method_updatehybridconnection_autorest.go deleted file mode 100644 index a51a5781d21..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_updatehybridconnection_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateHybridConnectionOperationResponse struct { - HttpResponse *http.Response - Model *HybridConnection -} - -// UpdateHybridConnection ... -func (c WebAppsClient) UpdateHybridConnection(ctx context.Context, id RelayId, input HybridConnection) (result UpdateHybridConnectionOperationResponse, err error) { - req, err := c.preparerForUpdateHybridConnection(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateHybridConnection", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateHybridConnection", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateHybridConnection(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateHybridConnection", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateHybridConnection prepares the UpdateHybridConnection request. -func (c WebAppsClient) preparerForUpdateHybridConnection(ctx context.Context, id RelayId, input HybridConnection) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateHybridConnection handles the response to the UpdateHybridConnection request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForUpdateHybridConnection(resp *http.Response) (result UpdateHybridConnectionOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_updatehybridconnectionslot.go b/resource-manager/web/2022-09-01/webapps/method_updatehybridconnectionslot.go new file mode 100644 index 00000000000..d8a98e055b4 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_updatehybridconnectionslot.go @@ -0,0 +1,55 @@ +package webapps + +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 UpdateHybridConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HybridConnection +} + +// UpdateHybridConnectionSlot ... +func (c WebAppsClient) UpdateHybridConnectionSlot(ctx context.Context, id SlotHybridConnectionNamespaceRelayId, input HybridConnection) (result UpdateHybridConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_updatehybridconnectionslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_updatehybridconnectionslot_autorest.go deleted file mode 100644 index cd5e5afe108..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_updatehybridconnectionslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateHybridConnectionSlotOperationResponse struct { - HttpResponse *http.Response - Model *HybridConnection -} - -// UpdateHybridConnectionSlot ... -func (c WebAppsClient) UpdateHybridConnectionSlot(ctx context.Context, id SlotHybridConnectionNamespaceRelayId, input HybridConnection) (result UpdateHybridConnectionSlotOperationResponse, err error) { - req, err := c.preparerForUpdateHybridConnectionSlot(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateHybridConnectionSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateHybridConnectionSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateHybridConnectionSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateHybridConnectionSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateHybridConnectionSlot prepares the UpdateHybridConnectionSlot request. -func (c WebAppsClient) preparerForUpdateHybridConnectionSlot(ctx context.Context, id SlotHybridConnectionNamespaceRelayId, input HybridConnection) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateHybridConnectionSlot handles the response to the UpdateHybridConnectionSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForUpdateHybridConnectionSlot(resp *http.Response) (result UpdateHybridConnectionSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_updatemetadata.go b/resource-manager/web/2022-09-01/webapps/method_updatemetadata.go new file mode 100644 index 00000000000..d60e95270a6 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_updatemetadata.go @@ -0,0 +1,56 @@ +package webapps + +import ( + "context" + "fmt" + "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 UpdateMetadataOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// UpdateMetadata ... +func (c WebAppsClient) UpdateMetadata(ctx context.Context, id SiteId, input StringDictionary) (result UpdateMetadataOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/metadata", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_updatemetadata_autorest.go b/resource-manager/web/2022-09-01/webapps/method_updatemetadata_autorest.go deleted file mode 100644 index 7cfafaa73b5..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_updatemetadata_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateMetadataOperationResponse struct { - HttpResponse *http.Response - Model *StringDictionary -} - -// UpdateMetadata ... -func (c WebAppsClient) UpdateMetadata(ctx context.Context, id SiteId, input StringDictionary) (result UpdateMetadataOperationResponse, err error) { - req, err := c.preparerForUpdateMetadata(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateMetadata", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateMetadata", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateMetadata(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateMetadata", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateMetadata prepares the UpdateMetadata request. -func (c WebAppsClient) preparerForUpdateMetadata(ctx context.Context, id SiteId, input StringDictionary) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/metadata", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateMetadata handles the response to the UpdateMetadata request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForUpdateMetadata(resp *http.Response) (result UpdateMetadataOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_updatemetadataslot.go b/resource-manager/web/2022-09-01/webapps/method_updatemetadataslot.go new file mode 100644 index 00000000000..9dde26857c2 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_updatemetadataslot.go @@ -0,0 +1,56 @@ +package webapps + +import ( + "context" + "fmt" + "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 UpdateMetadataSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// UpdateMetadataSlot ... +func (c WebAppsClient) UpdateMetadataSlot(ctx context.Context, id SlotId, input StringDictionary) (result UpdateMetadataSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/metadata", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_updatemetadataslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_updatemetadataslot_autorest.go deleted file mode 100644 index 6b8f5741e51..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_updatemetadataslot_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateMetadataSlotOperationResponse struct { - HttpResponse *http.Response - Model *StringDictionary -} - -// UpdateMetadataSlot ... -func (c WebAppsClient) UpdateMetadataSlot(ctx context.Context, id SlotId, input StringDictionary) (result UpdateMetadataSlotOperationResponse, err error) { - req, err := c.preparerForUpdateMetadataSlot(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateMetadataSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateMetadataSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateMetadataSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateMetadataSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateMetadataSlot prepares the UpdateMetadataSlot request. -func (c WebAppsClient) preparerForUpdateMetadataSlot(ctx context.Context, id SlotId, input StringDictionary) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/metadata", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateMetadataSlot handles the response to the UpdateMetadataSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForUpdateMetadataSlot(resp *http.Response) (result UpdateMetadataSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_updatepremieraddon.go b/resource-manager/web/2022-09-01/webapps/method_updatepremieraddon.go new file mode 100644 index 00000000000..114d5e7b789 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_updatepremieraddon.go @@ -0,0 +1,55 @@ +package webapps + +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 UpdatePremierAddOnOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PremierAddOn +} + +// UpdatePremierAddOn ... +func (c WebAppsClient) UpdatePremierAddOn(ctx context.Context, id PremierAddonId, input PremierAddOnPatchResource) (result UpdatePremierAddOnOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_updatepremieraddon_autorest.go b/resource-manager/web/2022-09-01/webapps/method_updatepremieraddon_autorest.go deleted file mode 100644 index 6702e9ff766..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_updatepremieraddon_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdatePremierAddOnOperationResponse struct { - HttpResponse *http.Response - Model *PremierAddOn -} - -// UpdatePremierAddOn ... -func (c WebAppsClient) UpdatePremierAddOn(ctx context.Context, id PremierAddonId, input PremierAddOnPatchResource) (result UpdatePremierAddOnOperationResponse, err error) { - req, err := c.preparerForUpdatePremierAddOn(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdatePremierAddOn", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdatePremierAddOn", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdatePremierAddOn(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdatePremierAddOn", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdatePremierAddOn prepares the UpdatePremierAddOn request. -func (c WebAppsClient) preparerForUpdatePremierAddOn(ctx context.Context, id PremierAddonId, input PremierAddOnPatchResource) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdatePremierAddOn handles the response to the UpdatePremierAddOn request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForUpdatePremierAddOn(resp *http.Response) (result UpdatePremierAddOnOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_updatepremieraddonslot.go b/resource-manager/web/2022-09-01/webapps/method_updatepremieraddonslot.go new file mode 100644 index 00000000000..d084349f1d8 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_updatepremieraddonslot.go @@ -0,0 +1,55 @@ +package webapps + +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 UpdatePremierAddOnSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PremierAddOn +} + +// UpdatePremierAddOnSlot ... +func (c WebAppsClient) UpdatePremierAddOnSlot(ctx context.Context, id SlotPremierAddonId, input PremierAddOnPatchResource) (result UpdatePremierAddOnSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_updatepremieraddonslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_updatepremieraddonslot_autorest.go deleted file mode 100644 index f715a36236e..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_updatepremieraddonslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdatePremierAddOnSlotOperationResponse struct { - HttpResponse *http.Response - Model *PremierAddOn -} - -// UpdatePremierAddOnSlot ... -func (c WebAppsClient) UpdatePremierAddOnSlot(ctx context.Context, id SlotPremierAddonId, input PremierAddOnPatchResource) (result UpdatePremierAddOnSlotOperationResponse, err error) { - req, err := c.preparerForUpdatePremierAddOnSlot(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdatePremierAddOnSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdatePremierAddOnSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdatePremierAddOnSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdatePremierAddOnSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdatePremierAddOnSlot prepares the UpdatePremierAddOnSlot request. -func (c WebAppsClient) preparerForUpdatePremierAddOnSlot(ctx context.Context, id SlotPremierAddonId, input PremierAddOnPatchResource) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdatePremierAddOnSlot handles the response to the UpdatePremierAddOnSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForUpdatePremierAddOnSlot(resp *http.Response) (result UpdatePremierAddOnSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_updaterelayserviceconnection.go b/resource-manager/web/2022-09-01/webapps/method_updaterelayserviceconnection.go new file mode 100644 index 00000000000..fcf597467bd --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_updaterelayserviceconnection.go @@ -0,0 +1,55 @@ +package webapps + +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 UpdateRelayServiceConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RelayServiceConnectionEntity +} + +// UpdateRelayServiceConnection ... +func (c WebAppsClient) UpdateRelayServiceConnection(ctx context.Context, id HybridConnectionId, input RelayServiceConnectionEntity) (result UpdateRelayServiceConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_updaterelayserviceconnection_autorest.go b/resource-manager/web/2022-09-01/webapps/method_updaterelayserviceconnection_autorest.go deleted file mode 100644 index c27d937b1a1..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_updaterelayserviceconnection_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateRelayServiceConnectionOperationResponse struct { - HttpResponse *http.Response - Model *RelayServiceConnectionEntity -} - -// UpdateRelayServiceConnection ... -func (c WebAppsClient) UpdateRelayServiceConnection(ctx context.Context, id HybridConnectionId, input RelayServiceConnectionEntity) (result UpdateRelayServiceConnectionOperationResponse, err error) { - req, err := c.preparerForUpdateRelayServiceConnection(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateRelayServiceConnection", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateRelayServiceConnection", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateRelayServiceConnection(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateRelayServiceConnection", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateRelayServiceConnection prepares the UpdateRelayServiceConnection request. -func (c WebAppsClient) preparerForUpdateRelayServiceConnection(ctx context.Context, id HybridConnectionId, input RelayServiceConnectionEntity) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateRelayServiceConnection handles the response to the UpdateRelayServiceConnection request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForUpdateRelayServiceConnection(resp *http.Response) (result UpdateRelayServiceConnectionOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_updaterelayserviceconnectionslot.go b/resource-manager/web/2022-09-01/webapps/method_updaterelayserviceconnectionslot.go new file mode 100644 index 00000000000..55bc601de40 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_updaterelayserviceconnectionslot.go @@ -0,0 +1,55 @@ +package webapps + +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 UpdateRelayServiceConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RelayServiceConnectionEntity +} + +// UpdateRelayServiceConnectionSlot ... +func (c WebAppsClient) UpdateRelayServiceConnectionSlot(ctx context.Context, id SlotHybridConnectionId, input RelayServiceConnectionEntity) (result UpdateRelayServiceConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_updaterelayserviceconnectionslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_updaterelayserviceconnectionslot_autorest.go deleted file mode 100644 index ca975d4daaf..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_updaterelayserviceconnectionslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateRelayServiceConnectionSlotOperationResponse struct { - HttpResponse *http.Response - Model *RelayServiceConnectionEntity -} - -// UpdateRelayServiceConnectionSlot ... -func (c WebAppsClient) UpdateRelayServiceConnectionSlot(ctx context.Context, id SlotHybridConnectionId, input RelayServiceConnectionEntity) (result UpdateRelayServiceConnectionSlotOperationResponse, err error) { - req, err := c.preparerForUpdateRelayServiceConnectionSlot(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateRelayServiceConnectionSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateRelayServiceConnectionSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateRelayServiceConnectionSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateRelayServiceConnectionSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateRelayServiceConnectionSlot prepares the UpdateRelayServiceConnectionSlot request. -func (c WebAppsClient) preparerForUpdateRelayServiceConnectionSlot(ctx context.Context, id SlotHybridConnectionId, input RelayServiceConnectionEntity) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateRelayServiceConnectionSlot handles the response to the UpdateRelayServiceConnectionSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForUpdateRelayServiceConnectionSlot(resp *http.Response) (result UpdateRelayServiceConnectionSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_updatescmallowed.go b/resource-manager/web/2022-09-01/webapps/method_updatescmallowed.go new file mode 100644 index 00000000000..cb27edf2489 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_updatescmallowed.go @@ -0,0 +1,56 @@ +package webapps + +import ( + "context" + "fmt" + "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 UpdateScmAllowedOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CsmPublishingCredentialsPoliciesEntity +} + +// UpdateScmAllowed ... +func (c WebAppsClient) UpdateScmAllowed(ctx context.Context, id SiteId, input CsmPublishingCredentialsPoliciesEntity) (result UpdateScmAllowedOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/basicPublishingCredentialsPolicies/scm", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_updatescmallowed_autorest.go b/resource-manager/web/2022-09-01/webapps/method_updatescmallowed_autorest.go deleted file mode 100644 index 6c7b9c81ee5..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_updatescmallowed_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateScmAllowedOperationResponse struct { - HttpResponse *http.Response - Model *CsmPublishingCredentialsPoliciesEntity -} - -// UpdateScmAllowed ... -func (c WebAppsClient) UpdateScmAllowed(ctx context.Context, id SiteId, input CsmPublishingCredentialsPoliciesEntity) (result UpdateScmAllowedOperationResponse, err error) { - req, err := c.preparerForUpdateScmAllowed(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateScmAllowed", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateScmAllowed", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateScmAllowed(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateScmAllowed", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateScmAllowed prepares the UpdateScmAllowed request. -func (c WebAppsClient) preparerForUpdateScmAllowed(ctx context.Context, id SiteId, input CsmPublishingCredentialsPoliciesEntity) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/basicPublishingCredentialsPolicies/scm", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateScmAllowed handles the response to the UpdateScmAllowed request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForUpdateScmAllowed(resp *http.Response) (result UpdateScmAllowedOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_updatescmallowedslot.go b/resource-manager/web/2022-09-01/webapps/method_updatescmallowedslot.go new file mode 100644 index 00000000000..b8d0ee283ed --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_updatescmallowedslot.go @@ -0,0 +1,56 @@ +package webapps + +import ( + "context" + "fmt" + "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 UpdateScmAllowedSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CsmPublishingCredentialsPoliciesEntity +} + +// UpdateScmAllowedSlot ... +func (c WebAppsClient) UpdateScmAllowedSlot(ctx context.Context, id SlotId, input CsmPublishingCredentialsPoliciesEntity) (result UpdateScmAllowedSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/basicPublishingCredentialsPolicies/scm", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_updatescmallowedslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_updatescmallowedslot_autorest.go deleted file mode 100644 index f462b733775..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_updatescmallowedslot_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateScmAllowedSlotOperationResponse struct { - HttpResponse *http.Response - Model *CsmPublishingCredentialsPoliciesEntity -} - -// UpdateScmAllowedSlot ... -func (c WebAppsClient) UpdateScmAllowedSlot(ctx context.Context, id SlotId, input CsmPublishingCredentialsPoliciesEntity) (result UpdateScmAllowedSlotOperationResponse, err error) { - req, err := c.preparerForUpdateScmAllowedSlot(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateScmAllowedSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateScmAllowedSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateScmAllowedSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateScmAllowedSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateScmAllowedSlot prepares the UpdateScmAllowedSlot request. -func (c WebAppsClient) preparerForUpdateScmAllowedSlot(ctx context.Context, id SlotId, input CsmPublishingCredentialsPoliciesEntity) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/basicPublishingCredentialsPolicies/scm", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateScmAllowedSlot handles the response to the UpdateScmAllowedSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForUpdateScmAllowedSlot(resp *http.Response) (result UpdateScmAllowedSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_updatesitepushsettings.go b/resource-manager/web/2022-09-01/webapps/method_updatesitepushsettings.go new file mode 100644 index 00000000000..ec16bf8623e --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_updatesitepushsettings.go @@ -0,0 +1,56 @@ +package webapps + +import ( + "context" + "fmt" + "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 UpdateSitePushSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PushSettings +} + +// UpdateSitePushSettings ... +func (c WebAppsClient) UpdateSitePushSettings(ctx context.Context, id SiteId, input PushSettings) (result UpdateSitePushSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/pushsettings", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_updatesitepushsettings_autorest.go b/resource-manager/web/2022-09-01/webapps/method_updatesitepushsettings_autorest.go deleted file mode 100644 index b9e268b96e3..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_updatesitepushsettings_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateSitePushSettingsOperationResponse struct { - HttpResponse *http.Response - Model *PushSettings -} - -// UpdateSitePushSettings ... -func (c WebAppsClient) UpdateSitePushSettings(ctx context.Context, id SiteId, input PushSettings) (result UpdateSitePushSettingsOperationResponse, err error) { - req, err := c.preparerForUpdateSitePushSettings(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateSitePushSettings", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateSitePushSettings", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateSitePushSettings(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateSitePushSettings", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateSitePushSettings prepares the UpdateSitePushSettings request. -func (c WebAppsClient) preparerForUpdateSitePushSettings(ctx context.Context, id SiteId, input PushSettings) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/pushsettings", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateSitePushSettings handles the response to the UpdateSitePushSettings request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForUpdateSitePushSettings(resp *http.Response) (result UpdateSitePushSettingsOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_updatesitepushsettingsslot.go b/resource-manager/web/2022-09-01/webapps/method_updatesitepushsettingsslot.go new file mode 100644 index 00000000000..09e95fac92c --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_updatesitepushsettingsslot.go @@ -0,0 +1,56 @@ +package webapps + +import ( + "context" + "fmt" + "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 UpdateSitePushSettingsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PushSettings +} + +// UpdateSitePushSettingsSlot ... +func (c WebAppsClient) UpdateSitePushSettingsSlot(ctx context.Context, id SlotId, input PushSettings) (result UpdateSitePushSettingsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/pushsettings", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_updatesitepushsettingsslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_updatesitepushsettingsslot_autorest.go deleted file mode 100644 index 730117bfb34..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_updatesitepushsettingsslot_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateSitePushSettingsSlotOperationResponse struct { - HttpResponse *http.Response - Model *PushSettings -} - -// UpdateSitePushSettingsSlot ... -func (c WebAppsClient) UpdateSitePushSettingsSlot(ctx context.Context, id SlotId, input PushSettings) (result UpdateSitePushSettingsSlotOperationResponse, err error) { - req, err := c.preparerForUpdateSitePushSettingsSlot(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateSitePushSettingsSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateSitePushSettingsSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateSitePushSettingsSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateSitePushSettingsSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateSitePushSettingsSlot prepares the UpdateSitePushSettingsSlot request. -func (c WebAppsClient) preparerForUpdateSitePushSettingsSlot(ctx context.Context, id SlotId, input PushSettings) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/pushsettings", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateSitePushSettingsSlot handles the response to the UpdateSitePushSettingsSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForUpdateSitePushSettingsSlot(resp *http.Response) (result UpdateSitePushSettingsSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_updateslot.go b/resource-manager/web/2022-09-01/webapps/method_updateslot.go new file mode 100644 index 00000000000..c0f31c8110a --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_updateslot.go @@ -0,0 +1,56 @@ +package webapps + +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 UpdateSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Site +} + +// UpdateSlot ... +func (c WebAppsClient) UpdateSlot(ctx context.Context, id SlotId, input SitePatchResource) (result UpdateSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_updateslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_updateslot_autorest.go deleted file mode 100644 index a7998682091..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_updateslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateSlotOperationResponse struct { - HttpResponse *http.Response - Model *Site -} - -// UpdateSlot ... -func (c WebAppsClient) UpdateSlot(ctx context.Context, id SlotId, input SitePatchResource) (result UpdateSlotOperationResponse, err error) { - req, err := c.preparerForUpdateSlot(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateSlot prepares the UpdateSlot request. -func (c WebAppsClient) preparerForUpdateSlot(ctx context.Context, id SlotId, input SitePatchResource) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateSlot handles the response to the UpdateSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForUpdateSlot(resp *http.Response) (result UpdateSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_updateslotconfigurationnames.go b/resource-manager/web/2022-09-01/webapps/method_updateslotconfigurationnames.go new file mode 100644 index 00000000000..8e745801148 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_updateslotconfigurationnames.go @@ -0,0 +1,56 @@ +package webapps + +import ( + "context" + "fmt" + "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 UpdateSlotConfigurationNamesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SlotConfigNamesResource +} + +// UpdateSlotConfigurationNames ... +func (c WebAppsClient) UpdateSlotConfigurationNames(ctx context.Context, id SiteId, input SlotConfigNamesResource) (result UpdateSlotConfigurationNamesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/slotConfigNames", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_updateslotconfigurationnames_autorest.go b/resource-manager/web/2022-09-01/webapps/method_updateslotconfigurationnames_autorest.go deleted file mode 100644 index e3d866661c7..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_updateslotconfigurationnames_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateSlotConfigurationNamesOperationResponse struct { - HttpResponse *http.Response - Model *SlotConfigNamesResource -} - -// UpdateSlotConfigurationNames ... -func (c WebAppsClient) UpdateSlotConfigurationNames(ctx context.Context, id SiteId, input SlotConfigNamesResource) (result UpdateSlotConfigurationNamesOperationResponse, err error) { - req, err := c.preparerForUpdateSlotConfigurationNames(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateSlotConfigurationNames", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateSlotConfigurationNames", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateSlotConfigurationNames(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateSlotConfigurationNames", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateSlotConfigurationNames prepares the UpdateSlotConfigurationNames request. -func (c WebAppsClient) preparerForUpdateSlotConfigurationNames(ctx context.Context, id SiteId, input SlotConfigNamesResource) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/config/slotConfigNames", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateSlotConfigurationNames handles the response to the UpdateSlotConfigurationNames request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForUpdateSlotConfigurationNames(resp *http.Response) (result UpdateSlotConfigurationNamesOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_updatesourcecontrol.go b/resource-manager/web/2022-09-01/webapps/method_updatesourcecontrol.go new file mode 100644 index 00000000000..fa14ee7f9a1 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_updatesourcecontrol.go @@ -0,0 +1,58 @@ +package webapps + +import ( + "context" + "fmt" + "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 UpdateSourceControlOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteSourceControl +} + +// UpdateSourceControl ... +func (c WebAppsClient) UpdateSourceControl(ctx context.Context, id SiteId, input SiteSourceControl) (result UpdateSourceControlOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: fmt.Sprintf("%s/sourceControls/web", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_updatesourcecontrol_autorest.go b/resource-manager/web/2022-09-01/webapps/method_updatesourcecontrol_autorest.go deleted file mode 100644 index 7441a3dc7be..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_updatesourcecontrol_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateSourceControlOperationResponse struct { - HttpResponse *http.Response - Model *SiteSourceControl -} - -// UpdateSourceControl ... -func (c WebAppsClient) UpdateSourceControl(ctx context.Context, id SiteId, input SiteSourceControl) (result UpdateSourceControlOperationResponse, err error) { - req, err := c.preparerForUpdateSourceControl(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateSourceControl", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateSourceControl", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateSourceControl(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateSourceControl", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateSourceControl prepares the UpdateSourceControl request. -func (c WebAppsClient) preparerForUpdateSourceControl(ctx context.Context, id SiteId, input SiteSourceControl) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/sourceControls/web", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateSourceControl handles the response to the UpdateSourceControl request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForUpdateSourceControl(resp *http.Response) (result UpdateSourceControlOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_updatesourcecontrolslot.go b/resource-manager/web/2022-09-01/webapps/method_updatesourcecontrolslot.go new file mode 100644 index 00000000000..0fb72cb031b --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_updatesourcecontrolslot.go @@ -0,0 +1,58 @@ +package webapps + +import ( + "context" + "fmt" + "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 UpdateSourceControlSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteSourceControl +} + +// UpdateSourceControlSlot ... +func (c WebAppsClient) UpdateSourceControlSlot(ctx context.Context, id SlotId, input SiteSourceControl) (result UpdateSourceControlSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: fmt.Sprintf("%s/sourceControls/web", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_updatesourcecontrolslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_updatesourcecontrolslot_autorest.go deleted file mode 100644 index 829c71c57c2..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_updatesourcecontrolslot_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateSourceControlSlotOperationResponse struct { - HttpResponse *http.Response - Model *SiteSourceControl -} - -// UpdateSourceControlSlot ... -func (c WebAppsClient) UpdateSourceControlSlot(ctx context.Context, id SlotId, input SiteSourceControl) (result UpdateSourceControlSlotOperationResponse, err error) { - req, err := c.preparerForUpdateSourceControlSlot(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateSourceControlSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateSourceControlSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateSourceControlSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateSourceControlSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateSourceControlSlot prepares the UpdateSourceControlSlot request. -func (c WebAppsClient) preparerForUpdateSourceControlSlot(ctx context.Context, id SlotId, input SiteSourceControl) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/sourceControls/web", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateSourceControlSlot handles the response to the UpdateSourceControlSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForUpdateSourceControlSlot(resp *http.Response) (result UpdateSourceControlSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusCreated, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_updateswiftvirtualnetworkconnectionwithcheck.go b/resource-manager/web/2022-09-01/webapps/method_updateswiftvirtualnetworkconnectionwithcheck.go new file mode 100644 index 00000000000..2fc03e7729a --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_updateswiftvirtualnetworkconnectionwithcheck.go @@ -0,0 +1,56 @@ +package webapps + +import ( + "context" + "fmt" + "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 UpdateSwiftVirtualNetworkConnectionWithCheckOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SwiftVirtualNetwork +} + +// UpdateSwiftVirtualNetworkConnectionWithCheck ... +func (c WebAppsClient) UpdateSwiftVirtualNetworkConnectionWithCheck(ctx context.Context, id SiteId, input SwiftVirtualNetwork) (result UpdateSwiftVirtualNetworkConnectionWithCheckOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: fmt.Sprintf("%s/networkConfig/virtualNetwork", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_updateswiftvirtualnetworkconnectionwithcheck_autorest.go b/resource-manager/web/2022-09-01/webapps/method_updateswiftvirtualnetworkconnectionwithcheck_autorest.go deleted file mode 100644 index 9388b3fe93d..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_updateswiftvirtualnetworkconnectionwithcheck_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateSwiftVirtualNetworkConnectionWithCheckOperationResponse struct { - HttpResponse *http.Response - Model *SwiftVirtualNetwork -} - -// UpdateSwiftVirtualNetworkConnectionWithCheck ... -func (c WebAppsClient) UpdateSwiftVirtualNetworkConnectionWithCheck(ctx context.Context, id SiteId, input SwiftVirtualNetwork) (result UpdateSwiftVirtualNetworkConnectionWithCheckOperationResponse, err error) { - req, err := c.preparerForUpdateSwiftVirtualNetworkConnectionWithCheck(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateSwiftVirtualNetworkConnectionWithCheck", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateSwiftVirtualNetworkConnectionWithCheck", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateSwiftVirtualNetworkConnectionWithCheck(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateSwiftVirtualNetworkConnectionWithCheck", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateSwiftVirtualNetworkConnectionWithCheck prepares the UpdateSwiftVirtualNetworkConnectionWithCheck request. -func (c WebAppsClient) preparerForUpdateSwiftVirtualNetworkConnectionWithCheck(ctx context.Context, id SiteId, input SwiftVirtualNetwork) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/networkConfig/virtualNetwork", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateSwiftVirtualNetworkConnectionWithCheck handles the response to the UpdateSwiftVirtualNetworkConnectionWithCheck request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForUpdateSwiftVirtualNetworkConnectionWithCheck(resp *http.Response) (result UpdateSwiftVirtualNetworkConnectionWithCheckOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_updateswiftvirtualnetworkconnectionwithcheckslot.go b/resource-manager/web/2022-09-01/webapps/method_updateswiftvirtualnetworkconnectionwithcheckslot.go new file mode 100644 index 00000000000..6cceb7415ab --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_updateswiftvirtualnetworkconnectionwithcheckslot.go @@ -0,0 +1,56 @@ +package webapps + +import ( + "context" + "fmt" + "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 UpdateSwiftVirtualNetworkConnectionWithCheckSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SwiftVirtualNetwork +} + +// UpdateSwiftVirtualNetworkConnectionWithCheckSlot ... +func (c WebAppsClient) UpdateSwiftVirtualNetworkConnectionWithCheckSlot(ctx context.Context, id SlotId, input SwiftVirtualNetwork) (result UpdateSwiftVirtualNetworkConnectionWithCheckSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: fmt.Sprintf("%s/networkConfig/virtualNetwork", 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_updateswiftvirtualnetworkconnectionwithcheckslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_updateswiftvirtualnetworkconnectionwithcheckslot_autorest.go deleted file mode 100644 index 6e435549cc1..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_updateswiftvirtualnetworkconnectionwithcheckslot_autorest.go +++ /dev/null @@ -1,70 +0,0 @@ -package webapps - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateSwiftVirtualNetworkConnectionWithCheckSlotOperationResponse struct { - HttpResponse *http.Response - Model *SwiftVirtualNetwork -} - -// UpdateSwiftVirtualNetworkConnectionWithCheckSlot ... -func (c WebAppsClient) UpdateSwiftVirtualNetworkConnectionWithCheckSlot(ctx context.Context, id SlotId, input SwiftVirtualNetwork) (result UpdateSwiftVirtualNetworkConnectionWithCheckSlotOperationResponse, err error) { - req, err := c.preparerForUpdateSwiftVirtualNetworkConnectionWithCheckSlot(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateSwiftVirtualNetworkConnectionWithCheckSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateSwiftVirtualNetworkConnectionWithCheckSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateSwiftVirtualNetworkConnectionWithCheckSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateSwiftVirtualNetworkConnectionWithCheckSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateSwiftVirtualNetworkConnectionWithCheckSlot prepares the UpdateSwiftVirtualNetworkConnectionWithCheckSlot request. -func (c WebAppsClient) preparerForUpdateSwiftVirtualNetworkConnectionWithCheckSlot(ctx context.Context, id SlotId, input SwiftVirtualNetwork) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/networkConfig/virtualNetwork", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateSwiftVirtualNetworkConnectionWithCheckSlot handles the response to the UpdateSwiftVirtualNetworkConnectionWithCheckSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForUpdateSwiftVirtualNetworkConnectionWithCheckSlot(resp *http.Response) (result UpdateSwiftVirtualNetworkConnectionWithCheckSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_updatevnetconnection.go b/resource-manager/web/2022-09-01/webapps/method_updatevnetconnection.go new file mode 100644 index 00000000000..ac487d7dcdc --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_updatevnetconnection.go @@ -0,0 +1,55 @@ +package webapps + +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 UpdateVnetConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetInfoResource +} + +// UpdateVnetConnection ... +func (c WebAppsClient) UpdateVnetConnection(ctx context.Context, id VirtualNetworkConnectionId, input VnetInfoResource) (result UpdateVnetConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_updatevnetconnection_autorest.go b/resource-manager/web/2022-09-01/webapps/method_updatevnetconnection_autorest.go deleted file mode 100644 index 72551a265c9..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_updatevnetconnection_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateVnetConnectionOperationResponse struct { - HttpResponse *http.Response - Model *VnetInfoResource -} - -// UpdateVnetConnection ... -func (c WebAppsClient) UpdateVnetConnection(ctx context.Context, id VirtualNetworkConnectionId, input VnetInfoResource) (result UpdateVnetConnectionOperationResponse, err error) { - req, err := c.preparerForUpdateVnetConnection(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateVnetConnection", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateVnetConnection", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateVnetConnection(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateVnetConnection", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateVnetConnection prepares the UpdateVnetConnection request. -func (c WebAppsClient) preparerForUpdateVnetConnection(ctx context.Context, id VirtualNetworkConnectionId, input VnetInfoResource) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateVnetConnection handles the response to the UpdateVnetConnection request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForUpdateVnetConnection(resp *http.Response) (result UpdateVnetConnectionOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_updatevnetconnectiongateway.go b/resource-manager/web/2022-09-01/webapps/method_updatevnetconnectiongateway.go new file mode 100644 index 00000000000..7a30b06a446 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_updatevnetconnectiongateway.go @@ -0,0 +1,55 @@ +package webapps + +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 UpdateVnetConnectionGatewayOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetGateway +} + +// UpdateVnetConnectionGateway ... +func (c WebAppsClient) UpdateVnetConnectionGateway(ctx context.Context, id GatewayId, input VnetGateway) (result UpdateVnetConnectionGatewayOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_updatevnetconnectiongateway_autorest.go b/resource-manager/web/2022-09-01/webapps/method_updatevnetconnectiongateway_autorest.go deleted file mode 100644 index 48068cefc66..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_updatevnetconnectiongateway_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateVnetConnectionGatewayOperationResponse struct { - HttpResponse *http.Response - Model *VnetGateway -} - -// UpdateVnetConnectionGateway ... -func (c WebAppsClient) UpdateVnetConnectionGateway(ctx context.Context, id GatewayId, input VnetGateway) (result UpdateVnetConnectionGatewayOperationResponse, err error) { - req, err := c.preparerForUpdateVnetConnectionGateway(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateVnetConnectionGateway", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateVnetConnectionGateway", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateVnetConnectionGateway(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateVnetConnectionGateway", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateVnetConnectionGateway prepares the UpdateVnetConnectionGateway request. -func (c WebAppsClient) preparerForUpdateVnetConnectionGateway(ctx context.Context, id GatewayId, input VnetGateway) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateVnetConnectionGateway handles the response to the UpdateVnetConnectionGateway request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForUpdateVnetConnectionGateway(resp *http.Response) (result UpdateVnetConnectionGatewayOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_updatevnetconnectiongatewayslot.go b/resource-manager/web/2022-09-01/webapps/method_updatevnetconnectiongatewayslot.go new file mode 100644 index 00000000000..211706a99e2 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_updatevnetconnectiongatewayslot.go @@ -0,0 +1,55 @@ +package webapps + +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 UpdateVnetConnectionGatewaySlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetGateway +} + +// UpdateVnetConnectionGatewaySlot ... +func (c WebAppsClient) UpdateVnetConnectionGatewaySlot(ctx context.Context, id SlotVirtualNetworkConnectionGatewayId, input VnetGateway) (result UpdateVnetConnectionGatewaySlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_updatevnetconnectiongatewayslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_updatevnetconnectiongatewayslot_autorest.go deleted file mode 100644 index b51496aa63f..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_updatevnetconnectiongatewayslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateVnetConnectionGatewaySlotOperationResponse struct { - HttpResponse *http.Response - Model *VnetGateway -} - -// UpdateVnetConnectionGatewaySlot ... -func (c WebAppsClient) UpdateVnetConnectionGatewaySlot(ctx context.Context, id SlotVirtualNetworkConnectionGatewayId, input VnetGateway) (result UpdateVnetConnectionGatewaySlotOperationResponse, err error) { - req, err := c.preparerForUpdateVnetConnectionGatewaySlot(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateVnetConnectionGatewaySlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateVnetConnectionGatewaySlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateVnetConnectionGatewaySlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateVnetConnectionGatewaySlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateVnetConnectionGatewaySlot prepares the UpdateVnetConnectionGatewaySlot request. -func (c WebAppsClient) preparerForUpdateVnetConnectionGatewaySlot(ctx context.Context, id SlotVirtualNetworkConnectionGatewayId, input VnetGateway) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateVnetConnectionGatewaySlot handles the response to the UpdateVnetConnectionGatewaySlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForUpdateVnetConnectionGatewaySlot(resp *http.Response) (result UpdateVnetConnectionGatewaySlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/webapps/method_updatevnetconnectionslot.go b/resource-manager/web/2022-09-01/webapps/method_updatevnetconnectionslot.go new file mode 100644 index 00000000000..0ca97a7a442 --- /dev/null +++ b/resource-manager/web/2022-09-01/webapps/method_updatevnetconnectionslot.go @@ -0,0 +1,55 @@ +package webapps + +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 UpdateVnetConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetInfoResource +} + +// UpdateVnetConnectionSlot ... +func (c WebAppsClient) UpdateVnetConnectionSlot(ctx context.Context, id SlotVirtualNetworkConnectionId, input VnetInfoResource) (result UpdateVnetConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + 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 +} diff --git a/resource-manager/web/2022-09-01/webapps/method_updatevnetconnectionslot_autorest.go b/resource-manager/web/2022-09-01/webapps/method_updatevnetconnectionslot_autorest.go deleted file mode 100644 index 82eeb8d0714..00000000000 --- a/resource-manager/web/2022-09-01/webapps/method_updatevnetconnectionslot_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package webapps - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpdateVnetConnectionSlotOperationResponse struct { - HttpResponse *http.Response - Model *VnetInfoResource -} - -// UpdateVnetConnectionSlot ... -func (c WebAppsClient) UpdateVnetConnectionSlot(ctx context.Context, id SlotVirtualNetworkConnectionId, input VnetInfoResource) (result UpdateVnetConnectionSlotOperationResponse, err error) { - req, err := c.preparerForUpdateVnetConnectionSlot(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateVnetConnectionSlot", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateVnetConnectionSlot", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForUpdateVnetConnectionSlot(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "webapps.WebAppsClient", "UpdateVnetConnectionSlot", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForUpdateVnetConnectionSlot prepares the UpdateVnetConnectionSlot request. -func (c WebAppsClient) preparerForUpdateVnetConnectionSlot(ctx context.Context, id SlotVirtualNetworkConnectionId, input VnetInfoResource) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForUpdateVnetConnectionSlot handles the response to the UpdateVnetConnectionSlot request. The method always -// closes the http.Response Body. -func (c WebAppsClient) responderForUpdateVnetConnectionSlot(resp *http.Response) (result UpdateVnetConnectionSlotOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/workflowrunactions/client.go b/resource-manager/web/2022-09-01/workflowrunactions/client.go index 4be56ad82df..b831f4e826e 100644 --- a/resource-manager/web/2022-09-01/workflowrunactions/client.go +++ b/resource-manager/web/2022-09-01/workflowrunactions/client.go @@ -1,18 +1,26 @@ package workflowrunactions -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 WorkflowRunActionsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewWorkflowRunActionsClientWithBaseURI(endpoint string) WorkflowRunActionsClient { - return WorkflowRunActionsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewWorkflowRunActionsClientWithBaseURI(api environments.Api) (*WorkflowRunActionsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "workflowrunactions", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating WorkflowRunActionsClient: %+v", err) } + + return &WorkflowRunActionsClient{ + Client: client, + }, nil } diff --git a/resource-manager/web/2022-09-01/workflowrunactions/constants.go b/resource-manager/web/2022-09-01/workflowrunactions/constants.go index 2b85ab65c47..98029f459ce 100644 --- a/resource-manager/web/2022-09-01/workflowrunactions/constants.go +++ b/resource-manager/web/2022-09-01/workflowrunactions/constants.go @@ -1,6 +1,10 @@ package workflowrunactions -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. @@ -41,6 +45,19 @@ func PossibleValuesForWorkflowStatus() []string { } } +func (s *WorkflowStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseWorkflowStatus(input string) (*WorkflowStatus, error) { vals := map[string]WorkflowStatus{ "aborted": WorkflowStatusAborted, diff --git a/resource-manager/web/2022-09-01/workflowrunactions/method_coperepetitionsget.go b/resource-manager/web/2022-09-01/workflowrunactions/method_coperepetitionsget.go new file mode 100644 index 00000000000..5d5db074d6d --- /dev/null +++ b/resource-manager/web/2022-09-01/workflowrunactions/method_coperepetitionsget.go @@ -0,0 +1,51 @@ +package workflowrunactions + +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 CopeRepetitionsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkflowRunActionRepetitionDefinition +} + +// CopeRepetitionsGet ... +func (c WorkflowRunActionsClient) CopeRepetitionsGet(ctx context.Context, id ScopeRepetitionId) (result CopeRepetitionsGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/workflowrunactions/method_coperepetitionsget_autorest.go b/resource-manager/web/2022-09-01/workflowrunactions/method_coperepetitionsget_autorest.go deleted file mode 100644 index 608ad25cf8e..00000000000 --- a/resource-manager/web/2022-09-01/workflowrunactions/method_coperepetitionsget_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package workflowrunactions - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CopeRepetitionsGetOperationResponse struct { - HttpResponse *http.Response - Model *WorkflowRunActionRepetitionDefinition -} - -// CopeRepetitionsGet ... -func (c WorkflowRunActionsClient) CopeRepetitionsGet(ctx context.Context, id ScopeRepetitionId) (result CopeRepetitionsGetOperationResponse, err error) { - req, err := c.preparerForCopeRepetitionsGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowrunactions.WorkflowRunActionsClient", "CopeRepetitionsGet", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowrunactions.WorkflowRunActionsClient", "CopeRepetitionsGet", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCopeRepetitionsGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowrunactions.WorkflowRunActionsClient", "CopeRepetitionsGet", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCopeRepetitionsGet prepares the CopeRepetitionsGet request. -func (c WorkflowRunActionsClient) preparerForCopeRepetitionsGet(ctx context.Context, id ScopeRepetitionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCopeRepetitionsGet handles the response to the CopeRepetitionsGet request. The method always -// closes the http.Response Body. -func (c WorkflowRunActionsClient) responderForCopeRepetitionsGet(resp *http.Response) (result CopeRepetitionsGetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/workflowrunactions/method_coperepetitionslist.go b/resource-manager/web/2022-09-01/workflowrunactions/method_coperepetitionslist.go new file mode 100644 index 00000000000..773e0938d7d --- /dev/null +++ b/resource-manager/web/2022-09-01/workflowrunactions/method_coperepetitionslist.go @@ -0,0 +1,89 @@ +package workflowrunactions + +import ( + "context" + "fmt" + "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 CopeRepetitionsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WorkflowRunActionRepetitionDefinition +} + +type CopeRepetitionsListCompleteResult struct { + Items []WorkflowRunActionRepetitionDefinition +} + +// CopeRepetitionsList ... +func (c WorkflowRunActionsClient) CopeRepetitionsList(ctx context.Context, id ActionId) (result CopeRepetitionsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/scopeRepetitions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]WorkflowRunActionRepetitionDefinition `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// CopeRepetitionsListComplete retrieves all the results into a single object +func (c WorkflowRunActionsClient) CopeRepetitionsListComplete(ctx context.Context, id ActionId) (CopeRepetitionsListCompleteResult, error) { + return c.CopeRepetitionsListCompleteMatchingPredicate(ctx, id, WorkflowRunActionRepetitionDefinitionOperationPredicate{}) +} + +// CopeRepetitionsListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WorkflowRunActionsClient) CopeRepetitionsListCompleteMatchingPredicate(ctx context.Context, id ActionId, predicate WorkflowRunActionRepetitionDefinitionOperationPredicate) (result CopeRepetitionsListCompleteResult, err error) { + items := make([]WorkflowRunActionRepetitionDefinition, 0) + + resp, err := c.CopeRepetitionsList(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = CopeRepetitionsListCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/workflowrunactions/method_coperepetitionslist_autorest.go b/resource-manager/web/2022-09-01/workflowrunactions/method_coperepetitionslist_autorest.go deleted file mode 100644 index 5a819b320e9..00000000000 --- a/resource-manager/web/2022-09-01/workflowrunactions/method_coperepetitionslist_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package workflowrunactions - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CopeRepetitionsListOperationResponse struct { - HttpResponse *http.Response - Model *[]WorkflowRunActionRepetitionDefinition - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (CopeRepetitionsListOperationResponse, error) -} - -type CopeRepetitionsListCompleteResult struct { - Items []WorkflowRunActionRepetitionDefinition -} - -func (r CopeRepetitionsListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r CopeRepetitionsListOperationResponse) LoadMore(ctx context.Context) (resp CopeRepetitionsListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// CopeRepetitionsList ... -func (c WorkflowRunActionsClient) CopeRepetitionsList(ctx context.Context, id ActionId) (resp CopeRepetitionsListOperationResponse, err error) { - req, err := c.preparerForCopeRepetitionsList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowrunactions.WorkflowRunActionsClient", "CopeRepetitionsList", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowrunactions.WorkflowRunActionsClient", "CopeRepetitionsList", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForCopeRepetitionsList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowrunactions.WorkflowRunActionsClient", "CopeRepetitionsList", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForCopeRepetitionsList prepares the CopeRepetitionsList request. -func (c WorkflowRunActionsClient) preparerForCopeRepetitionsList(ctx context.Context, id ActionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/scopeRepetitions", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForCopeRepetitionsListWithNextLink prepares the CopeRepetitionsList request with the given nextLink token. -func (c WorkflowRunActionsClient) preparerForCopeRepetitionsListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCopeRepetitionsList handles the response to the CopeRepetitionsList request. The method always -// closes the http.Response Body. -func (c WorkflowRunActionsClient) responderForCopeRepetitionsList(resp *http.Response) (result CopeRepetitionsListOperationResponse, err error) { - type page struct { - Values []WorkflowRunActionRepetitionDefinition `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result CopeRepetitionsListOperationResponse, err error) { - req, err := c.preparerForCopeRepetitionsListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowrunactions.WorkflowRunActionsClient", "CopeRepetitionsList", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowrunactions.WorkflowRunActionsClient", "CopeRepetitionsList", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCopeRepetitionsList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowrunactions.WorkflowRunActionsClient", "CopeRepetitionsList", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// CopeRepetitionsListComplete retrieves all of the results into a single object -func (c WorkflowRunActionsClient) CopeRepetitionsListComplete(ctx context.Context, id ActionId) (CopeRepetitionsListCompleteResult, error) { - return c.CopeRepetitionsListCompleteMatchingPredicate(ctx, id, WorkflowRunActionRepetitionDefinitionOperationPredicate{}) -} - -// CopeRepetitionsListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WorkflowRunActionsClient) CopeRepetitionsListCompleteMatchingPredicate(ctx context.Context, id ActionId, predicate WorkflowRunActionRepetitionDefinitionOperationPredicate) (resp CopeRepetitionsListCompleteResult, err error) { - items := make([]WorkflowRunActionRepetitionDefinition, 0) - - page, err := c.CopeRepetitionsList(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := CopeRepetitionsListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/workflowrunactions/method_get.go b/resource-manager/web/2022-09-01/workflowrunactions/method_get.go new file mode 100644 index 00000000000..98b992c00e0 --- /dev/null +++ b/resource-manager/web/2022-09-01/workflowrunactions/method_get.go @@ -0,0 +1,51 @@ +package workflowrunactions + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkflowRunAction +} + +// Get ... +func (c WorkflowRunActionsClient) Get(ctx context.Context, id ActionId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/workflowrunactions/method_get_autorest.go b/resource-manager/web/2022-09-01/workflowrunactions/method_get_autorest.go deleted file mode 100644 index 5033bc3a79e..00000000000 --- a/resource-manager/web/2022-09-01/workflowrunactions/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package workflowrunactions - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *WorkflowRunAction -} - -// Get ... -func (c WorkflowRunActionsClient) Get(ctx context.Context, id ActionId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowrunactions.WorkflowRunActionsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowrunactions.WorkflowRunActionsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowrunactions.WorkflowRunActionsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c WorkflowRunActionsClient) preparerForGet(ctx context.Context, id ActionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c WorkflowRunActionsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/workflowrunactions/method_list.go b/resource-manager/web/2022-09-01/workflowrunactions/method_list.go new file mode 100644 index 00000000000..e20ea788608 --- /dev/null +++ b/resource-manager/web/2022-09-01/workflowrunactions/method_list.go @@ -0,0 +1,121 @@ +package workflowrunactions + +import ( + "context" + "fmt" + "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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WorkflowRunAction +} + +type ListCompleteResult struct { + Items []WorkflowRunAction +} + +type ListOperationOptions struct { + Filter *string + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// List ... +func (c WorkflowRunActionsClient) List(ctx context.Context, id RunId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/actions", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]WorkflowRunAction `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c WorkflowRunActionsClient) ListComplete(ctx context.Context, id RunId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, WorkflowRunActionOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WorkflowRunActionsClient) ListCompleteMatchingPredicate(ctx context.Context, id RunId, options ListOperationOptions, predicate WorkflowRunActionOperationPredicate) (result ListCompleteResult, err error) { + items := make([]WorkflowRunAction, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/workflowrunactions/method_list_autorest.go b/resource-manager/web/2022-09-01/workflowrunactions/method_list_autorest.go deleted file mode 100644 index 3aabe40f9ae..00000000000 --- a/resource-manager/web/2022-09-01/workflowrunactions/method_list_autorest.go +++ /dev/null @@ -1,220 +0,0 @@ -package workflowrunactions - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListOperationResponse struct { - HttpResponse *http.Response - Model *[]WorkflowRunAction - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []WorkflowRunAction -} - -func (r ListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListOperationOptions struct { - Filter *string - Top *int64 -} - -func DefaultListOperationOptions() ListOperationOptions { - return ListOperationOptions{} -} - -func (o ListOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// List ... -func (c WorkflowRunActionsClient) List(ctx context.Context, id RunId, options ListOperationOptions) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowrunactions.WorkflowRunActionsClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowrunactions.WorkflowRunActionsClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowrunactions.WorkflowRunActionsClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c WorkflowRunActionsClient) preparerForList(ctx context.Context, id RunId, options ListOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/actions", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c WorkflowRunActionsClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForList handles the response to the List request. The method always -// closes the http.Response Body. -func (c WorkflowRunActionsClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []WorkflowRunAction `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { - req, err := c.preparerForListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowrunactions.WorkflowRunActionsClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowrunactions.WorkflowRunActionsClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowrunactions.WorkflowRunActionsClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c WorkflowRunActionsClient) ListComplete(ctx context.Context, id RunId, options ListOperationOptions) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, options, WorkflowRunActionOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WorkflowRunActionsClient) ListCompleteMatchingPredicate(ctx context.Context, id RunId, options ListOperationOptions, predicate WorkflowRunActionOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]WorkflowRunAction, 0) - - page, err := c.List(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/workflowrunactions/method_listexpressiontraces.go b/resource-manager/web/2022-09-01/workflowrunactions/method_listexpressiontraces.go new file mode 100644 index 00000000000..419cc19abf0 --- /dev/null +++ b/resource-manager/web/2022-09-01/workflowrunactions/method_listexpressiontraces.go @@ -0,0 +1,82 @@ +package workflowrunactions + +import ( + "context" + "fmt" + "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 ListExpressionTracesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]interface{} +} + +type ListExpressionTracesCompleteResult struct { + Items []interface{} +} + +// ListExpressionTraces ... +func (c WorkflowRunActionsClient) ListExpressionTraces(ctx context.Context, id ActionId) (result ListExpressionTracesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listExpressionTraces", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]interface{} `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListExpressionTracesComplete retrieves all the results into a single object +func (c WorkflowRunActionsClient) ListExpressionTracesComplete(ctx context.Context, id ActionId) (result ListExpressionTracesCompleteResult, err error) { + items := make([]interface{}, 0) + + resp, err := c.ListExpressionTraces(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + items = append(items, v) + } + } + + result = ListExpressionTracesCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/workflowrunactions/method_listexpressiontraces_autorest.go b/resource-manager/web/2022-09-01/workflowrunactions/method_listexpressiontraces_autorest.go deleted file mode 100644 index 926a2b9f10a..00000000000 --- a/resource-manager/web/2022-09-01/workflowrunactions/method_listexpressiontraces_autorest.go +++ /dev/null @@ -1,177 +0,0 @@ -package workflowrunactions - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListExpressionTracesOperationResponse struct { - HttpResponse *http.Response - Model *[]interface{} - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListExpressionTracesOperationResponse, error) -} - -type ListExpressionTracesCompleteResult struct { - Items []interface{} -} - -func (r ListExpressionTracesOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListExpressionTracesOperationResponse) LoadMore(ctx context.Context) (resp ListExpressionTracesOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// ListExpressionTraces ... -func (c WorkflowRunActionsClient) ListExpressionTraces(ctx context.Context, id ActionId) (resp ListExpressionTracesOperationResponse, err error) { - req, err := c.preparerForListExpressionTraces(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowrunactions.WorkflowRunActionsClient", "ListExpressionTraces", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowrunactions.WorkflowRunActionsClient", "ListExpressionTraces", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForListExpressionTraces(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowrunactions.WorkflowRunActionsClient", "ListExpressionTraces", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForListExpressionTraces prepares the ListExpressionTraces request. -func (c WorkflowRunActionsClient) preparerForListExpressionTraces(ctx context.Context, id ActionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/listExpressionTraces", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListExpressionTracesWithNextLink prepares the ListExpressionTraces request with the given nextLink token. -func (c WorkflowRunActionsClient) preparerForListExpressionTracesWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListExpressionTraces handles the response to the ListExpressionTraces request. The method always -// closes the http.Response Body. -func (c WorkflowRunActionsClient) responderForListExpressionTraces(resp *http.Response) (result ListExpressionTracesOperationResponse, err error) { - type page struct { - Values []interface{} `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListExpressionTracesOperationResponse, err error) { - req, err := c.preparerForListExpressionTracesWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowrunactions.WorkflowRunActionsClient", "ListExpressionTraces", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowrunactions.WorkflowRunActionsClient", "ListExpressionTraces", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListExpressionTraces(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowrunactions.WorkflowRunActionsClient", "ListExpressionTraces", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListExpressionTracesComplete retrieves all of the results into a single object -func (c WorkflowRunActionsClient) ListExpressionTracesComplete(ctx context.Context, id ActionId) (result ListExpressionTracesCompleteResult, err error) { - items := make([]interface{}, 0) - - page, err := c.ListExpressionTraces(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - items = append(items, v) - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - items = append(items, v) - } - } - } - - out := ListExpressionTracesCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/workflowrunactions/method_workflowrunactionrepetitionsget.go b/resource-manager/web/2022-09-01/workflowrunactions/method_workflowrunactionrepetitionsget.go new file mode 100644 index 00000000000..0d155f44ef7 --- /dev/null +++ b/resource-manager/web/2022-09-01/workflowrunactions/method_workflowrunactionrepetitionsget.go @@ -0,0 +1,51 @@ +package workflowrunactions + +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 WorkflowRunActionRepetitionsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkflowRunActionRepetitionDefinition +} + +// WorkflowRunActionRepetitionsGet ... +func (c WorkflowRunActionsClient) WorkflowRunActionRepetitionsGet(ctx context.Context, id RepetitionId) (result WorkflowRunActionRepetitionsGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/workflowrunactions/method_workflowrunactionrepetitionsget_autorest.go b/resource-manager/web/2022-09-01/workflowrunactions/method_workflowrunactionrepetitionsget_autorest.go deleted file mode 100644 index 1fc34e96d81..00000000000 --- a/resource-manager/web/2022-09-01/workflowrunactions/method_workflowrunactionrepetitionsget_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package workflowrunactions - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type WorkflowRunActionRepetitionsGetOperationResponse struct { - HttpResponse *http.Response - Model *WorkflowRunActionRepetitionDefinition -} - -// WorkflowRunActionRepetitionsGet ... -func (c WorkflowRunActionsClient) WorkflowRunActionRepetitionsGet(ctx context.Context, id RepetitionId) (result WorkflowRunActionRepetitionsGetOperationResponse, err error) { - req, err := c.preparerForWorkflowRunActionRepetitionsGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowrunactions.WorkflowRunActionsClient", "WorkflowRunActionRepetitionsGet", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowrunactions.WorkflowRunActionsClient", "WorkflowRunActionRepetitionsGet", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForWorkflowRunActionRepetitionsGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowrunactions.WorkflowRunActionsClient", "WorkflowRunActionRepetitionsGet", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForWorkflowRunActionRepetitionsGet prepares the WorkflowRunActionRepetitionsGet request. -func (c WorkflowRunActionsClient) preparerForWorkflowRunActionRepetitionsGet(ctx context.Context, id RepetitionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForWorkflowRunActionRepetitionsGet handles the response to the WorkflowRunActionRepetitionsGet request. The method always -// closes the http.Response Body. -func (c WorkflowRunActionsClient) responderForWorkflowRunActionRepetitionsGet(resp *http.Response) (result WorkflowRunActionRepetitionsGetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/workflowrunactions/method_workflowrunactionrepetitionslist.go b/resource-manager/web/2022-09-01/workflowrunactions/method_workflowrunactionrepetitionslist.go new file mode 100644 index 00000000000..fc9972cf384 --- /dev/null +++ b/resource-manager/web/2022-09-01/workflowrunactions/method_workflowrunactionrepetitionslist.go @@ -0,0 +1,89 @@ +package workflowrunactions + +import ( + "context" + "fmt" + "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 WorkflowRunActionRepetitionsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WorkflowRunActionRepetitionDefinition +} + +type WorkflowRunActionRepetitionsListCompleteResult struct { + Items []WorkflowRunActionRepetitionDefinition +} + +// WorkflowRunActionRepetitionsList ... +func (c WorkflowRunActionsClient) WorkflowRunActionRepetitionsList(ctx context.Context, id ActionId) (result WorkflowRunActionRepetitionsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/repetitions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]WorkflowRunActionRepetitionDefinition `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// WorkflowRunActionRepetitionsListComplete retrieves all the results into a single object +func (c WorkflowRunActionsClient) WorkflowRunActionRepetitionsListComplete(ctx context.Context, id ActionId) (WorkflowRunActionRepetitionsListCompleteResult, error) { + return c.WorkflowRunActionRepetitionsListCompleteMatchingPredicate(ctx, id, WorkflowRunActionRepetitionDefinitionOperationPredicate{}) +} + +// WorkflowRunActionRepetitionsListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WorkflowRunActionsClient) WorkflowRunActionRepetitionsListCompleteMatchingPredicate(ctx context.Context, id ActionId, predicate WorkflowRunActionRepetitionDefinitionOperationPredicate) (result WorkflowRunActionRepetitionsListCompleteResult, err error) { + items := make([]WorkflowRunActionRepetitionDefinition, 0) + + resp, err := c.WorkflowRunActionRepetitionsList(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = WorkflowRunActionRepetitionsListCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/workflowrunactions/method_workflowrunactionrepetitionslist_autorest.go b/resource-manager/web/2022-09-01/workflowrunactions/method_workflowrunactionrepetitionslist_autorest.go deleted file mode 100644 index 81fa34d61bf..00000000000 --- a/resource-manager/web/2022-09-01/workflowrunactions/method_workflowrunactionrepetitionslist_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package workflowrunactions - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type WorkflowRunActionRepetitionsListOperationResponse struct { - HttpResponse *http.Response - Model *[]WorkflowRunActionRepetitionDefinition - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (WorkflowRunActionRepetitionsListOperationResponse, error) -} - -type WorkflowRunActionRepetitionsListCompleteResult struct { - Items []WorkflowRunActionRepetitionDefinition -} - -func (r WorkflowRunActionRepetitionsListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r WorkflowRunActionRepetitionsListOperationResponse) LoadMore(ctx context.Context) (resp WorkflowRunActionRepetitionsListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// WorkflowRunActionRepetitionsList ... -func (c WorkflowRunActionsClient) WorkflowRunActionRepetitionsList(ctx context.Context, id ActionId) (resp WorkflowRunActionRepetitionsListOperationResponse, err error) { - req, err := c.preparerForWorkflowRunActionRepetitionsList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowrunactions.WorkflowRunActionsClient", "WorkflowRunActionRepetitionsList", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowrunactions.WorkflowRunActionsClient", "WorkflowRunActionRepetitionsList", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForWorkflowRunActionRepetitionsList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowrunactions.WorkflowRunActionsClient", "WorkflowRunActionRepetitionsList", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForWorkflowRunActionRepetitionsList prepares the WorkflowRunActionRepetitionsList request. -func (c WorkflowRunActionsClient) preparerForWorkflowRunActionRepetitionsList(ctx context.Context, id ActionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/repetitions", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForWorkflowRunActionRepetitionsListWithNextLink prepares the WorkflowRunActionRepetitionsList request with the given nextLink token. -func (c WorkflowRunActionsClient) preparerForWorkflowRunActionRepetitionsListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForWorkflowRunActionRepetitionsList handles the response to the WorkflowRunActionRepetitionsList request. The method always -// closes the http.Response Body. -func (c WorkflowRunActionsClient) responderForWorkflowRunActionRepetitionsList(resp *http.Response) (result WorkflowRunActionRepetitionsListOperationResponse, err error) { - type page struct { - Values []WorkflowRunActionRepetitionDefinition `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result WorkflowRunActionRepetitionsListOperationResponse, err error) { - req, err := c.preparerForWorkflowRunActionRepetitionsListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowrunactions.WorkflowRunActionsClient", "WorkflowRunActionRepetitionsList", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowrunactions.WorkflowRunActionsClient", "WorkflowRunActionRepetitionsList", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForWorkflowRunActionRepetitionsList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowrunactions.WorkflowRunActionsClient", "WorkflowRunActionRepetitionsList", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// WorkflowRunActionRepetitionsListComplete retrieves all of the results into a single object -func (c WorkflowRunActionsClient) WorkflowRunActionRepetitionsListComplete(ctx context.Context, id ActionId) (WorkflowRunActionRepetitionsListCompleteResult, error) { - return c.WorkflowRunActionRepetitionsListCompleteMatchingPredicate(ctx, id, WorkflowRunActionRepetitionDefinitionOperationPredicate{}) -} - -// WorkflowRunActionRepetitionsListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WorkflowRunActionsClient) WorkflowRunActionRepetitionsListCompleteMatchingPredicate(ctx context.Context, id ActionId, predicate WorkflowRunActionRepetitionDefinitionOperationPredicate) (resp WorkflowRunActionRepetitionsListCompleteResult, err error) { - items := make([]WorkflowRunActionRepetitionDefinition, 0) - - page, err := c.WorkflowRunActionRepetitionsList(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := WorkflowRunActionRepetitionsListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/workflowrunactions/method_workflowrunactionrepetitionslistexpressiontraces.go b/resource-manager/web/2022-09-01/workflowrunactions/method_workflowrunactionrepetitionslistexpressiontraces.go new file mode 100644 index 00000000000..9692e40b46b --- /dev/null +++ b/resource-manager/web/2022-09-01/workflowrunactions/method_workflowrunactionrepetitionslistexpressiontraces.go @@ -0,0 +1,82 @@ +package workflowrunactions + +import ( + "context" + "fmt" + "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 WorkflowRunActionRepetitionsListExpressionTracesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]interface{} +} + +type WorkflowRunActionRepetitionsListExpressionTracesCompleteResult struct { + Items []interface{} +} + +// WorkflowRunActionRepetitionsListExpressionTraces ... +func (c WorkflowRunActionsClient) WorkflowRunActionRepetitionsListExpressionTraces(ctx context.Context, id RepetitionId) (result WorkflowRunActionRepetitionsListExpressionTracesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listExpressionTraces", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]interface{} `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// WorkflowRunActionRepetitionsListExpressionTracesComplete retrieves all the results into a single object +func (c WorkflowRunActionsClient) WorkflowRunActionRepetitionsListExpressionTracesComplete(ctx context.Context, id RepetitionId) (result WorkflowRunActionRepetitionsListExpressionTracesCompleteResult, err error) { + items := make([]interface{}, 0) + + resp, err := c.WorkflowRunActionRepetitionsListExpressionTraces(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + items = append(items, v) + } + } + + result = WorkflowRunActionRepetitionsListExpressionTracesCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/workflowrunactions/method_workflowrunactionrepetitionslistexpressiontraces_autorest.go b/resource-manager/web/2022-09-01/workflowrunactions/method_workflowrunactionrepetitionslistexpressiontraces_autorest.go deleted file mode 100644 index 38015469207..00000000000 --- a/resource-manager/web/2022-09-01/workflowrunactions/method_workflowrunactionrepetitionslistexpressiontraces_autorest.go +++ /dev/null @@ -1,177 +0,0 @@ -package workflowrunactions - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type WorkflowRunActionRepetitionsListExpressionTracesOperationResponse struct { - HttpResponse *http.Response - Model *[]interface{} - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (WorkflowRunActionRepetitionsListExpressionTracesOperationResponse, error) -} - -type WorkflowRunActionRepetitionsListExpressionTracesCompleteResult struct { - Items []interface{} -} - -func (r WorkflowRunActionRepetitionsListExpressionTracesOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r WorkflowRunActionRepetitionsListExpressionTracesOperationResponse) LoadMore(ctx context.Context) (resp WorkflowRunActionRepetitionsListExpressionTracesOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// WorkflowRunActionRepetitionsListExpressionTraces ... -func (c WorkflowRunActionsClient) WorkflowRunActionRepetitionsListExpressionTraces(ctx context.Context, id RepetitionId) (resp WorkflowRunActionRepetitionsListExpressionTracesOperationResponse, err error) { - req, err := c.preparerForWorkflowRunActionRepetitionsListExpressionTraces(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowrunactions.WorkflowRunActionsClient", "WorkflowRunActionRepetitionsListExpressionTraces", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowrunactions.WorkflowRunActionsClient", "WorkflowRunActionRepetitionsListExpressionTraces", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForWorkflowRunActionRepetitionsListExpressionTraces(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowrunactions.WorkflowRunActionsClient", "WorkflowRunActionRepetitionsListExpressionTraces", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForWorkflowRunActionRepetitionsListExpressionTraces prepares the WorkflowRunActionRepetitionsListExpressionTraces request. -func (c WorkflowRunActionsClient) preparerForWorkflowRunActionRepetitionsListExpressionTraces(ctx context.Context, id RepetitionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/listExpressionTraces", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForWorkflowRunActionRepetitionsListExpressionTracesWithNextLink prepares the WorkflowRunActionRepetitionsListExpressionTraces request with the given nextLink token. -func (c WorkflowRunActionsClient) preparerForWorkflowRunActionRepetitionsListExpressionTracesWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForWorkflowRunActionRepetitionsListExpressionTraces handles the response to the WorkflowRunActionRepetitionsListExpressionTraces request. The method always -// closes the http.Response Body. -func (c WorkflowRunActionsClient) responderForWorkflowRunActionRepetitionsListExpressionTraces(resp *http.Response) (result WorkflowRunActionRepetitionsListExpressionTracesOperationResponse, err error) { - type page struct { - Values []interface{} `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result WorkflowRunActionRepetitionsListExpressionTracesOperationResponse, err error) { - req, err := c.preparerForWorkflowRunActionRepetitionsListExpressionTracesWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowrunactions.WorkflowRunActionsClient", "WorkflowRunActionRepetitionsListExpressionTraces", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowrunactions.WorkflowRunActionsClient", "WorkflowRunActionRepetitionsListExpressionTraces", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForWorkflowRunActionRepetitionsListExpressionTraces(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowrunactions.WorkflowRunActionsClient", "WorkflowRunActionRepetitionsListExpressionTraces", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// WorkflowRunActionRepetitionsListExpressionTracesComplete retrieves all of the results into a single object -func (c WorkflowRunActionsClient) WorkflowRunActionRepetitionsListExpressionTracesComplete(ctx context.Context, id RepetitionId) (result WorkflowRunActionRepetitionsListExpressionTracesCompleteResult, err error) { - items := make([]interface{}, 0) - - page, err := c.WorkflowRunActionRepetitionsListExpressionTraces(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - items = append(items, v) - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - items = append(items, v) - } - } - } - - out := WorkflowRunActionRepetitionsListExpressionTracesCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/workflowrunactions/method_workflowrunactionrepetitionsrequesthistoriesget.go b/resource-manager/web/2022-09-01/workflowrunactions/method_workflowrunactionrepetitionsrequesthistoriesget.go new file mode 100644 index 00000000000..cdfa70bb95f --- /dev/null +++ b/resource-manager/web/2022-09-01/workflowrunactions/method_workflowrunactionrepetitionsrequesthistoriesget.go @@ -0,0 +1,51 @@ +package workflowrunactions + +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 WorkflowRunActionRepetitionsRequestHistoriesGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RequestHistory +} + +// WorkflowRunActionRepetitionsRequestHistoriesGet ... +func (c WorkflowRunActionsClient) WorkflowRunActionRepetitionsRequestHistoriesGet(ctx context.Context, id RequestHistoryId) (result WorkflowRunActionRepetitionsRequestHistoriesGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/workflowrunactions/method_workflowrunactionrepetitionsrequesthistoriesget_autorest.go b/resource-manager/web/2022-09-01/workflowrunactions/method_workflowrunactionrepetitionsrequesthistoriesget_autorest.go deleted file mode 100644 index 12dbb1f8d90..00000000000 --- a/resource-manager/web/2022-09-01/workflowrunactions/method_workflowrunactionrepetitionsrequesthistoriesget_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package workflowrunactions - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type WorkflowRunActionRepetitionsRequestHistoriesGetOperationResponse struct { - HttpResponse *http.Response - Model *RequestHistory -} - -// WorkflowRunActionRepetitionsRequestHistoriesGet ... -func (c WorkflowRunActionsClient) WorkflowRunActionRepetitionsRequestHistoriesGet(ctx context.Context, id RequestHistoryId) (result WorkflowRunActionRepetitionsRequestHistoriesGetOperationResponse, err error) { - req, err := c.preparerForWorkflowRunActionRepetitionsRequestHistoriesGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowrunactions.WorkflowRunActionsClient", "WorkflowRunActionRepetitionsRequestHistoriesGet", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowrunactions.WorkflowRunActionsClient", "WorkflowRunActionRepetitionsRequestHistoriesGet", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForWorkflowRunActionRepetitionsRequestHistoriesGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowrunactions.WorkflowRunActionsClient", "WorkflowRunActionRepetitionsRequestHistoriesGet", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForWorkflowRunActionRepetitionsRequestHistoriesGet prepares the WorkflowRunActionRepetitionsRequestHistoriesGet request. -func (c WorkflowRunActionsClient) preparerForWorkflowRunActionRepetitionsRequestHistoriesGet(ctx context.Context, id RequestHistoryId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForWorkflowRunActionRepetitionsRequestHistoriesGet handles the response to the WorkflowRunActionRepetitionsRequestHistoriesGet request. The method always -// closes the http.Response Body. -func (c WorkflowRunActionsClient) responderForWorkflowRunActionRepetitionsRequestHistoriesGet(resp *http.Response) (result WorkflowRunActionRepetitionsRequestHistoriesGetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/workflowrunactions/method_workflowrunactionrepetitionsrequesthistorieslist.go b/resource-manager/web/2022-09-01/workflowrunactions/method_workflowrunactionrepetitionsrequesthistorieslist.go new file mode 100644 index 00000000000..5d4102a35ee --- /dev/null +++ b/resource-manager/web/2022-09-01/workflowrunactions/method_workflowrunactionrepetitionsrequesthistorieslist.go @@ -0,0 +1,89 @@ +package workflowrunactions + +import ( + "context" + "fmt" + "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 WorkflowRunActionRepetitionsRequestHistoriesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RequestHistory +} + +type WorkflowRunActionRepetitionsRequestHistoriesListCompleteResult struct { + Items []RequestHistory +} + +// WorkflowRunActionRepetitionsRequestHistoriesList ... +func (c WorkflowRunActionsClient) WorkflowRunActionRepetitionsRequestHistoriesList(ctx context.Context, id RepetitionId) (result WorkflowRunActionRepetitionsRequestHistoriesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/requestHistories", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]RequestHistory `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// WorkflowRunActionRepetitionsRequestHistoriesListComplete retrieves all the results into a single object +func (c WorkflowRunActionsClient) WorkflowRunActionRepetitionsRequestHistoriesListComplete(ctx context.Context, id RepetitionId) (WorkflowRunActionRepetitionsRequestHistoriesListCompleteResult, error) { + return c.WorkflowRunActionRepetitionsRequestHistoriesListCompleteMatchingPredicate(ctx, id, RequestHistoryOperationPredicate{}) +} + +// WorkflowRunActionRepetitionsRequestHistoriesListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WorkflowRunActionsClient) WorkflowRunActionRepetitionsRequestHistoriesListCompleteMatchingPredicate(ctx context.Context, id RepetitionId, predicate RequestHistoryOperationPredicate) (result WorkflowRunActionRepetitionsRequestHistoriesListCompleteResult, err error) { + items := make([]RequestHistory, 0) + + resp, err := c.WorkflowRunActionRepetitionsRequestHistoriesList(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = WorkflowRunActionRepetitionsRequestHistoriesListCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/workflowrunactions/method_workflowrunactionrepetitionsrequesthistorieslist_autorest.go b/resource-manager/web/2022-09-01/workflowrunactions/method_workflowrunactionrepetitionsrequesthistorieslist_autorest.go deleted file mode 100644 index e33fe5ae49c..00000000000 --- a/resource-manager/web/2022-09-01/workflowrunactions/method_workflowrunactionrepetitionsrequesthistorieslist_autorest.go +++ /dev/null @@ -1,186 +0,0 @@ -package workflowrunactions - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type WorkflowRunActionRepetitionsRequestHistoriesListOperationResponse struct { - HttpResponse *http.Response - Model *[]RequestHistory - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (WorkflowRunActionRepetitionsRequestHistoriesListOperationResponse, error) -} - -type WorkflowRunActionRepetitionsRequestHistoriesListCompleteResult struct { - Items []RequestHistory -} - -func (r WorkflowRunActionRepetitionsRequestHistoriesListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r WorkflowRunActionRepetitionsRequestHistoriesListOperationResponse) LoadMore(ctx context.Context) (resp WorkflowRunActionRepetitionsRequestHistoriesListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -// WorkflowRunActionRepetitionsRequestHistoriesList ... -func (c WorkflowRunActionsClient) WorkflowRunActionRepetitionsRequestHistoriesList(ctx context.Context, id RepetitionId) (resp WorkflowRunActionRepetitionsRequestHistoriesListOperationResponse, err error) { - req, err := c.preparerForWorkflowRunActionRepetitionsRequestHistoriesList(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowrunactions.WorkflowRunActionsClient", "WorkflowRunActionRepetitionsRequestHistoriesList", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowrunactions.WorkflowRunActionsClient", "WorkflowRunActionRepetitionsRequestHistoriesList", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForWorkflowRunActionRepetitionsRequestHistoriesList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowrunactions.WorkflowRunActionsClient", "WorkflowRunActionRepetitionsRequestHistoriesList", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForWorkflowRunActionRepetitionsRequestHistoriesList prepares the WorkflowRunActionRepetitionsRequestHistoriesList request. -func (c WorkflowRunActionsClient) preparerForWorkflowRunActionRepetitionsRequestHistoriesList(ctx context.Context, id RepetitionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/requestHistories", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForWorkflowRunActionRepetitionsRequestHistoriesListWithNextLink prepares the WorkflowRunActionRepetitionsRequestHistoriesList request with the given nextLink token. -func (c WorkflowRunActionsClient) preparerForWorkflowRunActionRepetitionsRequestHistoriesListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForWorkflowRunActionRepetitionsRequestHistoriesList handles the response to the WorkflowRunActionRepetitionsRequestHistoriesList request. The method always -// closes the http.Response Body. -func (c WorkflowRunActionsClient) responderForWorkflowRunActionRepetitionsRequestHistoriesList(resp *http.Response) (result WorkflowRunActionRepetitionsRequestHistoriesListOperationResponse, err error) { - type page struct { - Values []RequestHistory `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result WorkflowRunActionRepetitionsRequestHistoriesListOperationResponse, err error) { - req, err := c.preparerForWorkflowRunActionRepetitionsRequestHistoriesListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowrunactions.WorkflowRunActionsClient", "WorkflowRunActionRepetitionsRequestHistoriesList", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowrunactions.WorkflowRunActionsClient", "WorkflowRunActionRepetitionsRequestHistoriesList", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForWorkflowRunActionRepetitionsRequestHistoriesList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowrunactions.WorkflowRunActionsClient", "WorkflowRunActionRepetitionsRequestHistoriesList", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// WorkflowRunActionRepetitionsRequestHistoriesListComplete retrieves all of the results into a single object -func (c WorkflowRunActionsClient) WorkflowRunActionRepetitionsRequestHistoriesListComplete(ctx context.Context, id RepetitionId) (WorkflowRunActionRepetitionsRequestHistoriesListCompleteResult, error) { - return c.WorkflowRunActionRepetitionsRequestHistoriesListCompleteMatchingPredicate(ctx, id, RequestHistoryOperationPredicate{}) -} - -// WorkflowRunActionRepetitionsRequestHistoriesListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WorkflowRunActionsClient) WorkflowRunActionRepetitionsRequestHistoriesListCompleteMatchingPredicate(ctx context.Context, id RepetitionId, predicate RequestHistoryOperationPredicate) (resp WorkflowRunActionRepetitionsRequestHistoriesListCompleteResult, err error) { - items := make([]RequestHistory, 0) - - page, err := c.WorkflowRunActionRepetitionsRequestHistoriesList(ctx, id) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := WorkflowRunActionRepetitionsRequestHistoriesListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/workflowruns/client.go b/resource-manager/web/2022-09-01/workflowruns/client.go index 6a17a8cec5f..43b565b2cd6 100644 --- a/resource-manager/web/2022-09-01/workflowruns/client.go +++ b/resource-manager/web/2022-09-01/workflowruns/client.go @@ -1,18 +1,26 @@ package workflowruns -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 WorkflowRunsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewWorkflowRunsClientWithBaseURI(endpoint string) WorkflowRunsClient { - return WorkflowRunsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewWorkflowRunsClientWithBaseURI(api environments.Api) (*WorkflowRunsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "workflowruns", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating WorkflowRunsClient: %+v", err) } + + return &WorkflowRunsClient{ + Client: client, + }, nil } diff --git a/resource-manager/web/2022-09-01/workflowruns/constants.go b/resource-manager/web/2022-09-01/workflowruns/constants.go index 52b89435b34..35a87b003f0 100644 --- a/resource-manager/web/2022-09-01/workflowruns/constants.go +++ b/resource-manager/web/2022-09-01/workflowruns/constants.go @@ -1,6 +1,10 @@ package workflowruns -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. @@ -33,6 +37,19 @@ func PossibleValuesForParameterType() []string { } } +func (s *ParameterType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseParameterType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseParameterType(input string) (*ParameterType, error) { vals := map[string]ParameterType{ "array": ParameterTypeArray, @@ -90,6 +107,19 @@ func PossibleValuesForWorkflowStatus() []string { } } +func (s *WorkflowStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseWorkflowStatus(input string) (*WorkflowStatus, error) { vals := map[string]WorkflowStatus{ "aborted": WorkflowStatusAborted, diff --git a/resource-manager/web/2022-09-01/workflowruns/method_cancel.go b/resource-manager/web/2022-09-01/workflowruns/method_cancel.go new file mode 100644 index 00000000000..217b0e617cb --- /dev/null +++ b/resource-manager/web/2022-09-01/workflowruns/method_cancel.go @@ -0,0 +1,47 @@ +package workflowruns + +import ( + "context" + "fmt" + "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 CancelOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Cancel ... +func (c WorkflowRunsClient) Cancel(ctx context.Context, id RunId) (result CancelOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/cancel", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/workflowruns/method_cancel_autorest.go b/resource-manager/web/2022-09-01/workflowruns/method_cancel_autorest.go deleted file mode 100644 index 50496281f01..00000000000 --- a/resource-manager/web/2022-09-01/workflowruns/method_cancel_autorest.go +++ /dev/null @@ -1,67 +0,0 @@ -package workflowruns - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type CancelOperationResponse struct { - HttpResponse *http.Response -} - -// Cancel ... -func (c WorkflowRunsClient) Cancel(ctx context.Context, id RunId) (result CancelOperationResponse, err error) { - req, err := c.preparerForCancel(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowruns.WorkflowRunsClient", "Cancel", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowruns.WorkflowRunsClient", "Cancel", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForCancel(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowruns.WorkflowRunsClient", "Cancel", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForCancel prepares the Cancel request. -func (c WorkflowRunsClient) preparerForCancel(ctx context.Context, id RunId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/cancel", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForCancel handles the response to the Cancel request. The method always -// closes the http.Response Body. -func (c WorkflowRunsClient) responderForCancel(resp *http.Response) (result CancelOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/workflowruns/method_get.go b/resource-manager/web/2022-09-01/workflowruns/method_get.go new file mode 100644 index 00000000000..8bb79847960 --- /dev/null +++ b/resource-manager/web/2022-09-01/workflowruns/method_get.go @@ -0,0 +1,51 @@ +package workflowruns + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkflowRun +} + +// Get ... +func (c WorkflowRunsClient) Get(ctx context.Context, id RunId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/workflowruns/method_get_autorest.go b/resource-manager/web/2022-09-01/workflowruns/method_get_autorest.go deleted file mode 100644 index adfb70e878b..00000000000 --- a/resource-manager/web/2022-09-01/workflowruns/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package workflowruns - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *WorkflowRun -} - -// Get ... -func (c WorkflowRunsClient) Get(ctx context.Context, id RunId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowruns.WorkflowRunsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowruns.WorkflowRunsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowruns.WorkflowRunsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c WorkflowRunsClient) preparerForGet(ctx context.Context, id RunId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c WorkflowRunsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/workflowruns/method_list.go b/resource-manager/web/2022-09-01/workflowruns/method_list.go new file mode 100644 index 00000000000..fab066aace9 --- /dev/null +++ b/resource-manager/web/2022-09-01/workflowruns/method_list.go @@ -0,0 +1,121 @@ +package workflowruns + +import ( + "context" + "fmt" + "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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WorkflowRun +} + +type ListCompleteResult struct { + Items []WorkflowRun +} + +type ListOperationOptions struct { + Filter *string + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// List ... +func (c WorkflowRunsClient) List(ctx context.Context, id ManagementWorkflowId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/runs", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]WorkflowRun `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c WorkflowRunsClient) ListComplete(ctx context.Context, id ManagementWorkflowId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, WorkflowRunOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WorkflowRunsClient) ListCompleteMatchingPredicate(ctx context.Context, id ManagementWorkflowId, options ListOperationOptions, predicate WorkflowRunOperationPredicate) (result ListCompleteResult, err error) { + items := make([]WorkflowRun, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/workflowruns/method_list_autorest.go b/resource-manager/web/2022-09-01/workflowruns/method_list_autorest.go deleted file mode 100644 index 68e96db138f..00000000000 --- a/resource-manager/web/2022-09-01/workflowruns/method_list_autorest.go +++ /dev/null @@ -1,220 +0,0 @@ -package workflowruns - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListOperationResponse struct { - HttpResponse *http.Response - Model *[]WorkflowRun - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []WorkflowRun -} - -func (r ListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListOperationOptions struct { - Filter *string - Top *int64 -} - -func DefaultListOperationOptions() ListOperationOptions { - return ListOperationOptions{} -} - -func (o ListOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// List ... -func (c WorkflowRunsClient) List(ctx context.Context, id ManagementWorkflowId, options ListOperationOptions) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowruns.WorkflowRunsClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowruns.WorkflowRunsClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowruns.WorkflowRunsClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c WorkflowRunsClient) preparerForList(ctx context.Context, id ManagementWorkflowId, options ListOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/runs", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c WorkflowRunsClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForList handles the response to the List request. The method always -// closes the http.Response Body. -func (c WorkflowRunsClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []WorkflowRun `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { - req, err := c.preparerForListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowruns.WorkflowRunsClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowruns.WorkflowRunsClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowruns.WorkflowRunsClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c WorkflowRunsClient) ListComplete(ctx context.Context, id ManagementWorkflowId, options ListOperationOptions) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, options, WorkflowRunOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WorkflowRunsClient) ListCompleteMatchingPredicate(ctx context.Context, id ManagementWorkflowId, options ListOperationOptions, predicate WorkflowRunOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]WorkflowRun, 0) - - page, err := c.List(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/workflows/client.go b/resource-manager/web/2022-09-01/workflows/client.go index 664f452829c..b86cd23219c 100644 --- a/resource-manager/web/2022-09-01/workflows/client.go +++ b/resource-manager/web/2022-09-01/workflows/client.go @@ -1,18 +1,26 @@ package workflows -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 WorkflowsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewWorkflowsClientWithBaseURI(endpoint string) WorkflowsClient { - return WorkflowsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewWorkflowsClientWithBaseURI(api environments.Api) (*WorkflowsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "workflows", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating WorkflowsClient: %+v", err) } + + return &WorkflowsClient{ + Client: client, + }, nil } diff --git a/resource-manager/web/2022-09-01/workflows/constants.go b/resource-manager/web/2022-09-01/workflows/constants.go index a1da9a9008b..856f9a16584 100644 --- a/resource-manager/web/2022-09-01/workflows/constants.go +++ b/resource-manager/web/2022-09-01/workflows/constants.go @@ -1,6 +1,10 @@ package workflows -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. @@ -21,6 +25,19 @@ func PossibleValuesForKeyType() []string { } } +func (s *KeyType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKeyType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseKeyType(input string) (*KeyType, error) { vals := map[string]KeyType{ "notspecified": KeyTypeNotSpecified, @@ -50,6 +67,19 @@ func PossibleValuesForKind() []string { } } +func (s *Kind) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKind(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseKind(input string) (*Kind, error) { vals := map[string]Kind{ "stateful": KindStateful, @@ -76,6 +106,19 @@ func PossibleValuesForOpenAuthenticationProviderType() []string { } } +func (s *OpenAuthenticationProviderType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOpenAuthenticationProviderType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseOpenAuthenticationProviderType(input string) (*OpenAuthenticationProviderType, error) { vals := map[string]OpenAuthenticationProviderType{ "aad": OpenAuthenticationProviderTypeAAD, @@ -117,6 +160,19 @@ func PossibleValuesForParameterType() []string { } } +func (s *ParameterType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseParameterType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseParameterType(input string) (*ParameterType, error) { vals := map[string]ParameterType{ "array": ParameterTypeArray, @@ -192,6 +248,19 @@ func PossibleValuesForWorkflowProvisioningState() []string { } } +func (s *WorkflowProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseWorkflowProvisioningState(input string) (*WorkflowProvisioningState, error) { vals := map[string]WorkflowProvisioningState{ "accepted": WorkflowProvisioningStateAccepted, @@ -248,6 +317,19 @@ func PossibleValuesForWorkflowSkuName() []string { } } +func (s *WorkflowSkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseWorkflowSkuName(input string) (*WorkflowSkuName, error) { vals := map[string]WorkflowSkuName{ "basic": WorkflowSkuNameBasic, @@ -288,6 +370,19 @@ func PossibleValuesForWorkflowState() []string { } } +func (s *WorkflowState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseWorkflowState(input string) (*WorkflowState, error) { vals := map[string]WorkflowState{ "completed": WorkflowStateCompleted, diff --git a/resource-manager/web/2022-09-01/workflows/method_regenerateaccesskey.go b/resource-manager/web/2022-09-01/workflows/method_regenerateaccesskey.go new file mode 100644 index 00000000000..7b2bc71c3b6 --- /dev/null +++ b/resource-manager/web/2022-09-01/workflows/method_regenerateaccesskey.go @@ -0,0 +1,51 @@ +package workflows + +import ( + "context" + "fmt" + "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 RegenerateAccessKeyOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// RegenerateAccessKey ... +func (c WorkflowsClient) RegenerateAccessKey(ctx context.Context, id ManagementWorkflowId, input RegenerateActionParameter) (result RegenerateAccessKeyOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/regenerateAccessKey", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/workflows/method_regenerateaccesskey_autorest.go b/resource-manager/web/2022-09-01/workflows/method_regenerateaccesskey_autorest.go deleted file mode 100644 index 4227b52708a..00000000000 --- a/resource-manager/web/2022-09-01/workflows/method_regenerateaccesskey_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package workflows - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type RegenerateAccessKeyOperationResponse struct { - HttpResponse *http.Response -} - -// RegenerateAccessKey ... -func (c WorkflowsClient) RegenerateAccessKey(ctx context.Context, id ManagementWorkflowId, input RegenerateActionParameter) (result RegenerateAccessKeyOperationResponse, err error) { - req, err := c.preparerForRegenerateAccessKey(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "workflows.WorkflowsClient", "RegenerateAccessKey", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "workflows.WorkflowsClient", "RegenerateAccessKey", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForRegenerateAccessKey(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "workflows.WorkflowsClient", "RegenerateAccessKey", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForRegenerateAccessKey prepares the RegenerateAccessKey request. -func (c WorkflowsClient) preparerForRegenerateAccessKey(ctx context.Context, id ManagementWorkflowId, input RegenerateActionParameter) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/regenerateAccessKey", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForRegenerateAccessKey handles the response to the RegenerateAccessKey request. The method always -// closes the http.Response Body. -func (c WorkflowsClient) responderForRegenerateAccessKey(resp *http.Response) (result RegenerateAccessKeyOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/workflows/method_validate.go b/resource-manager/web/2022-09-01/workflows/method_validate.go new file mode 100644 index 00000000000..ca923456cfe --- /dev/null +++ b/resource-manager/web/2022-09-01/workflows/method_validate.go @@ -0,0 +1,51 @@ +package workflows + +import ( + "context" + "fmt" + "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 ValidateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Validate ... +func (c WorkflowsClient) Validate(ctx context.Context, id ManagementWorkflowId, input Workflow) (result ValidateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/validate", 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 + } + + return +} diff --git a/resource-manager/web/2022-09-01/workflows/method_validate_autorest.go b/resource-manager/web/2022-09-01/workflows/method_validate_autorest.go deleted file mode 100644 index f25b8983f4b..00000000000 --- a/resource-manager/web/2022-09-01/workflows/method_validate_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package workflows - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ValidateOperationResponse struct { - HttpResponse *http.Response -} - -// Validate ... -func (c WorkflowsClient) Validate(ctx context.Context, id ManagementWorkflowId, input Workflow) (result ValidateOperationResponse, err error) { - req, err := c.preparerForValidate(ctx, id, input) - if err != nil { - err = autorest.NewErrorWithError(err, "workflows.WorkflowsClient", "Validate", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "workflows.WorkflowsClient", "Validate", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForValidate(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "workflows.WorkflowsClient", "Validate", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForValidate prepares the Validate request. -func (c WorkflowsClient) preparerForValidate(ctx context.Context, id ManagementWorkflowId, input Workflow) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/validate", id.ID())), - autorest.WithJSON(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForValidate handles the response to the Validate request. The method always -// closes the http.Response Body. -func (c WorkflowsClient) responderForValidate(resp *http.Response) (result ValidateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/workflowtriggerhistories/client.go b/resource-manager/web/2022-09-01/workflowtriggerhistories/client.go index c52ce0b306a..2616be06d78 100644 --- a/resource-manager/web/2022-09-01/workflowtriggerhistories/client.go +++ b/resource-manager/web/2022-09-01/workflowtriggerhistories/client.go @@ -1,18 +1,26 @@ package workflowtriggerhistories -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 WorkflowTriggerHistoriesClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewWorkflowTriggerHistoriesClientWithBaseURI(endpoint string) WorkflowTriggerHistoriesClient { - return WorkflowTriggerHistoriesClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewWorkflowTriggerHistoriesClientWithBaseURI(api environments.Api) (*WorkflowTriggerHistoriesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "workflowtriggerhistories", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating WorkflowTriggerHistoriesClient: %+v", err) } + + return &WorkflowTriggerHistoriesClient{ + Client: client, + }, nil } diff --git a/resource-manager/web/2022-09-01/workflowtriggerhistories/constants.go b/resource-manager/web/2022-09-01/workflowtriggerhistories/constants.go index 7c8d03afa79..9ccf7819b12 100644 --- a/resource-manager/web/2022-09-01/workflowtriggerhistories/constants.go +++ b/resource-manager/web/2022-09-01/workflowtriggerhistories/constants.go @@ -1,6 +1,10 @@ package workflowtriggerhistories -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. @@ -41,6 +45,19 @@ func PossibleValuesForWorkflowStatus() []string { } } +func (s *WorkflowStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseWorkflowStatus(input string) (*WorkflowStatus, error) { vals := map[string]WorkflowStatus{ "aborted": WorkflowStatusAborted, diff --git a/resource-manager/web/2022-09-01/workflowtriggerhistories/method_get.go b/resource-manager/web/2022-09-01/workflowtriggerhistories/method_get.go new file mode 100644 index 00000000000..09a876a455e --- /dev/null +++ b/resource-manager/web/2022-09-01/workflowtriggerhistories/method_get.go @@ -0,0 +1,51 @@ +package workflowtriggerhistories + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkflowTriggerHistory +} + +// Get ... +func (c WorkflowTriggerHistoriesClient) Get(ctx context.Context, id TriggerHistoryId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/workflowtriggerhistories/method_get_autorest.go b/resource-manager/web/2022-09-01/workflowtriggerhistories/method_get_autorest.go deleted file mode 100644 index 07ed0baf835..00000000000 --- a/resource-manager/web/2022-09-01/workflowtriggerhistories/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package workflowtriggerhistories - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *WorkflowTriggerHistory -} - -// Get ... -func (c WorkflowTriggerHistoriesClient) Get(ctx context.Context, id TriggerHistoryId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowtriggerhistories.WorkflowTriggerHistoriesClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowtriggerhistories.WorkflowTriggerHistoriesClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowtriggerhistories.WorkflowTriggerHistoriesClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c WorkflowTriggerHistoriesClient) preparerForGet(ctx context.Context, id TriggerHistoryId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c WorkflowTriggerHistoriesClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/workflowtriggerhistories/method_list.go b/resource-manager/web/2022-09-01/workflowtriggerhistories/method_list.go new file mode 100644 index 00000000000..4f9c1dfee9d --- /dev/null +++ b/resource-manager/web/2022-09-01/workflowtriggerhistories/method_list.go @@ -0,0 +1,121 @@ +package workflowtriggerhistories + +import ( + "context" + "fmt" + "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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WorkflowTriggerHistory +} + +type ListCompleteResult struct { + Items []WorkflowTriggerHistory +} + +type ListOperationOptions struct { + Filter *string + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// List ... +func (c WorkflowTriggerHistoriesClient) List(ctx context.Context, id TriggerId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/histories", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]WorkflowTriggerHistory `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c WorkflowTriggerHistoriesClient) ListComplete(ctx context.Context, id TriggerId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, WorkflowTriggerHistoryOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WorkflowTriggerHistoriesClient) ListCompleteMatchingPredicate(ctx context.Context, id TriggerId, options ListOperationOptions, predicate WorkflowTriggerHistoryOperationPredicate) (result ListCompleteResult, err error) { + items := make([]WorkflowTriggerHistory, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/workflowtriggerhistories/method_list_autorest.go b/resource-manager/web/2022-09-01/workflowtriggerhistories/method_list_autorest.go deleted file mode 100644 index 0f5fb42a547..00000000000 --- a/resource-manager/web/2022-09-01/workflowtriggerhistories/method_list_autorest.go +++ /dev/null @@ -1,220 +0,0 @@ -package workflowtriggerhistories - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListOperationResponse struct { - HttpResponse *http.Response - Model *[]WorkflowTriggerHistory - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []WorkflowTriggerHistory -} - -func (r ListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListOperationOptions struct { - Filter *string - Top *int64 -} - -func DefaultListOperationOptions() ListOperationOptions { - return ListOperationOptions{} -} - -func (o ListOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// List ... -func (c WorkflowTriggerHistoriesClient) List(ctx context.Context, id TriggerId, options ListOperationOptions) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowtriggerhistories.WorkflowTriggerHistoriesClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowtriggerhistories.WorkflowTriggerHistoriesClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowtriggerhistories.WorkflowTriggerHistoriesClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c WorkflowTriggerHistoriesClient) preparerForList(ctx context.Context, id TriggerId, options ListOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/histories", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c WorkflowTriggerHistoriesClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForList handles the response to the List request. The method always -// closes the http.Response Body. -func (c WorkflowTriggerHistoriesClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []WorkflowTriggerHistory `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { - req, err := c.preparerForListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowtriggerhistories.WorkflowTriggerHistoriesClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowtriggerhistories.WorkflowTriggerHistoriesClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowtriggerhistories.WorkflowTriggerHistoriesClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c WorkflowTriggerHistoriesClient) ListComplete(ctx context.Context, id TriggerId, options ListOperationOptions) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, options, WorkflowTriggerHistoryOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WorkflowTriggerHistoriesClient) ListCompleteMatchingPredicate(ctx context.Context, id TriggerId, options ListOperationOptions, predicate WorkflowTriggerHistoryOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]WorkflowTriggerHistory, 0) - - page, err := c.List(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/workflowtriggerhistories/method_resubmit.go b/resource-manager/web/2022-09-01/workflowtriggerhistories/method_resubmit.go new file mode 100644 index 00000000000..5dc9aca0fab --- /dev/null +++ b/resource-manager/web/2022-09-01/workflowtriggerhistories/method_resubmit.go @@ -0,0 +1,69 @@ +package workflowtriggerhistories + +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 ResubmitOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Resubmit ... +func (c WorkflowTriggerHistoriesClient) Resubmit(ctx context.Context, id TriggerHistoryId) (result ResubmitOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resubmit", 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 +} + +// ResubmitThenPoll performs Resubmit then polls until it's completed +func (c WorkflowTriggerHistoriesClient) ResubmitThenPoll(ctx context.Context, id TriggerHistoryId) error { + result, err := c.Resubmit(ctx, id) + if err != nil { + return fmt.Errorf("performing Resubmit: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Resubmit: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/workflowtriggerhistories/method_resubmit_autorest.go b/resource-manager/web/2022-09-01/workflowtriggerhistories/method_resubmit_autorest.go deleted file mode 100644 index 687f11936b0..00000000000 --- a/resource-manager/web/2022-09-01/workflowtriggerhistories/method_resubmit_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package workflowtriggerhistories - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ResubmitOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Resubmit ... -func (c WorkflowTriggerHistoriesClient) Resubmit(ctx context.Context, id TriggerHistoryId) (result ResubmitOperationResponse, err error) { - req, err := c.preparerForResubmit(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowtriggerhistories.WorkflowTriggerHistoriesClient", "Resubmit", nil, "Failure preparing request") - return - } - - result, err = c.senderForResubmit(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowtriggerhistories.WorkflowTriggerHistoriesClient", "Resubmit", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// ResubmitThenPoll performs Resubmit then polls until it's completed -func (c WorkflowTriggerHistoriesClient) ResubmitThenPoll(ctx context.Context, id TriggerHistoryId) error { - result, err := c.Resubmit(ctx, id) - if err != nil { - return fmt.Errorf("performing Resubmit: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Resubmit: %+v", err) - } - - return nil -} - -// preparerForResubmit prepares the Resubmit request. -func (c WorkflowTriggerHistoriesClient) preparerForResubmit(ctx context.Context, id TriggerHistoryId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/resubmit", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForResubmit sends the Resubmit request. The method will close the -// http.Response Body if it receives an error. -func (c WorkflowTriggerHistoriesClient) senderForResubmit(ctx context.Context, req *http.Request) (future ResubmitOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/workflowtriggers/client.go b/resource-manager/web/2022-09-01/workflowtriggers/client.go index 09e2d07ce68..b3c445df3bd 100644 --- a/resource-manager/web/2022-09-01/workflowtriggers/client.go +++ b/resource-manager/web/2022-09-01/workflowtriggers/client.go @@ -1,18 +1,26 @@ package workflowtriggers -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 WorkflowTriggersClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewWorkflowTriggersClientWithBaseURI(endpoint string) WorkflowTriggersClient { - return WorkflowTriggersClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewWorkflowTriggersClientWithBaseURI(api environments.Api) (*WorkflowTriggersClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "workflowtriggers", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating WorkflowTriggersClient: %+v", err) } + + return &WorkflowTriggersClient{ + Client: client, + }, nil } diff --git a/resource-manager/web/2022-09-01/workflowtriggers/constants.go b/resource-manager/web/2022-09-01/workflowtriggers/constants.go index 086728fdba1..344f92609e4 100644 --- a/resource-manager/web/2022-09-01/workflowtriggers/constants.go +++ b/resource-manager/web/2022-09-01/workflowtriggers/constants.go @@ -1,6 +1,10 @@ package workflowtriggers -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. @@ -29,6 +33,19 @@ func PossibleValuesForDayOfWeek() []string { } } +func (s *DayOfWeek) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDayOfWeek(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseDayOfWeek(input string) (*DayOfWeek, error) { vals := map[string]DayOfWeek{ "friday": DayOfWeekFriday, @@ -72,6 +89,19 @@ func PossibleValuesForDaysOfWeek() []string { } } +func (s *DaysOfWeek) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDaysOfWeek(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseDaysOfWeek(input string) (*DaysOfWeek, error) { vals := map[string]DaysOfWeek{ "friday": DaysOfWeekFriday, @@ -117,6 +147,19 @@ func PossibleValuesForRecurrenceFrequency() []string { } } +func (s *RecurrenceFrequency) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRecurrenceFrequency(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseRecurrenceFrequency(input string) (*RecurrenceFrequency, error) { vals := map[string]RecurrenceFrequency{ "day": RecurrenceFrequencyDay, @@ -159,6 +202,19 @@ func PossibleValuesForWorkflowState() []string { } } +func (s *WorkflowState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseWorkflowState(input string) (*WorkflowState, error) { vals := map[string]WorkflowState{ "completed": WorkflowStateCompleted, @@ -213,6 +269,19 @@ func PossibleValuesForWorkflowStatus() []string { } } +func (s *WorkflowStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseWorkflowStatus(input string) (*WorkflowStatus, error) { vals := map[string]WorkflowStatus{ "aborted": WorkflowStatusAborted, @@ -284,6 +353,19 @@ func PossibleValuesForWorkflowTriggerProvisioningState() []string { } } +func (s *WorkflowTriggerProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowTriggerProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseWorkflowTriggerProvisioningState(input string) (*WorkflowTriggerProvisioningState, error) { vals := map[string]WorkflowTriggerProvisioningState{ "accepted": WorkflowTriggerProvisioningStateAccepted, diff --git a/resource-manager/web/2022-09-01/workflowtriggers/method_get.go b/resource-manager/web/2022-09-01/workflowtriggers/method_get.go new file mode 100644 index 00000000000..29009bd15ab --- /dev/null +++ b/resource-manager/web/2022-09-01/workflowtriggers/method_get.go @@ -0,0 +1,51 @@ +package workflowtriggers + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkflowTrigger +} + +// Get ... +func (c WorkflowTriggersClient) Get(ctx context.Context, id TriggerId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/workflowtriggers/method_get_autorest.go b/resource-manager/web/2022-09-01/workflowtriggers/method_get_autorest.go deleted file mode 100644 index 4a2655a974e..00000000000 --- a/resource-manager/web/2022-09-01/workflowtriggers/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package workflowtriggers - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *WorkflowTrigger -} - -// Get ... -func (c WorkflowTriggersClient) Get(ctx context.Context, id TriggerId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowtriggers.WorkflowTriggersClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowtriggers.WorkflowTriggersClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowtriggers.WorkflowTriggersClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c WorkflowTriggersClient) preparerForGet(ctx context.Context, id TriggerId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c WorkflowTriggersClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/workflowtriggers/method_getschemajson.go b/resource-manager/web/2022-09-01/workflowtriggers/method_getschemajson.go new file mode 100644 index 00000000000..cbb20a93fd0 --- /dev/null +++ b/resource-manager/web/2022-09-01/workflowtriggers/method_getschemajson.go @@ -0,0 +1,52 @@ +package workflowtriggers + +import ( + "context" + "fmt" + "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 GetSchemaJsonOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *JsonSchema +} + +// GetSchemaJson ... +func (c WorkflowTriggersClient) GetSchemaJson(ctx context.Context, id TriggerId) (result GetSchemaJsonOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/schemas/json", 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 +} diff --git a/resource-manager/web/2022-09-01/workflowtriggers/method_getschemajson_autorest.go b/resource-manager/web/2022-09-01/workflowtriggers/method_getschemajson_autorest.go deleted file mode 100644 index 9c8ea932113..00000000000 --- a/resource-manager/web/2022-09-01/workflowtriggers/method_getschemajson_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package workflowtriggers - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetSchemaJsonOperationResponse struct { - HttpResponse *http.Response - Model *JsonSchema -} - -// GetSchemaJson ... -func (c WorkflowTriggersClient) GetSchemaJson(ctx context.Context, id TriggerId) (result GetSchemaJsonOperationResponse, err error) { - req, err := c.preparerForGetSchemaJson(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowtriggers.WorkflowTriggersClient", "GetSchemaJson", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowtriggers.WorkflowTriggersClient", "GetSchemaJson", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGetSchemaJson(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowtriggers.WorkflowTriggersClient", "GetSchemaJson", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGetSchemaJson prepares the GetSchemaJson request. -func (c WorkflowTriggersClient) preparerForGetSchemaJson(ctx context.Context, id TriggerId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/schemas/json", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGetSchemaJson handles the response to the GetSchemaJson request. The method always -// closes the http.Response Body. -func (c WorkflowTriggersClient) responderForGetSchemaJson(resp *http.Response) (result GetSchemaJsonOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/workflowtriggers/method_list.go b/resource-manager/web/2022-09-01/workflowtriggers/method_list.go new file mode 100644 index 00000000000..184517ab028 --- /dev/null +++ b/resource-manager/web/2022-09-01/workflowtriggers/method_list.go @@ -0,0 +1,121 @@ +package workflowtriggers + +import ( + "context" + "fmt" + "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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WorkflowTrigger +} + +type ListCompleteResult struct { + Items []WorkflowTrigger +} + +type ListOperationOptions struct { + Filter *string + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// List ... +func (c WorkflowTriggersClient) List(ctx context.Context, id ManagementWorkflowId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/triggers", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]WorkflowTrigger `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c WorkflowTriggersClient) ListComplete(ctx context.Context, id ManagementWorkflowId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, WorkflowTriggerOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WorkflowTriggersClient) ListCompleteMatchingPredicate(ctx context.Context, id ManagementWorkflowId, options ListOperationOptions, predicate WorkflowTriggerOperationPredicate) (result ListCompleteResult, err error) { + items := make([]WorkflowTrigger, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/workflowtriggers/method_list_autorest.go b/resource-manager/web/2022-09-01/workflowtriggers/method_list_autorest.go deleted file mode 100644 index 5e2fd64c8c9..00000000000 --- a/resource-manager/web/2022-09-01/workflowtriggers/method_list_autorest.go +++ /dev/null @@ -1,220 +0,0 @@ -package workflowtriggers - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListOperationResponse struct { - HttpResponse *http.Response - Model *[]WorkflowTrigger - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []WorkflowTrigger -} - -func (r ListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListOperationOptions struct { - Filter *string - Top *int64 -} - -func DefaultListOperationOptions() ListOperationOptions { - return ListOperationOptions{} -} - -func (o ListOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Filter != nil { - out["$filter"] = *o.Filter - } - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// List ... -func (c WorkflowTriggersClient) List(ctx context.Context, id ManagementWorkflowId, options ListOperationOptions) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowtriggers.WorkflowTriggersClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowtriggers.WorkflowTriggersClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowtriggers.WorkflowTriggersClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c WorkflowTriggersClient) preparerForList(ctx context.Context, id ManagementWorkflowId, options ListOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/triggers", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c WorkflowTriggersClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForList handles the response to the List request. The method always -// closes the http.Response Body. -func (c WorkflowTriggersClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []WorkflowTrigger `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { - req, err := c.preparerForListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowtriggers.WorkflowTriggersClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowtriggers.WorkflowTriggersClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowtriggers.WorkflowTriggersClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c WorkflowTriggersClient) ListComplete(ctx context.Context, id ManagementWorkflowId, options ListOperationOptions) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, options, WorkflowTriggerOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WorkflowTriggersClient) ListCompleteMatchingPredicate(ctx context.Context, id ManagementWorkflowId, options ListOperationOptions, predicate WorkflowTriggerOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]WorkflowTrigger, 0) - - page, err := c.List(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -} diff --git a/resource-manager/web/2022-09-01/workflowtriggers/method_listcallbackurl.go b/resource-manager/web/2022-09-01/workflowtriggers/method_listcallbackurl.go new file mode 100644 index 00000000000..b4edba4d041 --- /dev/null +++ b/resource-manager/web/2022-09-01/workflowtriggers/method_listcallbackurl.go @@ -0,0 +1,52 @@ +package workflowtriggers + +import ( + "context" + "fmt" + "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 ListCallbackUrlOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkflowTriggerCallbackUrl +} + +// ListCallbackUrl ... +func (c WorkflowTriggersClient) ListCallbackUrl(ctx context.Context, id TriggerId) (result ListCallbackUrlOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listCallbackUrl", 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 +} diff --git a/resource-manager/web/2022-09-01/workflowtriggers/method_listcallbackurl_autorest.go b/resource-manager/web/2022-09-01/workflowtriggers/method_listcallbackurl_autorest.go deleted file mode 100644 index 0f7e30a34eb..00000000000 --- a/resource-manager/web/2022-09-01/workflowtriggers/method_listcallbackurl_autorest.go +++ /dev/null @@ -1,69 +0,0 @@ -package workflowtriggers - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListCallbackUrlOperationResponse struct { - HttpResponse *http.Response - Model *WorkflowTriggerCallbackUrl -} - -// ListCallbackUrl ... -func (c WorkflowTriggersClient) ListCallbackUrl(ctx context.Context, id TriggerId) (result ListCallbackUrlOperationResponse, err error) { - req, err := c.preparerForListCallbackUrl(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowtriggers.WorkflowTriggersClient", "ListCallbackUrl", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowtriggers.WorkflowTriggersClient", "ListCallbackUrl", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForListCallbackUrl(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowtriggers.WorkflowTriggersClient", "ListCallbackUrl", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForListCallbackUrl prepares the ListCallbackUrl request. -func (c WorkflowTriggersClient) preparerForListCallbackUrl(ctx context.Context, id TriggerId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/listCallbackUrl", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForListCallbackUrl handles the response to the ListCallbackUrl request. The method always -// closes the http.Response Body. -func (c WorkflowTriggersClient) responderForListCallbackUrl(resp *http.Response) (result ListCallbackUrlOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/workflowtriggers/method_run.go b/resource-manager/web/2022-09-01/workflowtriggers/method_run.go new file mode 100644 index 00000000000..93331b77c3d --- /dev/null +++ b/resource-manager/web/2022-09-01/workflowtriggers/method_run.go @@ -0,0 +1,70 @@ +package workflowtriggers + +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 RunOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Run ... +func (c WorkflowTriggersClient) Run(ctx context.Context, id TriggerId) (result RunOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/run", 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 +} + +// RunThenPoll performs Run then polls until it's completed +func (c WorkflowTriggersClient) RunThenPoll(ctx context.Context, id TriggerId) error { + result, err := c.Run(ctx, id) + if err != nil { + return fmt.Errorf("performing Run: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Run: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2022-09-01/workflowtriggers/method_run_autorest.go b/resource-manager/web/2022-09-01/workflowtriggers/method_run_autorest.go deleted file mode 100644 index 4234c1f4d63..00000000000 --- a/resource-manager/web/2022-09-01/workflowtriggers/method_run_autorest.go +++ /dev/null @@ -1,78 +0,0 @@ -package workflowtriggers - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/polling" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type RunOperationResponse struct { - Poller polling.LongRunningPoller - HttpResponse *http.Response -} - -// Run ... -func (c WorkflowTriggersClient) Run(ctx context.Context, id TriggerId) (result RunOperationResponse, err error) { - req, err := c.preparerForRun(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowtriggers.WorkflowTriggersClient", "Run", nil, "Failure preparing request") - return - } - - result, err = c.senderForRun(ctx, req) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowtriggers.WorkflowTriggersClient", "Run", result.HttpResponse, "Failure sending request") - return - } - - return -} - -// RunThenPoll performs Run then polls until it's completed -func (c WorkflowTriggersClient) RunThenPoll(ctx context.Context, id TriggerId) error { - result, err := c.Run(ctx, id) - if err != nil { - return fmt.Errorf("performing Run: %+v", err) - } - - if err := result.Poller.PollUntilDone(); err != nil { - return fmt.Errorf("polling after Run: %+v", err) - } - - return nil -} - -// preparerForRun prepares the Run request. -func (c WorkflowTriggersClient) preparerForRun(ctx context.Context, id TriggerId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(fmt.Sprintf("%s/run", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// senderForRun sends the Run request. The method will close the -// http.Response Body if it receives an error. -func (c WorkflowTriggersClient) senderForRun(ctx context.Context, req *http.Request) (future RunOperationResponse, err error) { - var resp *http.Response - resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - return - } - - future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) - return -} diff --git a/resource-manager/web/2022-09-01/workflowversions/client.go b/resource-manager/web/2022-09-01/workflowversions/client.go index 852f837301e..1e35b4c3284 100644 --- a/resource-manager/web/2022-09-01/workflowversions/client.go +++ b/resource-manager/web/2022-09-01/workflowversions/client.go @@ -1,18 +1,26 @@ package workflowversions -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 WorkflowVersionsClient struct { - Client autorest.Client - baseUri string + Client *resourcemanager.Client } -func NewWorkflowVersionsClientWithBaseURI(endpoint string) WorkflowVersionsClient { - return WorkflowVersionsClient{ - Client: autorest.NewClientWithUserAgent(userAgent()), - baseUri: endpoint, +func NewWorkflowVersionsClientWithBaseURI(api environments.Api) (*WorkflowVersionsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(api, "workflowversions", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating WorkflowVersionsClient: %+v", err) } + + return &WorkflowVersionsClient{ + Client: client, + }, nil } diff --git a/resource-manager/web/2022-09-01/workflowversions/constants.go b/resource-manager/web/2022-09-01/workflowversions/constants.go index 71aed1d028b..fe1be75f3e9 100644 --- a/resource-manager/web/2022-09-01/workflowversions/constants.go +++ b/resource-manager/web/2022-09-01/workflowversions/constants.go @@ -1,6 +1,10 @@ package workflowversions -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. @@ -17,6 +21,19 @@ func PossibleValuesForOpenAuthenticationProviderType() []string { } } +func (s *OpenAuthenticationProviderType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOpenAuthenticationProviderType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseOpenAuthenticationProviderType(input string) (*OpenAuthenticationProviderType, error) { vals := map[string]OpenAuthenticationProviderType{ "aad": OpenAuthenticationProviderTypeAAD, @@ -58,6 +75,19 @@ func PossibleValuesForParameterType() []string { } } +func (s *ParameterType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseParameterType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseParameterType(input string) (*ParameterType, error) { vals := map[string]ParameterType{ "array": ParameterTypeArray, @@ -133,6 +163,19 @@ func PossibleValuesForWorkflowProvisioningState() []string { } } +func (s *WorkflowProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseWorkflowProvisioningState(input string) (*WorkflowProvisioningState, error) { vals := map[string]WorkflowProvisioningState{ "accepted": WorkflowProvisioningStateAccepted, @@ -189,6 +232,19 @@ func PossibleValuesForWorkflowSkuName() []string { } } +func (s *WorkflowSkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseWorkflowSkuName(input string) (*WorkflowSkuName, error) { vals := map[string]WorkflowSkuName{ "basic": WorkflowSkuNameBasic, @@ -229,6 +285,19 @@ func PossibleValuesForWorkflowState() []string { } } +func (s *WorkflowState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + func parseWorkflowState(input string) (*WorkflowState, error) { vals := map[string]WorkflowState{ "completed": WorkflowStateCompleted, diff --git a/resource-manager/web/2022-09-01/workflowversions/method_get.go b/resource-manager/web/2022-09-01/workflowversions/method_get.go new file mode 100644 index 00000000000..14f760a02d8 --- /dev/null +++ b/resource-manager/web/2022-09-01/workflowversions/method_get.go @@ -0,0 +1,51 @@ +package workflowversions + +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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkflowVersion +} + +// Get ... +func (c WorkflowVersionsClient) Get(ctx context.Context, id VersionId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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 +} diff --git a/resource-manager/web/2022-09-01/workflowversions/method_get_autorest.go b/resource-manager/web/2022-09-01/workflowversions/method_get_autorest.go deleted file mode 100644 index a43a8b7d34a..00000000000 --- a/resource-manager/web/2022-09-01/workflowversions/method_get_autorest.go +++ /dev/null @@ -1,68 +0,0 @@ -package workflowversions - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type GetOperationResponse struct { - HttpResponse *http.Response - Model *WorkflowVersion -} - -// Get ... -func (c WorkflowVersionsClient) Get(ctx context.Context, id VersionId) (result GetOperationResponse, err error) { - req, err := c.preparerForGet(ctx, id) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowversions.WorkflowVersionsClient", "Get", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowversions.WorkflowVersionsClient", "Get", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForGet(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowversions.WorkflowVersionsClient", "Get", result.HttpResponse, "Failure responding to request") - return - } - - return -} - -// preparerForGet prepares the Get request. -func (c WorkflowVersionsClient) preparerForGet(ctx context.Context, id VersionId) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(id.ID()), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForGet handles the response to the Get request. The method always -// closes the http.Response Body. -func (c WorkflowVersionsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp - - return -} diff --git a/resource-manager/web/2022-09-01/workflowversions/method_list.go b/resource-manager/web/2022-09-01/workflowversions/method_list.go new file mode 100644 index 00000000000..3b756823bd1 --- /dev/null +++ b/resource-manager/web/2022-09-01/workflowversions/method_list.go @@ -0,0 +1,117 @@ +package workflowversions + +import ( + "context" + "fmt" + "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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WorkflowVersion +} + +type ListCompleteResult struct { + Items []WorkflowVersion +} + +type ListOperationOptions struct { + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// List ... +func (c WorkflowVersionsClient) List(ctx context.Context, id ManagementWorkflowId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/versions", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]WorkflowVersion `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c WorkflowVersionsClient) ListComplete(ctx context.Context, id ManagementWorkflowId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, WorkflowVersionOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WorkflowVersionsClient) ListCompleteMatchingPredicate(ctx context.Context, id ManagementWorkflowId, options ListOperationOptions, predicate WorkflowVersionOperationPredicate) (result ListCompleteResult, err error) { + items := make([]WorkflowVersion, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/web/2022-09-01/workflowversions/method_list_autorest.go b/resource-manager/web/2022-09-01/workflowversions/method_list_autorest.go deleted file mode 100644 index 782df17335e..00000000000 --- a/resource-manager/web/2022-09-01/workflowversions/method_list_autorest.go +++ /dev/null @@ -1,215 +0,0 @@ -package workflowversions - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type ListOperationResponse struct { - HttpResponse *http.Response - Model *[]WorkflowVersion - - nextLink *string - nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) -} - -type ListCompleteResult struct { - Items []WorkflowVersion -} - -func (r ListOperationResponse) HasMore() bool { - return r.nextLink != nil -} - -func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { - if !r.HasMore() { - err = fmt.Errorf("no more pages returned") - return - } - return r.nextPageFunc(ctx, *r.nextLink) -} - -type ListOperationOptions struct { - Top *int64 -} - -func DefaultListOperationOptions() ListOperationOptions { - return ListOperationOptions{} -} - -func (o ListOperationOptions) toHeaders() map[string]interface{} { - out := make(map[string]interface{}) - - return out -} - -func (o ListOperationOptions) toQueryString() map[string]interface{} { - out := make(map[string]interface{}) - - if o.Top != nil { - out["$top"] = *o.Top - } - - return out -} - -// List ... -func (c WorkflowVersionsClient) List(ctx context.Context, id ManagementWorkflowId, options ListOperationOptions) (resp ListOperationResponse, err error) { - req, err := c.preparerForList(ctx, id, options) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowversions.WorkflowVersionsClient", "List", nil, "Failure preparing request") - return - } - - resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowversions.WorkflowVersionsClient", "List", resp.HttpResponse, "Failure sending request") - return - } - - resp, err = c.responderForList(resp.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowversions.WorkflowVersionsClient", "List", resp.HttpResponse, "Failure responding to request") - return - } - return -} - -// preparerForList prepares the List request. -func (c WorkflowVersionsClient) preparerForList(ctx context.Context, id ManagementWorkflowId, options ListOperationOptions) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "api-version": defaultApiVersion, - } - - for k, v := range options.toQueryString() { - queryParameters[k] = autorest.Encode("query", v) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithHeaders(options.toHeaders()), - autorest.WithPath(fmt.Sprintf("%s/versions", id.ID())), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// preparerForListWithNextLink prepares the List request with the given nextLink token. -func (c WorkflowVersionsClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { - uri, err := url.Parse(nextLink) - if err != nil { - return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) - } - queryParameters := map[string]interface{}{} - for k, v := range uri.Query() { - if len(v) == 0 { - continue - } - val := v[0] - val = autorest.Encode("query", val) - queryParameters[k] = val - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(c.baseUri), - autorest.WithPath(uri.Path), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// responderForList handles the response to the List request. The method always -// closes the http.Response Body. -func (c WorkflowVersionsClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { - type page struct { - Values []WorkflowVersion `json:"value"` - NextLink *string `json:"nextLink"` - } - var respObj page - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&respObj), - autorest.ByClosing()) - result.HttpResponse = resp - result.Model = &respObj.Values - result.nextLink = respObj.NextLink - if respObj.NextLink != nil { - result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { - req, err := c.preparerForListWithNextLink(ctx, nextLink) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowversions.WorkflowVersionsClient", "List", nil, "Failure preparing request") - return - } - - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowversions.WorkflowVersionsClient", "List", result.HttpResponse, "Failure sending request") - return - } - - result, err = c.responderForList(result.HttpResponse) - if err != nil { - err = autorest.NewErrorWithError(err, "workflowversions.WorkflowVersionsClient", "List", result.HttpResponse, "Failure responding to request") - return - } - - return - } - } - return -} - -// ListComplete retrieves all of the results into a single object -func (c WorkflowVersionsClient) ListComplete(ctx context.Context, id ManagementWorkflowId, options ListOperationOptions) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, options, WorkflowVersionOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate -func (c WorkflowVersionsClient) ListCompleteMatchingPredicate(ctx context.Context, id ManagementWorkflowId, options ListOperationOptions, predicate WorkflowVersionOperationPredicate) (resp ListCompleteResult, err error) { - items := make([]WorkflowVersion, 0) - - page, err := c.List(ctx, id, options) - if err != nil { - err = fmt.Errorf("loading the initial page: %+v", err) - return - } - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - - for page.HasMore() { - page, err = page.LoadMore(ctx) - if err != nil { - err = fmt.Errorf("loading the next page: %+v", err) - return - } - - if page.Model != nil { - for _, v := range *page.Model { - if predicate.Matches(v) { - items = append(items, v) - } - } - } - } - - out := ListCompleteResult{ - Items: items, - } - return out, nil -}